From 22b8b7e2478e3b205c89cc7a700058bfe39175f2 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sun, 2 Jun 2024 09:17:55 -0700 Subject: Add strings and IO. --- syntax.sml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'syntax.sml') diff --git a/syntax.sml b/syntax.sml index 5672a5b..e05beee 100644 --- a/syntax.sml +++ b/syntax.sml @@ -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 -- cgit v1.3.1