[antlr-interest] Multi-level format parsing
Martin Probst
mail at martin-probst.com
Wed May 10 23:55:42 PDT 2006
Hi,
> stmt_assign : LITERAL EQU QUOTEDLITERAL ;
>
> And later, after 1st level parsing, I remove quotes from
> QUOTEDLITERAL and parse it again.
>
> But I would like to add this code directly to ANTLR grammar.
Does every literal contain executable code? How do you detect if it's
supposed to contain code?
You could probably do something with nested parsers and lexers, but
maybe you could also employ some sort of hack with lexer states, so
like if the literal before the EQU was "CodeParam" then ignore the
quotes and parse the code directly.
An important question is maybe also how you want to disambiguate between
CodeParam = "Var2 = ""text"""
and
CodeParam = Var2 = ""text""
Martin
More information about the antlr-interest
mailing list