lama_byterun/src/SM.ml

36 lines
1.1 KiB
OCaml
Raw Normal View History

2018-02-20 01:28:29 +03:00
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
*)
2018-02-25 14:48:13 +03:00
type config = int list * Language.Stmt.config
2018-02-20 01:28:29 +03:00
(* 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
2018-02-25 14:48:13 +03:00
val compile : Language.Stmt.t -> prg
2018-02-20 01:28:29 +03:00
Takes a program in the source language and returns an equivalent program for the
stack machine
*)
let compile _ = failwith "Not yet implemented"