README revision 4479:61d3ed46e373
1yply.py
2
3This example implements a program yply.py that converts a UNIX-yacc
4specification file into a PLY-compatible program.  To use, simply
5run it like this:
6
7   % python yply.py [-nocode] inputfile.y >myparser.py
8
9The output of this program is Python code. In the output,
10any C code in the original file is included, but is commented out.
11If you use the -nocode option, then all of the C code in the
12original file is just discarded.
13
14To use the resulting grammer with PLY, you'll need to edit the
15myparser.py file. Within this file, some stub code is included that
16can be used to test the construction of the parsing tables. However,
17you'll need to do more editing to make a workable parser.
18
19Disclaimer:  This just an example I threw together in an afternoon.
20It might have some bugs.  However, it worked when I tried it on
21a yacc-specified C++ parser containing 442 rules and 855 parsing
22states.
23
24Comments:
25
261. This example does not parse specification files meant for lex/flex.
27   You'll need to specify the tokenizer on your own.
28
292. 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