[antlr-interest] (unknown)
Rob Bugh
rbugh at journee.com
Mon Aug 18 12:04:01 PDT 2003
I'm using grammar inheritance and a rule in the sub-grammar is not working
because it does not test against the tokens defined in the sub-grammar. In
other words, it appears that the generated code did not take into account
the tokens defined in the sub-grammar. See example below
File: super.g ------------ANTLR was run against this file first
class superlexer extends lexer;
options { exportVocab = super; }
tokens { FOO="foo"; }
//rules ...
...
class superparser extends parser;
options { exportVocab = super; }
// rules ...
-----------------------------------------
File: sub.g ---------------ANTLR was run against this file second
class sublexer extend superlexer;
options { exportVocab = sub; }
tokens { BAR="bar"; X="x"; Y="y" }
// rules...
class subparser extends superparser;
options { exportVocab = sub; codeGenBitsetTestThreshold=999; }
// rules...
foo_statement: foo_expression BAR;
foo_expression: FOO ( ~(BAR) )*;
-----------------------------------------
Given the input token stream "foo x y bar", the rule "foo_expression" fails
when it encounters an X or Y reporting that a BAR was expected. Looking at
the code for foo_expression() it compares LT(1) against every token defined
in the super grammar but none of the tokens defined in the sub grammar.
Can anyone else verify whether this is a bug or not.
Thanks,
Rob Bugh
Journee Software
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list