small medium large xlarge

19 Jun 2017, 21:00
Lin Zhang (8 posts)

Dear Prof. Parr,

I noticed that your UnderlineListener on page 156 is applied to only the parser. When I applied it to the lexer, it will not work, because unrecognized tokens cannot be cast to CommonTokenStream. But can we underline the offending token if it causes a lexer error? If yes, can you show us how? Thank you for your time and help.



20 Jun 2017, 15:55
Terence Parr (52 posts)

This is really a question for the antlr discussion forum not the book but you can override a lexer error method I believe to get bad token events. You can see what I do for this in the antlr 4 plugin for intellij. see my stuff

You must be logged in to comment