annotate ply-3.8/example/yply/README @ 12292:d51f2100210c draft

<kspalaiologos> `` cat <<<"asmbf && bfi output.b" > /hackenv/ibin/asmbf
author HackEso <hackeso@esolangs.org>
date Thu, 02 Jan 2020 15:38:21 +0000
parents 343ff337a19b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7267
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
1 yply.py
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
2
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
3 This example implements a program yply.py that converts a UNIX-yacc
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
4 specification file into a PLY-compatible program. To use, simply
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
5 run it like this:
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
6
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
7 % python yply.py [-nocode] inputfile.y >myparser.py
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
8
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
9 The output of this program is Python code. In the output,
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
10 any C code in the original file is included, but is commented out.
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
11 If you use the -nocode option, then all of the C code in the
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
12 original file is just discarded.
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
13
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
14 To use the resulting grammer with PLY, you'll need to edit the
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
15 myparser.py file. Within this file, some stub code is included that
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
16 can be used to test the construction of the parsing tables. However,
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
17 you'll need to do more editing to make a workable parser.
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
18
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
19 Disclaimer: This just an example I threw together in an afternoon.
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
20 It might have some bugs. However, it worked when I tried it on
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
21 a yacc-specified C++ parser containing 442 rules and 855 parsing
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
22 states.
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
23
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
24 Comments:
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
25
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
26 1. This example does not parse specification files meant for lex/flex.
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
27 You'll need to specify the tokenizer on your own.
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
28
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
29 2. This example shows a number of interesting PLY features including
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
30
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
31 - Parsing of literal text delimited by nested parentheses
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
32 - Some interaction between the parser and the lexer.
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
33 - Use of literals in the grammar specification
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
34 - One pass compilation. The program just emits the result,
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
35 there is no intermediate parse tree.
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
36
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
37 3. This program could probably be cleaned up and enhanced a lot.
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
38 It would be great if someone wanted to work on this (hint).
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
39
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
40 -Dave
343ff337a19b <ais523> ` tar -xf ply-3.8.tar.gz
HackBot
parents:
diff changeset
41