[antlr-interest] Grammar dependencies (was Re: Expected token apparently not expected?!)
David Bullock
db at dawnbreaks.net
Thu Sep 9 23:12:27 PDT 2004
--- In antlr-interest at yahoogroups.com, Ric Klaren <klaren at c...> wrote:
> Always use import/export vocab in a clear chain. E.g. have
definitions move
> up:
>
> Lexer -> Parser -> treeparser
Hi Ric,
Thanks for your reply (which got me a solution in the end!).
I guess the problem is that if you use literals in the parser, then
the lexer needs to get these somehow. This means that the grammar
needs to be 'pushed back' to the lexer.
> In l.g do exportVocab = L;
> In p.g do importVocab = L; and exportVocab = P;
Instead I did:
p.g exportVocab = L;
l.g importVocab = P;
and compiled p.g first.
This seems counter-intutitive to me (and not to your taste either, I
gather), but it makes my paser behave how I want it to.
IMHO it would be better to dispense with importing and exporting
vocabularies, and have antlr.Tool accept multiple grammar files on
the command-line, to achieve similar results as the 'all classes
defined in one grammar file' semantics.
thanks!
David
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