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

RE: [antlr-interest] Token object creation

Expand Messages
  • mzukowski@bco.com
    ... I took a look at your grammar, and basically the answer is yes. If you are not building trees, and you are not, then you can only label token references
    Message 1 of 5 , Mar 9, 2001
    • 0 Attachment
      RE: [antlr-interest] Token object creation

      > -----Original Message-----
      > From: Pedro Joao Assis [mailto:passis@...]
      > Sent: Thursday, March 08, 2001 2:59 AM
      > To: antlr-interest@yahoogroups.com
      > Subject: Re: [antlr-interest] Token object creation
      >
      > So, it is true that only lexer rules, and yes this are the
      > ones that grab
      > the tokens..., can be labeled? like this,
      >               v:IDENTIFIER { qlfID = v.getText (); }

      I took a look at your grammar, and basically the answer is yes.  If you are not building trees, and you are not, then you can only label token references and not rule references.  The reason being that ANTLR isn't smart enough to know if a rule will always only match one token or not.  ANTLR should generate a warning to this effect, but it currently does not.

      Labels can be used with rules, however, if you are building trees.  If you happen to want to do that then you can label the rule and grab the text out of the node returned, since you know only one node will be returned for the rules which are like qualifierName.

      Monty

    Your message has been successfully submitted and would be delivered to recipients shortly.