This Perl script parses a Lemon grammar file on entry (input.y) and prints out an equivalent grammar file suitable for use with the Parse::Yapp Perl parser generator module (output.yp).
This output can be used with the yapp command line tool to produce a perl parser for the grammar.
The output is also good for making a skeletal grammar file for use with yacc, as yapp and yacc have pretty much the same grammar file format.
Limitations:
· This script makes no attempt to do anything with rule actions---it simply removes them. Same goes for comments in the source file. Also, the śllback directive is not understood by yapp, so it is ignored, as are the %ifdef / %ifndef directives. In fact, the only directives used by this script are the precedence directives (%left, %right, etc.) The best thing to do is to scan the source file and manually extract anything inside an %ifdef / %ifndef block that you don't want, as everything else will be put into the output. Then you can manually define an nonterminal that does what the śllback directive would have done