[antlr-interest] Bug in ANTLRv3.g

Terence Parr parrt at cs.usfca.edu
Tue Jul 29 12:53:46 PDT 2008


Ooops. change rule

fragment
ACTION_STRING_LITERAL
	:	'"' (ACTION_ESC|~('\\'|'"'))* '"'
	;

+ to *

Ter

On Jul 29, 2008, at 10:53 AM, Víctor Manuel Sánchez Cartagena wrote:

> I think I have found a bug in the ANTLRv3.g grammar.
> I build the lexer and the parser with ANTLR, and when I try to parse  
> the  following grammar, it fails, although the grammar is correct.
>
> grammar plp2;
> @members {
>   public String refactor_rename_this;
>   public String refactor_rename_to;
> }
> s returns [String value]
>     :
>                 // It doesn't fail:
>                  c["aa"]
>                 // It fails:
>                 //c[""]
>     ;
> c[String ambito] returns [String value]
>     :    'class' ID
>         {
>                      // It doesn't fail:
>                       $value= "class " + $ID.text + " n;" + "{}n";
>                      // It fails:
>                      // $value= "class " + $ID.text + " n;" + "}n";
>                 }
>     ;
> ID    :    ('a'..'z'|'A'..'Z')('a'..'z'|'A'..'Z'|'0'..'9')*
>     ;
> ENTERO    :    ('0'..'9')+
>     ;
>
> Could anyone help me to find out what's wrong in ANTLRv3.g?



More information about the antlr-interest mailing list