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

4.2. Random Testing

In addition to testing whether your language supports the features you intend, it is a good idea to conduct random tests by running random language elements through your parser. Figure 4.1 shows the abstract class ParserTester, from package sjm.parse. This class accepts a parser in its constructor and tests the parser in response to a test() message.

Figure 4.1. The ParserTester class. This class tests the parser that it accepts in its constructor.

The ParserTester class is abstract because its assembly() method is abstract. Subclasses implement this method to treat the string as a sequence of either tokens or characters. The ...

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