[antlr-interest] ANTLR3 Nested parser
Bertalan Fodor (LilyPondTool)
lilypondtool at organum.hu
Wed Jan 23 00:20:11 PST 2008
> But, that seems like you will end up lexing a lot of things you should
> not need to this way, especially if you have a lot of embedded
> elements. Perhaps if you mention what you are trying to parse, then
> better solutions can be thought of.
>
>
>
> One other thought is whether the first lexer can determine where the
> embedded language starts and stops in which case you can tokenize the
> whole text into one token and invoke the embedded language parser from
> your parser.
>
Thanks for your ideas. I attach the nested language grammar to let you
see for what I would need to find the end of input.
The outer grammar looks for the '#' symbol, upon seeing that it will
switch to the nested language like this.
assignment_in_outer = #(inner-language expression (which-is scheme))
The real fun is that the inner-language expression can contain even
fragments written in the outer language. (If you know the Scheme
language you can know that it allows redefining the language itself.)
Now I consider them as multiline comments for simplicity.
Bert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080123/b8aabbed/attachment.html
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Scheme.g3
Url: http://www.antlr.org/pipermail/antlr-interest/attachments/20080123/b8aabbed/attachment.pl
More information about the antlr-interest
mailing list