[antlr-interest] Bug in ANTLRv3.g

Víctor Manuel Sánchez Cartagena vitaka at gmail.com
Tue Jul 29 14:33:09 PDT 2008


Thank you very much. I changed the rule and now it doesn't fail in: c[""]
But it still fails in: $value= "class " + $ID.text + " n;" + "}n";

In fact, ANTLR gives an error in every string that starts with }.

In this case, I get the following output:

line 26:0 mismatched character '<EOF>' expecting '"'
line 19:62 no viable alternative at input 'n'
BR.recoverFromMismatchedToken


2008/7/29 Terence Parr <parrt at cs.usfca.edu>

> 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?
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080729/4e8534cd/attachment.html 


More information about the antlr-interest mailing list