[antlr-interest] Trying to modify the getting started field guide to C++
Philippe Lavoie
philippe.lavoie at cactus.ca
Tue Jan 28 12:48:48 PST 2003
The following grammar file generates this error
E:\projects\morphy>java antlr.Tool basic.g
ANTLR Parser Generator Version 2.7.2 1989-2003 jGuru.com
basic.g:12:5: expecting ASSIGN_RHS, found ':n:NAME
{ std::cerr << "Hi there, " << n.getText() << std::endl;}
;'
basic.g:3:1: rule grammar trapped:
basic.g:3:1: expecting SEMI, found '}'
Exiting due to errors.
Any idea why going from Java to C++ causes this error?
Thanks
Phil
options {
language = "CPP"
}
{
#include <iostream>
#include <string>
}
class P extends Parser;
startRule
: n:NAME
{ std::cerr << "Hi there, " << n.getText() << std::endl; }
;
class L extends Lexer;
// one-or-more letters followed by a newline
NAME: ( 'a'..'z'|'A'..'Z' )+ NEWLINE
;
NEWLINE
: '\r' '\n' // DOS
| '\n' // UNIX
;
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list