[antlr-interest] Multipass parsing
John D. Mitchell
johnm-antlr at non.net
Sun Mar 28 15:17:28 PST 2004
>>>>> "FranklinChen" == FranklinChen <FranklinChen at cmu.edu> writes:
[...]
> What's currently the best way to do multipass parsing (while retaining
> all location information so that error messages are informative)?
> Basically, I would like to be able to evolve a parser by starting from
> recognizing and processing a coarse-grained structure and then refining
> it, e.g., suppose I have a language that can be thought of at a first cut
> as consisting of space-delimited tokens, and then I wish also to parse
> within those tokens eventually.
For your example, with Antlr, you can write a separate grammar for each of
the languages and then invoke the appropriate grammar at the appropriate
spot.
However, given your example, I don't understand *why* you'd want to do
"nested parsing". The main reason to do nested parsing is because you have
dynamically changing/configurable sub-languages. If you don't need that
kind of pluggability, it's much easier to write a lexer and a parser do the
minimum necessary to reliably build up a tree and then do your multiple
"refinement" passes over the tree (rather than trying to do all of the
stuff in the parser).
Or do you have some other need/constraint on the sub-languages?
Hope this helps,
John
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list