I am attempting to parse Lua, which depends on whitespace in some cases due to the fact that it doesn’t use braces for scope. I figure that by throwing out whitespace only if another rule doesn’t match is the best way, but i have no clue how to do that. Can someone help me?
Share
Looking at Lua’s documentation, I see no need to take spaces into account.
The parser rule
ifStatement:should match both:
and:
No need to take spaces into account, AFAIK. So you can just add:
in your grammar.
EDIT
It seems there is a Lua grammar on the ANTLR wiki: http://www.antlr.org/grammar/1178608849736/Lua.g
And it seems I my suggestion for an if statement slightly differs from the grammar above:
which is the correct one, as you can see.