1
0
Fork
You've already forked astTF
0
astTF | Transmission Format for Abstract Syntax Trees
  • TypeScript 32.5%
  • Zig 19.8%
  • json 19.3%
  • C 13%
  • Nim 12.3%
  • Other 3%
Find a file
2026年07月03日 23:14:39 +02:00
.github/workflows git: Fix Error Checking CI 2025年03月17日 02:54:10 +01:00
bin rmv: Move everything into butcher for deep refactor 2025年12月10日 21:38:01 +01:00
doc/design new: Allow Types to be Expressions (Binding and Procedure.returnType) 2026年05月03日 09:00:53 +02:00
samples new: Loop.keyword support 2026年06月16日 14:44:44 +02:00
spec new: Loop.keyword support 2026年06月16日 14:44:44 +02:00
src new: Loop.keyword support 2026年06月16日 14:44:44 +02:00
.attw.json bld: Install and configure @arethetypeswrong/cli export checker 2025年03月16日 23:30:58 +01:00
.gitattributes git: Add .atf extension for the github syntax highlighter 2025年03月16日 18:53:14 +01:00
.gitignore bld: Add zig build and nim package support 2026年04月27日 10:46:07 +02:00
astTF.nimble new: Loop.keyword support 2026年06月16日 14:44:44 +02:00
build.zig bld: zig: Allow passing optimization/target options to astTF.zig 2026年07月03日 23:14:39 +02:00
build.zig.zon new: Loop.keyword support 2026年06月16日 14:44:44 +02:00
eslint.config.mjs fix: Bundling and linting issues 2026年04月26日 10:36:06 +02:00
license.md rmv: Move everything into butcher for deep refactor 2025年12月10日 21:38:01 +01:00
package.json new: Loop.keyword support 2026年06月16日 14:44:44 +02:00
readme.md doc: Cleanup roadmap overview on the readme 2026年04月27日 03:29:52 +02:00
tsconfig.build.json fix: Bundling and linting issues 2026年04月26日 10:36:06 +02:00
tsconfig.eslint.json fix: Bundling and linting issues 2026年04月26日 10:36:06 +02:00
tsconfig.json fix: Bundling and linting issues 2026年04月26日 10:36:06 +02:00

astTF | Transmission Format for Abstract Syntax Trees

astTF is a format to serialize AST data into JSON-glTF-like objects.
It is an efficient and extensible format for transmission and loading of AST data, for use in compilers and programming language tools.

Specification

The astTF specification can be found inside the ./spec folder:

spec/
├── astTF.zig : Type Declarations for Zig
├── astTF.h : Type Declarations for C
├── astTF.nim : Type Declarations for Nim
├── astTF.py : Type Declarations for Python
└── *.schema.json : JSON Schema representation of the Specification, for use by other tools

Samples

The ./samples folder contains working examples for every AST feature.
Each sample has an ast.atf file and a paired source file written in the original language.

See the samples' readme.md file for a complete list.

How to use

astTF allows serializing and transferring AST data in a compiler-agnostic way.
A parser writes an .atf file, and any number of backends can read it (code generators,linters, formatters, documentation tools)
without having to reimplement the parser themselves.

Given the code int x = 5;, a C parser would produce:

{
 "root": 0,
 "data": {
 "modules": [{ "path": "main.c", "source": "int x = 5;\n", "body": 0 }],
 "types": [{ "primitive": { "name": { "location": { "start": 0, "end": 2 } } } }],
 "expressions": [{ "literal": { "kind": 0, "value": { "start": 8, "end": 8 } } }],
 "bindings": [{ "name": { "location": { "start": 4, "end": 4 } }, "dataType": 0, "value": 0 }],
 "statements": [{ "variable": { "id": 0 } }]
 }
}

A backend (eg: a formatter, a linter, a code generator or any other tool), then reads this data with any regular JSON parser,
traverses (and/or modifies) the data in whatever way they need,
and is then free to re-transfer or process the result (eg: outputting documentation, machine code, linting, etc),
without ever having to parse C themselves at all.

Getting Started

The best way to start using this format is to go through the implementation roadmap,
and, one by one, add support for each feature to the application.
The phases are written and organized as an "implementation guide" for development,
and they gradually build upon the features of previous phases.

Buildsystem

note: These tools are useful mostly for development of the specification itself.
Requires bun.

bun install
bun spec # re-generate all spec files
bun test # run validation tests
bun test:zig # run zig parsing tests

License

MPL-2.0