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