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

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.

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