10.7. Empty Matching

An empty parser matches a collection of assemblies by returning the collection with no changes whatsoever. Here is the code for Empty.match():

public Vector match(Vector in) { 
    return elementClone(in);
}

The match() methods must not change the input state. An Empty parser does not consume text from an assembly, but it may alter an assembly's state by applying an assembler to it in matchAndAssemble(). The code here makes a copy to ensure that matching does not affect the input state.

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.