Purely as a self-learning exercise, I'm trying to write a Java parser in Perl using the Parse::RecDescent
module. I may later re-implement the parser using other other tools like Antlr, bison, etc.
But how would I ensure that my parser is indeed generating the correct parse, per the Java Language Specification? Meaning, its correct handling of dangling else
's, operator-associativity and -precedence etc.
One method would be to compare my parser against a known, bug-free parser by having both parsers generate ASTs for a very large number of test Java programs, and then comparing the two sets of ASTs.
If this is indeed the only method, where could I find a large suite of test Java programs thoroughly covering the entire Java Language Specification?
I have looked at JavaParser but it doesn't seem to have an exhaustive test dataset.
The other method would, of course, be writing by hand tens of thousands test Java programs myself, which would be very impractical for me, not only time-wise but also in ensuring its exhaustiveness!
Aucun commentaire:
Enregistrer un commentaire