Loading ...
Sorry, an error occurred while loading the content.

Expand Messages
  • Rob Bugh
    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
    Message 1 of 1 , Aug 18, 2003
    • 0 Attachment
      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 message has been successfully submitted and would be delivered to recipients shortly.