README revision 4479
111104Spower.jg@gmail.comyply.py
211104Spower.jg@gmail.com
311104Spower.jg@gmail.comThis example implements a program yply.py that converts a UNIX-yacc
411104Spower.jg@gmail.comspecification file into a PLY-compatible program.  To use, simply
511104Spower.jg@gmail.comrun it like this:
611104Spower.jg@gmail.com
711104Spower.jg@gmail.com   % python yply.py [-nocode] inputfile.y >myparser.py
811104Spower.jg@gmail.com
911104Spower.jg@gmail.comThe output of this program is Python code. In the output,
1011104Spower.jg@gmail.comany C code in the original file is included, but is commented out.
1111104Spower.jg@gmail.comIf you use the -nocode option, then all of the C code in the
1211104Spower.jg@gmail.comoriginal file is just discarded.
1311104Spower.jg@gmail.com
1411104Spower.jg@gmail.comTo use the resulting grammer with PLY, you'll need to edit the
1511104Spower.jg@gmail.commyparser.py file. Within this file, some stub code is included that
1611104Spower.jg@gmail.comcan be used to test the construction of the parsing tables. However,
1711104Spower.jg@gmail.comyou'll need to do more editing to make a workable parser.
1811104Spower.jg@gmail.com
1911104Spower.jg@gmail.comDisclaimer:  This just an example I threw together in an afternoon.
2011104Spower.jg@gmail.comIt might have some bugs.  However, it worked when I tried it on
2111104Spower.jg@gmail.coma yacc-specified C++ parser containing 442 rules and 855 parsing
2211104Spower.jg@gmail.comstates.
2311104Spower.jg@gmail.com
2411104Spower.jg@gmail.comComments:
2511104Spower.jg@gmail.com
2611104Spower.jg@gmail.com1. This example does not parse specification files meant for lex/flex.
2711104Spower.jg@gmail.com   You'll need to specify the tokenizer on your own.
2811104Spower.jg@gmail.com
2911104Spower.jg@gmail.com2. This example shows a number of interesting PLY features including
30    
31     - Parsing of literal text delimited by nested parentheses
32     - Some interaction between the parser and the lexer.
33     - Use of literals in the grammar specification
34     - One pass compilation.  The program just emits the result,
35       there is no intermediate parse tree.
36
373. This program could probably be cleaned up and enhanced a lot.
38   It would be great if someone wanted to work on this (hint).
39
40-Dave
41       
42