📄 readme
字号:
yply.pyThis example implements a program yply.py that converts a UNIX-yaccspecification file into a PLY-compatible program. To use, simplyrun it like this: % python yply.py [-nocode] inputfile.y >myparser.pyThe output of this program is Python code. In the output,any C code in the original file is included, but is commented out.If you use the -nocode option, then all of the C code in theoriginal file is just discarded.To use the resulting grammer with PLY, you'll need to edit themyparser.py file. Within this file, some stub code is included thatcan be used to test the construction of the parsing tables. However,you'll need to do more editing to make a workable parser.Disclaimer: This just an example I threw together in an afternoon.It might have some bugs. However, it worked when I tried it ona yacc-specified C++ parser containing 442 rules and 855 parsingstates.Comments:1. This example does not parse specification files meant for lex/flex. You'll need to specify the tokenizer on your own.2. This example shows a number of interesting PLY features including - Parsing of literal text delimited by nested parentheses - Some interaction between the parser and the lexer. - Use of literals in the grammar specification - One pass compilation. The program just emits the result, there is no intermediate parse tree.3. This program could probably be cleaned up and enhanced a lot. It would be great if someone wanted to work on this (hint).-Dave
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -