![]()
|
"http://www.w3.org/TR/html4/loose.dtd">
>
Chapter 4
|
|
The tpg.compile function produces Python code from the grammar (see figure 4.2).
Then you can use the new generated parser. The parser is now simply a Python class (see figure 4.3).
|
The tpg script is just a wrapper for the package. It reads a grammar in a file and write the generated code in a Python script. To produce a Python script from a grammar you can use tpg as follow:
tpg [-v|-vv] grammar.g [-o parser.py]
|
tpg accepts some options on the command line: