Skip to main content

ASTx

ASTx is a language-agnostic Python model for abstract syntax trees. It provides typed nodes and common metadata that parsers, analyzers, transpilers, and compiler backends can share without adopting a particular source grammar.

Status: functional and actively evolving. ASTx models more constructs than any one backend necessarily supports.

Scope

ASTx currently models:

  • source locations, identifiers, expressions, statements, and blocks
  • scalar, string, temporal, collection, generic, and union types
  • functions, defaults, modules, packages, and imports
  • conditionals, loops, generators, comprehensions, and context managers
  • classes, structs, inheritance, member access, and modifiers
  • templates, FFI pointers/opaque handles, and semantic helper metadata
  • lists, buffer views, tensors, DataFrames, and Series
  • YAML, JSON, Mermaid, PNG, and optional console visualization paths

ASTx does not lex or parse source and does not generate LLVM by itself. IRx is the Arx ecosystem backend that analyzes and lowers the supported ASTx subset.

Install

pip install astx

For ASCII visualization through mermaid-ascii:

pip install 'astx[console]'

Example

import astx

args = astx.Arguments(
    astx.Argument(name="x", type_=astx.Int32()),
    astx.Argument(name="y", type_=astx.Int32()),
)

body = astx.Block()
body.append(
    astx.FunctionReturn(
        astx.BinaryOp(
            op_code="+",
            lhs=astx.Variable("x"),
            rhs=astx.Variable("y"),
        )
    )
)

add = astx.FunctionDef(
    prototype=astx.FunctionPrototype(
        name="add",
        args=args,
        return_type=astx.Int32(),
    ),
    body=body,
)

print(add.to_yaml())

Relationship to Arrow

ASTx defines the compiler-facing node and type vocabulary for arrays, buffer views, Tensors, DataFrames, and Series. It deliberately does not depend on Apache Arrow or own native storage. IRx maps those nodes to its Arrow C++ runtime.

Documentation: https://arxlang.org/astx/

License: Apache-2.0.

Download files

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

Source Distribution

astx-1.24.0.tar.gz (47.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

astx-1.24.0-py3-none-any.whl (72.3 kB view details)

Uploaded Python 3

File details

Details for the file astx-1.24.0.tar.gz.

File metadata

  • Download URL: astx-1.24.0.tar.gz
  • Upload date:
  • Size: 47.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.10.20 Linux/6.17.0-1020-azure

File hashes

Hashes for astx-1.24.0.tar.gz
Algorithm Hash digest
SHA256 4ac48f60c3f965cf319f84a5442cf80fa7a5123d9253772b5ab632669a5f076a
MD5 a8b61ee74bb0481f131e0e9804466d61
BLAKE2b-256 d1c4807b2e4ef9f09101ebf05b5abac15bf930abe94de869e4bdc41f2fa13963

See more details on using hashes here.

File details

Details for the file astx-1.24.0-py3-none-any.whl.

File metadata

  • Download URL: astx-1.24.0-py3-none-any.whl
  • Upload date:
  • Size: 72.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.10.20 Linux/6.17.0-1020-azure

File hashes

Hashes for astx-1.24.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6a5a2505202da98ea9ff2e1ac468667d6e4fb1655c123d22ad79d53a87ee13c
MD5 e9cb06a52679d69d39d55389439e04ed
BLAKE2b-256 13bdc96d069816f15dff4247165e766cd8c612a6c390438105e3d6fb5dac2664

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 Sentry Error logging StatusPage Status page