Interpreters, Languages, and Parsers

The INTERPRETER pattern addresses how interpreters work but does not specify how you should compose new interpreters at runtime. In this chapter, you have built new interpreters “manually,” by writing lines of Java code. But by far the most common way to create a new interpreter is with a parser. A parser can read textual commands from a file or from a user prompt and can use the text to create an interpreter. Powerful! Another reason to learn about building parsers is that if you want to understand the INTERPRETER chapter in Design Patterns (Gamma et al. 1995), you really need to understand the interrelation of interpreters, parsers, and computer languages.

A parser is an object that can recognize text and ...

Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.