-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up the basic structure of the project
- Loading branch information
Showing
35 changed files
with
15,464 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
*/bin/* | ||
bin/ | ||
|
||
*.class | ||
|
||
# Package Files # | ||
*.war | ||
*.ear | ||
|
||
|
||
# Eclipse | ||
.settings/ | ||
*.project | ||
*.classpath | ||
.prefs | ||
*.prefs | ||
.metadata/ | ||
|
||
# Intellij | ||
.idea/ | ||
*.iml | ||
*.iws | ||
out/ | ||
|
||
# VSCode | ||
.vscode/ | ||
|
||
# Mac | ||
.DS_Store | ||
|
||
# Maven | ||
log/* | ||
target/ | ||
|
||
# Gradle | ||
.gradle/ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
lexer grammar CommonLexer; | ||
|
||
// Keywords | ||
|
||
ABSTRACT: 'abstract'; | ||
ASSERT: 'assert'; | ||
BOOLEAN: 'boolean'; | ||
BREAK: 'break'; | ||
BYTE: 'byte'; | ||
CASE: 'case'; | ||
CATCH: 'catch'; | ||
CHAR: 'char'; | ||
CLASS: 'class'; | ||
CONST: 'const'; | ||
CONTINUE: 'continue'; | ||
DEFAULT: 'default'; | ||
DO: 'do'; | ||
DOUBLE: 'double'; | ||
ELSE: 'else'; | ||
ENUM: 'enum'; | ||
EXTENDS: 'extends'; | ||
FINAL: 'final'; | ||
FINALLY: 'finally'; | ||
FLOAT: 'float'; | ||
FOR: 'for'; | ||
IF: 'if'; | ||
GOTO: 'goto'; | ||
IMPLEMENTS: 'implements'; | ||
IMPORT: 'import'; | ||
INSTANCEOF: 'instanceof'; | ||
INT: 'int'; | ||
INTERFACE: 'interface'; | ||
LONG: 'long'; | ||
NATIVE: 'native'; | ||
NEW: 'new'; | ||
PACKAGE: 'package'; | ||
PRIVATE: 'private'; | ||
PROTECTED: 'protected'; | ||
PUBLIC: 'public'; | ||
RETURN: 'return'; | ||
SHORT: 'short'; | ||
STATIC: 'static'; | ||
STRICTFP: 'strictfp'; | ||
SUPER: 'super'; | ||
SWITCH: 'switch'; | ||
SYNCHRONIZED: 'synchronized'; | ||
THIS: 'this'; | ||
THROW: 'throw'; | ||
THROWS: 'throws'; | ||
TRANSIENT: 'transient'; | ||
TRY: 'try'; | ||
VOID: 'void'; | ||
VOLATILE: 'volatile'; | ||
WHILE: 'while'; | ||
|
||
FUNCTION: 'function'; | ||
|
||
STRING: 'string'; //added on 2019-08-29 by Richard Gong | ||
|
||
// Literals | ||
|
||
DECIMAL_LITERAL: ('0' | [1-9] (Digits? | '_'+ Digits)) [lL]?; | ||
HEX_LITERAL: '0' [xX] [0-9a-fA-F] ([0-9a-fA-F_]* [0-9a-fA-F])? [lL]?; | ||
OCT_LITERAL: '0' '_'* [0-7] ([0-7_]* [0-7])? [lL]?; | ||
BINARY_LITERAL: '0' [bB] [01] ([01_]* [01])? [lL]?; | ||
|
||
FLOAT_LITERAL: (Digits '.' Digits? | '.' Digits) ExponentPart? [fFdD]? | ||
| Digits (ExponentPart [fFdD]? | [fFdD]) | ||
; | ||
|
||
HEX_FLOAT_LITERAL: '0' [xX] (HexDigits '.'? | HexDigits? '.' HexDigits) [pP] [+-]? Digits [fFdD]?; | ||
|
||
BOOL_LITERAL: 'true' | ||
| 'false' | ||
; | ||
|
||
CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence) '\''; | ||
|
||
STRING_LITERAL: '"' (~["\\\r\n] | EscapeSequence)* '"'; | ||
NULL_LITERAL: 'null'; | ||
// Separators | ||
LPAREN: '('; | ||
RPAREN: ')'; | ||
LBRACE: '{'; | ||
RBRACE: '}'; | ||
LBRACK: '['; | ||
RBRACK: ']'; | ||
SEMI: ';'; | ||
COMMA: ','; | ||
DOT: '.'; | ||
// Operators | ||
ASSIGN: '='; | ||
GT: '>'; | ||
LT: '<'; | ||
BANG: '!'; | ||
TILDE: '~'; | ||
QUESTION: '?'; | ||
COLON: ':'; | ||
EQUAL: '=='; | ||
LE: '<='; | ||
GE: '>='; | ||
NOTEQUAL: '!='; | ||
AND: '&&'; | ||
OR: '||'; | ||
INC: '++'; | ||
DEC: '--'; | ||
ADD: '+'; | ||
SUB: '-'; | ||
MUL: '*'; | ||
DIV: '/'; | ||
BITAND: '&'; | ||
BITOR: '|'; | ||
CARET: '^'; | ||
MOD: '%'; | ||
ADD_ASSIGN: '+='; | ||
SUB_ASSIGN: '-='; | ||
MUL_ASSIGN: '*='; | ||
DIV_ASSIGN: '/='; | ||
AND_ASSIGN: '&='; | ||
OR_ASSIGN: '|='; | ||
XOR_ASSIGN: '^='; | ||
MOD_ASSIGN: '%='; | ||
LSHIFT_ASSIGN: '<<='; | ||
RSHIFT_ASSIGN: '>>='; | ||
URSHIFT_ASSIGN: '>>>='; | ||
// Java 8 tokens | ||
ARROW: '->'; | ||
COLONCOLON: '::'; | ||
// Additional symbols not defined in the lexical specification | ||
AT: '@'; | ||
ELLIPSIS: '...'; | ||
// Whitespace and comments | ||
WS: [ \t\r\n\u000C]+ -> channel(HIDDEN); | ||
COMMENT: '/*' .*? '*/' -> channel(HIDDEN); | ||
LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); | ||
|
||
// Identifiers | ||
|
||
IDENTIFIER: Letter LetterOrDigit*; | ||
|
||
// Fragment rules | ||
|
||
fragment ExponentPart | ||
: [eE] [+-]? Digits | ||
; | ||
|
||
fragment EscapeSequence | ||
: '\\' [btnfr"'\\] | ||
| '\\' ([0-3]? [0-7])? [0-7] | ||
| '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit | ||
; | ||
fragment HexDigits | ||
: HexDigit ((HexDigit | '_')* HexDigit)? | ||
; | ||
fragment HexDigit | ||
: [0-9a-fA-F] | ||
; | ||
fragment Digits | ||
: [0-9] ([0-9_]* [0-9])? | ||
; | ||
fragment LetterOrDigit | ||
: Letter | ||
| [0-9] | ||
; | ||
fragment Letter | ||
: [a-zA-Z$_] // these are the "java letters" below 0x7F | ||
| ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate | ||
| [\uD800-\uDBFF] [\uDC00-\uDFFF] // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF | ||
; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
java -jar ./antlr-4.7.2-complete.jar -visitor Fatjs.g4 | ||
|
||
javac *.java | ||
|
||
D:\code\fatjs\antlr>java org.antlr.v4.gui.TestRig Fatjs expression -gui | ||
age + 10 * 2 + 10 | ||
^Z |
Oops, something went wrong.