2.4. The Parser Hierarchy

A parser is an object that recognizes strings. The examples in this book always wrap a string to be recognized in an Assembly object, as an assembly of either characters or tokens. Figure 2.6 shows the public interface of Parser objects that the examples use.

Figure 2.6. Parser class. A parser is an object that can recognize a string (wrapped in an Assembly object) and assemble a result.

The Parser class in sjm.parse recognizes assemblies and returns assemblies. Often, you want to see whether a parser can recognize an entire string. If the parser can recognize the assembly you provide, its completeMatch() method returns ...

Get Building Parsers with Java™ 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.