Skip to main content

Pure-Python implementation of the "ast" module

Project description

This is a pure-Python implementation of “ast” module as described in CPython documentation. It is written for the Pycopy project and is a part of its standard library, pycopy-lib.

The main component is a Python parser Implementation-wise, it’s laid out as a package, with following submodules:

  • ast.types, with AST node types auto-generated from CPython’s ASDL description.

  • ast.parser, implementing hand-written parser for Python 3.5, utilizing recursive descent to parse statements, and Pratt operator precedence parser to parse expressions.

  • ast, the main package, integrating submodules above, and exposing CPython-compatible API with corresponding additional functions and classes to process AST trees.

At the time of writing, parsers support Python 3.5 syntax with future-looking cleanups, e.g. async is treated as a keyword. Updates for the next versions of Python syntax are expected to follow.

The package has small builtin test corpus to check that the AST trees match the ones generated by CPython, and can also use entire CPython standard library as a test corpus, which it can parse similarly correctly (but with some discrepancies, e.g. this module is optimized for minimal size and doesn’t support Unicode named escape sequences (in the same way as Pycopy doesn’t support them)).

Pycopy’s ast module is written by Paul Sokolovsky and provided under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycopy-ast-2.3.4.tar.gz (11.3 kB view details)

Uploaded Source

File details

Details for the file pycopy-ast-2.3.4.tar.gz.

File metadata

  • Download URL: pycopy-ast-2.3.4.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for pycopy-ast-2.3.4.tar.gz
Algorithm Hash digest
SHA256 4120c2cbd0c19155298ba3d2d2b5c654e0be9c9cfaaa1d54b08953a0cdaec5e0
MD5 a6093ac75515f3ecbcfe66691479bca7
BLAKE2b-256 ff9f95c7bdea4095a45074524095ae0cd55c482aecf2977fee98a292be9ddb72

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page