Validating a parser generator 2005-04-17

A large part of validating a parser generator, such as my BNF to parser assembler tool is ensuring the generated parser is equivalent to a well tested hand written parser.

Generally, my approach is to start bringing the hand written parser for the tool into line with a version of the parser for the tool specified in the tools own language as soon as I possibly can.

The reason is that by being methodical and writing the parser in the same style you expect to use, you quickly identify problems with the generation, but you also make it trivial to compare the two.

Even when it makes hand writing the parser harder, it's worthwhile, because at the stage where you've worked for a long time on the code generation, you've probably debugged the hand written parser quite a lot, and making the generated parser match so well a basic text comparison find only minor differences reduces the validation process to a simple question:

Do you trust the testing you've done of your hand written parser?

blog comments powered by Disqus