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

8.4. Regular Expression Assemblers

You need assemblers for each of the operators a user can specify, and an assembler to handle characters such as a and b. Figure 8.2 shows these assemblers as part of the regular package.

Figure 8.2. The regular expression package. This package contains classes that collaborate to create a new regular expression parser from text.

You must plug in the operator assemblers where each operator appears in the grammar. To see where the assemblers belong, it helps to rewrite the grammar from this:

 expression = term ('|' term)*; term = factor factor*; factor = phrase | (phrase '*'); phrase = letterOrDigit | '(' expression ...

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