diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2024-06-02 09:17:55 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2024-06-02 09:17:55 -0700 |
| commit | 22b8b7e2478e3b205c89cc7a700058bfe39175f2 (patch) | |
| tree | ad6cf17b8729ab9af71d4d731162e738f3a7b057 /syntax.sml | |
| parent | 90c4eac546d2c950b27a84ef0e390ac33a1a347d (diff) | |
| download | sml-22b8b7e2478e3b205c89cc7a700058bfe39175f2.tar.zst | |
Add strings and IO.
Diffstat (limited to 'syntax.sml')
| -rw-r--r-- | syntax.sml | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -47,6 +47,9 @@ struct | PLess | PEq | PIf + | PRead + | PWrite + | PWriteErr datatype lexp = LVar of var @@ -65,7 +68,6 @@ struct VVar of var | VLabel of var | VInt of int - | VString of string datatype cexp = CRecord of ((value * int list) list * var) list * cexp @@ -89,6 +91,9 @@ struct | OEq of var * value * value | OIf of value * var | OLabel of var + | ORead of var * var * value * value + | OWrite of var * value * value + | OWriteErr of var * value * value fun listToString (show : 'a -> string) (l : 'a list) = "[" ^ String.concatWith ", " (map show l) ^ "]" @@ -163,6 +168,9 @@ struct | PLess => "PLess" | PEq => "PEq" | PIf => "PIf" + | PRead => "PRead" + | PWrite => "PWrite" + | PWriteErr => "PWriteErr" fun lexpToStringI (indent : string) (x : lexp) : string = case x of @@ -184,7 +192,6 @@ struct VVar v => "VVar " ^ Int.toString v | VLabel l => "VLabel " ^ Int.toString l | VInt i => "VInt " ^ Int.toString i - | VString s => "VString " ^ quote s fun cexpToStringI (indent : string) (x : cexp) : string = let @@ -216,4 +223,7 @@ struct | OEq (r, v1, v2) => "Var " ^ Int.toString r ^ " = OEq (" ^ valueToString v1 ^ ", " ^ valueToString v2 ^ ")" | OIf (condition, target) => "OIf (" ^ valueToString condition ^ ") goto " ^ Int.toString target | OLabel l => "OLabel " ^ Int.toString l + | ORead (r, ptr, off, len) => "Var " ^ Int.toString r ^ " = ORead (Var " ^ Int.toString ptr ^ ", " ^ valueToString off ^ ", " ^ valueToString len ^ ")" + | OWrite (ptr, off, len) => "OWrite (Var " ^ Int.toString ptr ^ ", " ^ valueToString off ^ ", " ^ valueToString len ^ ")" + | OWriteErr (ptr, off, len) => "OWriteErr (Var " ^ Int.toString ptr ^ ", " ^ valueToString off ^ ", " ^ valueToString len ^ ")" end |
