Scanner (Lexing keywords with ANTLR)
问题 I have been working on writing a scanner for my program and most of the tutorials online include a parser along with the scanner. It doesn't seem possible to write a lexer without writing a parser at the same time. I am only trying to generate tokens, not interpret them. I want to recognize INT tokens, float tokens, and some tokens like "begin" and "end" I am confused about how to match keywords. I unsuccessfully tried the following: KEYWORD : KEY1 | KEY2; KEY1 : {input.LT(1).getText().equals