Figure 10.1 shows two methods that support matching: bestMatch() and completeMatch(). The bestMatch() method accepts a single assembly, puts it in a vector, and matches against the vector. Then bestMatch() returns one assembly from the output vector of assemblies, choosing the one whose index is advanced furthest. If a grammar matches only part of an input, bestMatch() returns an assembly that shows the progress made. For example, consider matching the grammar
adjectives = ("steaming" | "hot")*;
against the string
"hot hot steaming hot coffee"
The following code sends bestMatch() to a parser for adjectives, showing that the parser can match up to the word "coffee":
package sjm.examples.mechanics; import sjm.parse.*; ...