[antlr-interest] Bug: mutli-lined return statements are not commented correctly in generated code

Brian DeVries contingencyplan at gmail.com
Sun Mar 4 06:17:51 PST 2007


Hey guys,

When I split up a parser rule return statement over multiple lines, the
lines are not commented out in the generated Java code.

Example:

ANTLR:
fnDecl returns [
                String name = null,
                ArrayList<String> params = null,
                ArrayList<String> indices = null
               ]
    :    ID {$name = $ID.text;}
            (LPAREN (paramList {$params = $paramList.params;})? RPAREN
            (indexVars {$indices = $indexVars.indices;})?)?
    ;


Java:
    // $ANTLR start fnDecl
    // File.g:68:1: fnDecl returns [
                    String name = null,
                    ArrayList<String> params = null,
                    ArrayList<String> indices = null
                 ] : ID ( ( LPAREN ( ( paramList )=> paramList )? RPAREN ( (
indexVars )=> indexVars )? )=> LPAREN ( ( paramList )=> paramList )? RPAREN
( ( indexVars )=> indexVars )? )? ;

Obviously, the above Java code should all be commented, since it's simply
describing the ANTLR rule it was generated from.

I'll go back to putting all the return values on one line, but I figure this
shouldn't be hard to fix, and splitting the return list up is a natural way
to use the language, so it qualified as a "bug". I haven't made any attempt
to find the code in ANTLR (yes, I'm a bad OSS user...), but if y'all are
swamped / busy / whatever, I can take a shot at it.

Thanks!
~Brian DeVries
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070304/14a90dda/attachment.html 


More information about the antlr-interest mailing list