Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
NOTES.txt
README.md
__init__.py
arith.asdl
arith_ast.py
arith_ast_test.py
arith_demo.cc
arith_parse.py
arith_parse_test.py
asdl_.py
asdl_demo.py
cgi.py
const.py
encode.py
encode_test.py
format.py
format_test.py
front_end.py
gen_cpp.py
gen_python.py
osh_demo.cc
pretty.py
py_meta.py
py_meta_test.py
run.sh
tdop.py
unpickle.py
unpickle_test.py
visitor.py

README.md

Zephyr ASDL

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 in oheap format (to be described later)
  • gen_cpp.py: tool to generate C++ code to read the oheap 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.

OHeap

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.)

OHeap Use Cases:

  • 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