ANTLR newbie here.
I just got into ANTLR recently and I am trying to parse IP tables using antlr.
This is the error I got:
syntax error: unterminated rule (missing ‘;’) detected at ‘status_line :’ while looking for rule element
The code snippets are below for the relatewd lexers and parsers. How should I fix this?
//parser
status_line
: 'Chain' chain_name '(' 'policy' policy PKTS 'pkts,' BYTES 'bytes)'
;
chain_name
: 'INPUT' | 'FORWARD' | 'OUTPUT' | CUSTOM_CHAIN
;
policy
: 'ACCEPT' | 'DROP' | 'QUEUE' | 'RETURN'
;
//lexer
PKTS
: [0-9]+
;
BYTES
: [0-9]+
;
CUSTOM_CHAIN
: [a-zA-Z_][a-zA-Z0-9_]*
;
I havbe double checked my tokens and separated ‘bytes’ ‘)’, not sure if I am just having a brain fart right now.
There was also a general error of: syntax error: mismatched character ‘:’ expecting ‘{‘ without indicating what line it was at. Not sure if that will help this resolving this error.
Artemis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.