Search code examples
antlr4

missing keyword at keyword in Antlr Lab


grammar Hello;
r : 'hello' ID ;
ID : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;

Input: hello world

Error: 1:0 missing 'hello' at 'hello'

I followed the code carefully... ive tried editing the code and it did not work.

Im a beginner with no compiler experience so can you please explain the error and give me tips on how to make levers using antler


Solution

  • There is nothing wrong with the grammar. You probably didn't see the Lexer tab.

    enter image description here

    Just remove everything you see in the Lexer tab.