[antlr-interest] Possible problem with AntlrV3.g
Terence Parr
parrt at cs.usfca.edu
Tue Aug 12 10:58:30 PDT 2008
On Aug 11, 2008, at 10:12 PM, Gerald Rosenberg wrote:
> In the "rule" rule in AntlrV3.g of the Antlr-3.1b2 distribution,
> does not appear as if the "modifier" label gets set and, therefore,
> is never re-written to the AST.
Yep, got a bug in on that one.
Ter
>
>
> ( modifier=( 'protected'| 'public' | 'private' |
> 'fragment' ) )?
> should be
> ( (modifier= 'protected'|modifier= 'public' |modifier=
> 'private' |modifier= 'fragment' ) )?
>
> and
>
> -> ^( RULE id {modifier!=null?adaptor.create(modifier):null}
> ^(ARG $arg)? ^(RET $rt)?
> should (likely) be
> -> ^( RULE id {$modifier!=null?adaptor.create($modifier):null}
> ^(ARG $arg)? ^(RET $rt)?
>
> FWIW, does not seem that the absence of the "$" operator in the
> rewrite phrase affects the generated code: what is generated still
> appears correct.
>
>
> The original rule is:
>
> rule
> scope {
> String name;
> }
> :DOC_COMMENT?
> ( modifier=( 'protected'| 'public' | 'private' |
> 'fragment' ) )?
> id {$rule::name = $id.text;}
> '!' ?
> ( arg=ARG_ACTION )?
> ( 'returns' rt=ARG_ACTION )?
> throwsSpec? optionsSpec? ruleScopeSpec? ruleAction*
> ':' altList ';'
> exceptionGroup?
> -> ^( RULE id {modifier!=null?
> adaptor.create(modifier):null} ^(ARG $arg)? ^(RET $rt)?
> optionsSpec? ruleScopeSpec? ruleAction*
> altList
> exceptionGroup?
> EOR["EOR"]
> )
> ;
More information about the antlr-interest
mailing list