[antlr-interest] Multi-level format parsing
Spálený Ivo
Ivo.Spaleny at bsp.cz
Wed May 10 14:54:46 PDT 2006
Hi,
How can I create a grammar for multi-level parsing in ANTLR?
For an example - encoded literal, quote escaped. I need to read and parse code in its value too.
CodeParam = "Var2 = ""text"""
where CodeParam includes another code:
Var = "text"
So the resulting tree is something like this:
(to avoid semigraphics experiments, I used XML-like tree)
<nodes>
=
<leftchild>
CodeParam
</leftchild>
<rightchild>
EncodedString
<leftchild>
=
<leftchild>
Var
</leftchild>
<rightchild>
"text"
</rightchild>
</leftchild>
</rightchild>
</nodes>
I can define a grammar rule:
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.
Thank you for any suggestions,
Ivo Spaleny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060510/1763be85/attachment.html
More information about the antlr-interest
mailing list