ó
|
Y\¬Qc @ sE d Z d d l Z d d l m Z m Z d e j f d YZ d S( sý Convert graminit.[ch] spit out by pgen to Python code.
|
|
Pgen is the Python parser generator. It is useful to quickly create a
|
parser from a grammar file in Python's grammar notation. But I don't
|
want my parsers to be written in C (yet), so I'm translating the
|
parsing tables to Python data structures and writing a Python parse
|
engine.
|
|
Note that the token numbers are constants determined by the standard
|
Python tokenizer. The standard token module defines these numbers and
|
their names (the names are not used much). The token numbers are
|
hardcoded into the Python tokenizer and into pgen. A Python
|
implementation of the Python tokenizer is also available, in the
|
standard tokenize module.
|
|
On the other hand, symbol numbers (representing the grammar's
|
non-terminals) are assigned by pgen based on the actual grammar
|
input.
|
|
Note: this module is pretty much obsolete; the pgen module generates
|
equivalent grammar tables directly from the Grammar.txt input file
|
without having to invoke the Python pgen C program.
|
|
iÿÿÿÿN( t grammart tokent |