Posted By:
ggrocz
Posted On:
Tuesday, July 3, 2012 11:22 PM
Hi everybody, sorry because of the silly question but I don't see the solution. I have the following grammar: grammar Simple; options { language = Java; } rule: name_line car_line free_line ; name_line: 'NAME' STRING EOL; car_line: 'CAR' STRING EOL; free_line: 'FREE' STRING EOL; STRING: ('A'..'Z')+; EOL: ('\n' | '\r')+; WS: ' '+ {$channel = HIDDEN;}; and the input: NAME JOHN CAR OWNER NAME IS JOHN FREE THERE CAN BE SOME NAME when I try to parse this input I get MismatchedTokenException. How can I
More>>
Hi everybody,
sorry because of the silly question but I don't see the solution. I have the following grammar:
grammar Simple;
options {
language = Java;
}
rule:
name_line
car_line
free_line
;
name_line: 'NAME' STRING EOL;
car_line: 'CAR' STRING EOL;
free_line: 'FREE' STRING EOL;
STRING: ('A'..'Z')+;
EOL: ('\n' | '\r')+;
WS: ' '+ {$channel = HIDDEN;};
and the input:
NAME JOHN
CAR OWNER NAME IS JOHN
FREE THERE CAN BE SOME NAME
when I try to parse this input I get MismatchedTokenException. How can I handle this kind of situation with antlr when something(e.g. the 'NAME') should be context dependent? What could be the solution in this grammar?
Thanks,
Gábor
<<Less