Created
March 21, 2013 03:08
-
-
Save 0x00b1/5210402 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar Grammar; | |
fragment Uppercase : [A-Z] | '$' | '_' ; | |
fragment Lowercase : [a-z] ; | |
fragment Letter : Uppercase | Lowercase ; | |
fragment Operator : [\u0020-\u007F]+ ; | |
fragment Body : (Letter | [0-9])* ('_' Operator) ; | |
fragment Decimal : '0' | [1-9] [0-9]* ; | |
fragment Hexadecimal : '0' 'x' [0-9A-Fa-f]+ ; | |
fragment Octal : '0' [0-7]+ ; | |
fragment Exponent : [Ee] ('+' | '-')? [0-9]+ ; | |
fragment Float : [DdFf] ; | |
fragment SingleQuotationMark : '\u2019' | '\u0022' | '\u0027' ; | |
fragment DoubleQuotationMark : '\u0022' | '\u201C' | '\u201D' ; | |
VARIABLE : Lowercase Body ; | |
IDENTIFIER : Uppercase Body | VARIABLE | Operator ; | |
INTEGER : (Decimal | Hexadecimal | Octal) ('L' | 'l') ; | |
FLOAT : [0-9]+ '.' [0-9]* Exponent? Float? | |
| '.' [0-9]+ Exponent? Float? | |
| [0-9]+ Exponent Float? | |
| [0-9]+ Exponent? Float ; | |
BOOLEAN : 'true' | 'false' ; | |
CHARACTER : SingleQuotationMark [\u0080-\ufffe] SingleQuotationMark ; | |
STRING : DoubleQuotationMark [\u0080-\ufffe]+ DoubleQuotationMark ; | |
NEWLINE : ';' | |
| [\u000A-\u000D] | '\u000D\u000A' | '\u0085' | [\u2028-\u2029] ; | |
WHITESPACE : ('\u0020' | '\u0009' | '\u000D' | '\u000A') -> skip ; | |
COMMENT : ('/*' .*? '*/' | '//' .*? NEWLINE) -> skip ; | |
literal : ('-')? INTEGER | |
| ('-')? FLOAT | |
| BOOLEAN | |
| CHARACTER | |
| STRING | |
| 'null' ; | |
identifiers : IDENTIFIER (',' IDENTIFIER)* ; | |
expression : (IDENTIFIER | '_') '\u21D2' expression | |
| expression1 ; | |
expression1 : 'if' expression (NEWLINE)? expression | |
((NEWLINE)? 'else' expression)? | |
| postfix ; | |
postfix : infix (IDENTIFIER (NEWLINE)?)? ; | |
infix : prefix | |
| infix IDENTIFIER (NEWLINE)? infix ; | |
prefix : ('-' | '+' | '~' | '!')? simple ; | |
simple : simple1 ('_')? ; | |
simple1 : literal | |
| '_' | |
| '(' (expression)? ')' ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment