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.1.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.1-py3-none-any.whl (72.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: astx-1.24.1.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.1.tar.gz
Algorithm Hash digest
SHA256 d81ee0aaca6c61438963ce00d5f86872a207cddf19ad50ce0d1d4c3667f005ee
MD5 6d336484dffce4961493249dac150c25
BLAKE2b-256 e116f573fa60d2d0b95614a27a623ad663929994ab3f089b1d1cbfd9facd0fce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: astx-1.24.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f48f68159ec0bafe5863295a6936466aa23f1ee150f7297b273a0563075f9dfd
MD5 dd1046447abb7a17aaf73ee20145196f
BLAKE2b-256 4b45b897be1a1a18f160be5470091713f00710a472d7d5e89d03ac62de1ed9cc

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