So, I started converting from ANTLR to CongoCC and I did not get any result
// Configuration
BASE_SRC_DIR="../../";
PARSER_PACKAGE="congocc.test.generated";
//================================================================================
// PARSER
//================================================================================
Document : // Entry point
UINode!
<EOF>!;
UINode :
<Identifier> <LBRACE> (Property)* <RBRACE>;
Property :
<Identifier> <COLON> Type;
Type :
<STRING>;
//================================================================================
// LEXER
//================================================================================
// Skip whitespaces and comments
SKIP : <Whitespace : (" "| "\t" | "\n" | "\r")+>;
UNPARSED #Comment :
<COMMENT : "#" (~["\n"])*>;
// Symbols
TOKEN #Symbol :
<EQUALS : '='>
| <PLUS_EQUALS : '+='>
| <LPAREN : '('>
| <RPAREN : ')'>
| <LBRACK : '['>
| <RBRACK : ']'>
| <LBRACE : '{'>
| <RBRACE : '}'>
| <COLON : ':'>
| <COMMA : ','>
| <DOT : '.'>;
TOKEN #Keyword :
<THIS : 'this'>
| <BOOLEAN : ('true' | 'false')>
| <INFINITY : ('Infinity' | '-Infinity')>
| <NAN : 'NaN'>
| <NULL : 'null'>;
// Types
TOKEN #Types :
// Literals
<CHAR : "'" (~["'", "\\", "\n", "\r"] | '\\') "'">
| <STRING : ("'" (~["'", "\\", "\n", "\r"] | '\\')* "'" | "\"" (~["\"", "\\", "\n", "\r"] | '\\')* "\"")>
// Integers
| <INTEGER : ["0"-"9"]((["0"-"9","_"])*["0"-"9"])?>
| <LONG : <INTEGER> (['l', 'L'])>
| <HEX : '0'['x', 'X'] (["0"-"9","a"-"f","A"-"F"])+>
| <BINARY : '0'['b', 'B'] (['0', '1'])+>
| <OCTAL : '0' (['0'-'7'])+>
// Floating point
| <FLOAT : (<INTEGER>)? '.' <INTEGER> (['e', 'E'] ['+', '-'] <INTEGER>)? ['f', 'F']>
| <DOUBLE : (<INTEGER>)? '.' <INTEGER> (['e', 'E'] ['+', '-'] <INTEGER>)? (['d', 'D'])?>;
// Identifiers
TOKEN : <Identifier : ["a"-"z", "A"-"Z", "$", "_"] (["a"-"z", "A"-"Z", "$", "_"] | ((["+", "-"])?["0"-"9"]))*>;
Aside the lexer rules which I know for sure can be optimized/written differently. The parser returns null
for rootNode()
.
For sure, the parser grammar is wrong. Point is, the lack of proper documentation makes this tool even harder to use than competitors. CongoCC makes the bold assumption that a user already knows some of this stuff, but I'm a complete neophyte.
Also, the visitor generated by ANTLR is much more intuitive to use, it all feels more 'automatic'