mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-25 08:08:47 +00:00
Shifted to stmt + SM
This commit is contained in:
parent
7a35fdf1eb
commit
9f9e912032
7 changed files with 118 additions and 66 deletions
35
src/SM.ml
Normal file
35
src/SM.ml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
open GT
|
||||
|
||||
(* The type for the stack machine instructions *)
|
||||
@type insn =
|
||||
(* binary operator *) | BINOP of string
|
||||
(* read to stack *) | READ
|
||||
(* write from stack *) | WRITE
|
||||
(* load a variable to the stack *) | LD of string
|
||||
(* store a variable from the stack *) | ST of string with show
|
||||
|
||||
(* The type for the stack machine program *)
|
||||
type prg = insn list
|
||||
|
||||
(* The type for the stack machine configuration: a stack and a configuration from statement
|
||||
interpreter
|
||||
*)
|
||||
type config = int list * Syntax.Stmt.config
|
||||
|
||||
(* Stack machine interpreter
|
||||
|
||||
val eval : config -> prg -> config
|
||||
|
||||
Takes a configuration and a program, and returns a configuration as a result
|
||||
*)
|
||||
let eval _ = failwith "Not yet implemented"
|
||||
|
||||
(* Stack machine compiler
|
||||
|
||||
val compile : Syntax.Stmt.t -> prg
|
||||
|
||||
Takes a program in the source language and returns an equivalent program for the
|
||||
stack machine
|
||||
*)
|
||||
|
||||
let compile _ = failwith "Not yet implemented"
|
||||
Loading…
Add table
Add a link
Reference in a new issue