This directory contains an implementation of Zephyr ASDL. It consists of these components:
asdl.py
: the ASDL schema parser, borrowed from Python (Python-3.5.2/Parser/asdl.py
)py_meta.py
: library to dynamically generate Python classes (using metaclasses)encode.py
: library to encode ASDL data structures inoheap
format (to be described later)gen_cpp.py
: tool to generate C++ code to read theoheap
format
This library will be used for serializing parsed osh
and oil
code.
The files arith_parse.py
, arith.asdl
, arith_ast.py
, and arith_demo.cc
are an end-to-end demo, driven by run.sh
.
For more on Zephyr ASDL, see this blog post.
This is an experimental serialization of ASDL data structures. See What is OHeap?
On Ubuntu:
build/codegen.sh download-clang
build/codegen.sh extract-clang
# encodes and decodes arithmetic AST
asdl/run.sh asdl-arith-oheap
# encodes and decodes the OSH "lossless syntax tree"
asdl/run.sh osh-demo
(NOTE: We probably shouldn't require Clang for this? It's only necessary for ASAN, clang-format, build time benchmarking, runtime benchmarking vs. GCC, etc.)
- To freeze OSH LSTs (instances of types in
osh.asdl
)- This isn't necessary if the parser is fast enough (which is desirable)
- To freeze Python / OPy bytecode, and associated constants
- Special case: ASDL reflection data for
osh.asdl
, so we can pretty print them
- Special case: ASDL reflection data for