I am still new to ANTLR, but I can’t even run the very normal Hello World program. To get started, here is the corresponding code (I think):
Test.g4
grammar Test;
kod
: påstående ';' kod
| EOF
;
påstående
:skriv
;
skriv
: 'skriv' STR
;
STR:('a'..'z')+ ;
WS: [ \n\t\r]+ -> skip ;
test1.t (My test program)
skriv helloworld;
When I compile and run the RunTest.java file, this is the output in the console:
line 1:0 no viable alternative at input 'skriv'
Process finished with exit code 0
Not sure what is wrong here. I tried various inputs such as numbers, quotation marks, equal signs, etc., but all this gives me the same error.
source
share