Hey, I'm an ANTLR beginner looking for some help with my first ANTLR
grammar.
I'm defining the grammar for a statement that looks more or less like a
Java package statement, except that the keyword is 'module'. So an
example input file should look like this:
module my.module.this;
And the final program should output "my.module.this". However, I can't
get the generated C++ to compile. It gives me errors on a not being
defined.
Any ANTLR experts want to help?
Thanks,
Owen
Here's what I have:
class DParser extends Parser;
parse :
moduleDecl
;
moduleDecl :
MODULE
a:(ID (DOT ID)* ) { cout << a->getText(); }
SEMI
;
class DLexer extends Lexer;
SEMI :
';'
;
DOT :
'.'
;
ID :
( 'a'..'z' | 'A'..'Z' | '_' )
( 'a'..'z' | 'A'..'Z' | '_' | '0'..'9')*
;
MODULE :
"module"
;