I am trying to create a very simple antlr grammar file which should parse the following file:
Report (MyReport)
Begin
End
Or without report name:
Report
Begin
End
And here is my grammar file:
grammar RL;
options {
language = Java;
}
report:
REPORT ('(' SPACE* STRING_LITERAL SPACE* ')')?
BEGIN
END
;
REPORT
: 'Report'
;
BEGIN
: 'Begin'
;
END : 'End';
NAME: LETTER (LETTER | DIGIT | '_')*;
STRING_LITERAL : NAME SPACE*;
fragment LETTER: LOWER | UPPER;
fragment LOWER: 'a'..'z';
fragment UPPER: 'A'..'Z';
fragment DIGIT: '0'..'9';
fragment SPACE: ' ' | '\t';
WHITESPACE: SPACE+ { $channel = HIDDEN; };
rule: ;
However when I debug in ANTLRWorks I always get the following error:
root -> report -> MismatchedTokenException(0!=0)
What's wrong in my Grammar file?
thanks, Green