Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pattern source_code =
- {
- lines = (any, ['\n'])|repeat =>
- tokens = any of
- (
- private whitespace = (any of ' \t\r')|repeat
- symbol = (any of '~`!@#$%^&*+-=;:\'",.?/\\|')|repeat
- brackets = any of '(){}[]<>'
- invalid = (any < 32 except whitespace)|repeat
- literal = any of
- (
- number = any of
- (
- decimal = any of
- (
- private nonnegative_int = (any of '0123456789')|repeat
- int = ['-'], nonnegative_int
- float = ([int], '.', [nonnegative_int]).mask > 0, ['e'|nocase, int]
- )
- hex = {
- int = ['-'], '0x', (any of '0123456789ABCDEF'|nocase)|repeat
- }
- )
- string = any of (
- single_quoted = '\'', any eat '\\\'', '\''
- double_quoted = '"', any eat '\\"', '"'
- )
- )
- word = any left
- )|repeat =>
- objects =
- (
- pattern class_path = [(word|lowercase, ['.', word|lowercase])|repeat]
- pattern class_name = word{0|uppercase}, any
- pattern full_class_name = [class_path, '.'], class_name
- pattern var_name = word
- pattern function_name = word
- pattern operator = symbol
- pattern type_name = class_name
- pattern arguments_list = (var_name, [':', type_name]), [',', arguments_list]
- pattern block = any of ((expression, ';'), '{', content == block|repeat, '}')
- pattern expression = any of
- (
- var_name
- literal
- '('
- content = expression
- ')'
- ), [operator, expression]
- package = 'package', [class_path], ';'
- imports = any of
- (
- import = 'import', class_path, ['.*'], ';'
- using = 'using', class_path, ';'
- )|repeat
- pattern class =
- (
- 'class', name = class_name, ['extends', full_class_name], [('implements', full_class_name)|repeat]
- '{'
- content == any of
- (
- var = [any of ('public', 'private', 'static', 'inline')|repeat once], 'var', name = var_name, ['=', expression], ';'
- function =
- (
- attribs = [any of ('public', 'private', 'static', 'inline')|repeat once]
- 'function'
- name = function_name
- args = '(', content == [arguments_list], ')'
- block = block
- )
- )|repeat
- '}'
- )
- definitions = (class)|repeat
- )
- }
Advertisement
Add Comment
Please, Sign In to add comment