Slide 19
Slide 19 text
19
.hk
import(f, src.main)
fn main(x) {
if x > 5 {
print(“nope”)
}
else {
Lex+Parse
Optimise
Compile Hark Executale
Better
AST
Tail-call recursion, in particular
https://commons.wikimedia.org/wiki/File:Abstract_syntax_tree_for_Euclidean_algorithm.svg
- Import statements
- Numbers, strings, …
- Operations (+, *, …)
- Function definitions
- Assignments (x = 5)
- Function Calls
- …
Convert the AST into
byte-code that the
Hark VM can execute
Abstract Syntax Tree (AST)
01101
01011
Pack
dataclasses, attrs
functools
typing
parsy, sly
https://github.com/python-attrs/attrs
https://github.com/python-parsy/parsy
https://github.com/dabeaz/sly
✨
Executable =
Byte-Code +
Python function references +
Symbol table +
Debugging info
Byte-code