[antlr-interest] Re: ANTLR 3: Bug in codegen.g

Oliver Zeigermann oliver.zeigermann at gmail.com
Mon Sep 12 06:39:10 PDT 2005


Modifying template lexerRuleRef in Java.stg
(org/antlr/codegen/templates/) to this

lexerRuleRef(label,rule,args) ::= <<
<if(label)>
int <label>Start = getCharIndex();<\n>
m<rule>(<args>);<\n>
Token <label> = new CommonToken(input, Token.INVALID_TOKEN_TYPE,
Token.DEFAULT_CHANNEL, <label>Start, getCharIndex()-1);<\n>
<else>
m<rule>(<args>);<\n>
<endif>
>>

allowed me to have labled lexer fragments like

name=GENERIC_ID

...

fragment GENERIC_ID     : ... ;

Oliver


2005/9/12, Oliver Zeigermann <oliver.zeigermann at gmail.com>:
> In codegen.g, rule atom the attribute "label" is set for
> lexerStringRef, charRef and lexerRuleRef while there is no attribute
> label for these rules. This causes an error upon generation.
> 
> Obvious solution: either remove code that sets "label" (already done
> at certain parts of rule atom) or add attribute "label" to the
> templates.
> 
> Oliver
>


More information about the antlr-interest mailing list