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 ...
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.