I have defined a ANTLR grammer:
grammar test5;
stats_statement
:
STATS IDENT ASSIGN_SYM functions_stats
;
functions_stats
: COUNT LPAREN IDENT RPAREN
;
STATS
: 'STATS'
;
COUNT
: 'count'
;
IDENT
: (LETTER | '_') (LETTER | DIGIT | '_')*
;
ASSIGN_SYM
: ':='
;
COMMA_SYM
: ','
;
SEMI_SYM
: ';'
;
LPAREN
: '(' ;
RPAREN
: ')' ;
fragment
LETTER : ('a'..'z' | 'A'..'Z') ;
fragment
DIGIT : '0'..'9';
which has one build-in function "count". But if I use the following test string:
STATS count:=count(col1)
the parser will return an error saying:
mismatched input 'count' expecting IDENT
any clue and/or hints on how to fix this problem?
Thanks Charles
Create an ident rule that matched both IDENT and COUNT and use that rule in your parser rules (instead of using IDENT):
stats_statement
: STATS ident ASSIGN_SYM functions_stats
;
functions_stats
: COUNT LPAREN ident RPAREN
;
ident
: COUNT
| IDENT
;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With