Can I push back the most recently read token into the input stream?

Terence Parr

You are thinking in terms of the old one-token-of-lookahead type parser generators without backtracking capabilities. ANTLR specifically provides a mechanism to lookahead ahead a fixed amount, k, or infinitely via syntactic predicates (a selective programmer-controlled form of backtracking). You can tell ANTLR to try out an alternative and back up to retry the next potentially viable alternative if that one fails. It's like specifying the infinite lookahead language that predicts an alternative.

About | Sitemap | Contact