Reorganized project

This commit is contained in:
2025-12-08 22:25:36 +03:00
parent 8e980a8f1b
commit adbf083c3d
15 changed files with 621 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
open Parser.Ast;;
(* This type represents an intermediate step between the AST and opcodes in our
compiler. We need this extra step to resolve addresses, e.g. how do you know
what exact address an if expression needs to jump to before you compile it?
you don't, you just keep a symbolic label there, resolve later.
*)
type intermediate_opcode =
| ISelect of string * string
| ILDF of string
| ILD of int (* an index into the constant table *)
| INil
| IRet
| IAdd
| IJoin
| ILabel of string (* does not emit any byte code *)
(* TODO: Complete *)
let (compile : lisp_ast -> intermediate_opcode list) = function
| LInt x -> [ILD x]
| _ -> [];;

3
lib/compiler/dune Normal file
View File

@@ -0,0 +1,3 @@
(library
(name compiler)
(libraries parser))