diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2016-07-04 21:53:55 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2016-07-04 21:53:55 +0200 |
commit | c7fb7dfd794700bf6977a907a8612e9b644e4fe4 (patch) | |
tree | 57bd9a7f0499c795cf7aa9ba2f1c08ef406df847 /cmake/elfinfo/src/main/antlr4 | |
parent | ead2f1961fc653861a151a033c3cd0657c50af16 (diff) | |
download | intel-quark-d2000-playground-c7fb7dfd794700bf6977a907a8612e9b644e4fe4.tar.gz intel-quark-d2000-playground-c7fb7dfd794700bf6977a907a8612e9b644e4fe4.tar.bz2 intel-quark-d2000-playground-c7fb7dfd794700bf6977a907a8612e9b644e4fe4.tar.xz intel-quark-d2000-playground-c7fb7dfd794700bf6977a907a8612e9b644e4fe4.zip |
o Improved parser.
Diffstat (limited to 'cmake/elfinfo/src/main/antlr4')
-rw-r--r-- | cmake/elfinfo/src/main/antlr4/Test1Lexer.g4 | 22 | ||||
-rw-r--r-- | cmake/elfinfo/src/main/antlr4/Test1Parser.g4 | 23 |
2 files changed, 45 insertions, 0 deletions
diff --git a/cmake/elfinfo/src/main/antlr4/Test1Lexer.g4 b/cmake/elfinfo/src/main/antlr4/Test1Lexer.g4 new file mode 100644 index 0000000..142229d --- /dev/null +++ b/cmake/elfinfo/src/main/antlr4/Test1Lexer.g4 @@ -0,0 +1,22 @@ +lexer grammar Test1Lexer; + +channels { + WHITESPACE_CHANNEL +} + +NAME : [a-z]+; + +// Characters +C_PLUS : '+'; +C_MINUS : '-'; +C_QUOTE : '"' -> skip, pushMode(STRING); + +//SPACE : [ ]; + +WS + : [ \t\r\n]+ -> channel(WHITESPACE_CHANNEL) + ; + +mode STRING; +STRING_ANY : ~'"'; +STRING_END_QUOTE : '"' -> skip, popMode; diff --git a/cmake/elfinfo/src/main/antlr4/Test1Parser.g4 b/cmake/elfinfo/src/main/antlr4/Test1Parser.g4 new file mode 100644 index 0000000..affdfe5 --- /dev/null +++ b/cmake/elfinfo/src/main/antlr4/Test1Parser.g4 @@ -0,0 +1,23 @@ +parser grammar Test1Parser; + +options { + tokenVocab = Test1Lexer; +} + +name + : NAME + | STRING_ANY* + ; + +file + : stmt* + ; + +stmt + : expr + ; + +expr + : name C_PLUS name + | name C_MINUS name + ; |