Documentation
¶
Overview ¶
Command parser_gen generates the PEG parser table for gopy from cpython/Grammar/python.gram. It is the Go-targeted counterpart of CPython's Tools/peg_generator/.
Inputs:
- $CPYTHON/Grammar/python.gram: the PEG grammar.
Output:
- <repo>/parser/pegen/parser_gen.go: the rule-table struct, the keyword tables, and the per-rule parse functions.
Run with:
go run ./tools/parser_gen \ -cpython=$HOME/github/python/cpython \ -out=parser/pegen/parser_gen.go
The full per-rule emitter is the next milestone. Today the generator extracts the rule list from python.gram and emits a stable scaffold: rule-id constants, a generated rule-name table, and a Dispatch entry point that returns ErrParserNotImplemented. Downstream code can program against the stable shape and the emitter will fill in real bodies in v0.6.
Click to show internal directories.
Click to hide internal directories.