parser_gen

command
v0.12.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL