[antlr-interest] [BUG] Adding options language = Cpp cause Antlr to return an error

Philippe Lavoie philippe.lavoie at cactus.ca
Fri Jan 31 08:47:18 PST 2003


When I run the following

////////////////
options {
    language="Cpp" // remove this and it works
}

class P extends Parser;

startRule
    :   n:NAME EOF!
        { ; }
    ;

class L extends Lexer;

// one-or-more letters followed by a newline
NAME:   ( 'a'..'z'|'A'..'Z' )+ NEWLINE
    ;

NEWLINE
    :   '\r' '\n'   // DOS
    |   '\n'        // UNIX
    ;
////////////

I get the following output

 E:\projects\morphy>java antlr.Tool basic.g
 ANTLR Parser Generator   Version 2.7.2   1989-2003 jGuru.com
 basic.g:8:5: expecting ASSIGN_RHS, found ':n:NAME EOF!
         { ; }
     ;'
 basic.g:3:1: rule grammar trapped:
 basic.g:3:1: expecting SEMI, found '}'
 Exiting due to errors.

When I remove the "language=Cpp" line, everything works correctly.

I think this is a bug in antlr2.7.2.

Please help, I'd like to have C++ generation working. Thanks.

Phil

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list