O'Reilly logo

Building Parsers with Java™ by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

11.1. The Role of New Types of Parsers

The basic parser tools of repetition, sequence, and alternation are sufficient for building an infinite variety of parsers. You may find that you never need to extend this fundamental suite of tools. However, cases do arise in which new parser types are needed, and this section looks at several ways to extend the parser hierarchy.

The most common need is for a new type of terminal. For example, a new terminal might distinguish an integer from a floating point number, or a lowercase word from an uppercase word. You may also need to adjust the tokenizer to change how it forms elements, and in conjunction create one or more new Terminal subclasses that recognize the new token types.

In general, there is no ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required