January 2013
Intermediate to advanced
328 pages
8h 5m
English
ANTLR generates lexers and parsers that are subclasses of Lexer and Parser. Superclass Recognizer abstracts the notion of recognizing structure within a sequence of characters or tokens. Recognizers feed off of IntStreams, which we’ll look at later. Here is the inheritance and interface implementation relationships (interfaces are in italics).

Lexer implements interface TokenSource, which specifies the core lexer functionality: nextToken, getLine, and getCharPositionInLine. Rolling our own lexer to use with an ANTLR parser grammar is not too much work. Let’s build a lexer that tokenizes simple identifiers and integers like the following ...
Read now
Unlock full access