10.3. Repetition Matching

The Repetition class earns its name through the way it implements the match() method. A repetition parser takes another parser and matches it repeatedly against each assembly in a set. The parser that a repetition repeats may be a simple terminal, such as the object new Word(). The parser that a repetition repeats may also be an arbitrarily complex composite parser. Figure 10.2 shows that the constructors of the Repetition class require the creator of a Repetition object to specify this subparser.

Figure 10.2. The Repetition class. A Repetition object represents a repetition of another parser, so the constructors of this class require this parser to be specified.

The idea of a Repetition object is that it produces many ...

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.