[antlr-interest] Bug when creating variable for parser (ANTLR 2.7.2)?

Jorge Scandaliaris j_scandaliaris at yahoo.es
Wed Jun 11 06:40:19 PDT 2003


Hi,
	Search the message archive for "understanding element labels", I
posted the question sometime ago and Monty answered basically this:

"A rule label will be naming a tree node, not a token.  You have two
options. One is to get the text out of the node.  The other is to have
parser_rule_reference return a token (or the token text for that
matter), in which case you will be responsible for declaring name and
assigning it as name=parser_rule_reference.

Monty"

Jorge
> -----Mensaje original-----
> De: defordusa [mailto:defordusa at yahoo.com]
> Enviado el: miércoles, 11 de junio de 2003 14:56
> Para: antlr-interest at yahoogroups.com
> Asunto: [antlr-interest] Bug when creating variable for parser (ANTLR
> 2.7.2)?
> 
> Is it a bug or by design that no variable "f1" is created in the
> parser?
> I have had to create an instance member "fpInstVar" in order to
> properly
> grab the contents of fp.
> 
> If I try to use "f1" I get a variable not defined error.
> 
> I am using ANTLER 2.7.2
> 
> ========== grammar snippet ==========
> 
> {
>    ...
>    ...
>    Token fpInstVar = null;    //  <== Creation of fpInstVar
>    ...
>    ...
> }
> 
> ...
> ...
> ...
> 
> 
> fpname  :
>             f1:fp      //  <=== Creation of f1 (f1 NEVER CREATED)
>             (
>               {
>                 fpInstVar= LT(1); // Contains contents of fp.
>               }
>               f2:TX
>               (
>                 f3:TX
>                 (
>                   f4:TX
>                   (
>                     {
>                       System.out.println( f1.getText() ); // <= ERROR!
>                       System.out.println(
> fpInstVar.getText() );
>                       System.out.println( f2.getText() );
>                       System.out.println( f3.getText() );
>                       System.out.println( f4.getText() );
>                     }
>                   )
> 
> ...
> ...
> ...
> 
> 
> 
> 
> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/




 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list