[antlr-interest] Possible problem with AntlrV3.g

Gerald Rosenberg gerald at certiv.net
Mon Aug 11 22:12:12 PDT 2008


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.

         ( 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"]
             )
         ; 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080811/007e3aad/attachment.html 


More information about the antlr-interest mailing list