diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2024-05-18 07:23:11 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2024-06-08 13:59:25 -0700 |
| commit | 4fe42be07b7b57147f9cac0d17c2611f71f0758a (patch) | |
| tree | f1bef68c480a04db1dcff04925ce8b2e98f73119 /syntax.sml | |
| parent | Improve read. (diff) | |
| download | sml-4fe42be07b7b57147f9cac0d17c2611f71f0758a.tar.zst | |
Add structures.
Diffstat (limited to 'syntax.sml')
| -rw-r--r-- | syntax.sml | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -12,7 +12,7 @@ struct | PVar of string | PInt of int | PTuple of pat list - | PCon of string * pat + | PCon of string list * pat datatype expr = EIdent of string list @@ -34,6 +34,7 @@ struct | DValRec of pat * expr | DFun of string * (pat list * expr) list | DDatatype of string * (string * etype option) list + | DStruct of string * dec list (* Lambda language *) type var = int @@ -127,7 +128,7 @@ struct | PVar v => "PVar " ^ quote v | PInt i => "PInt " ^ Int.toString i | PTuple pats => "PTuple " ^ listToString patToString pats - | PCon (con, v) => "PCon " ^ "(" ^ quote con ^ ", " ^ patToString v ^ ")" + | PCon (con, v) => "PCon " ^ "(" ^ listToString quote con ^ ", " ^ patToString v ^ ")" fun exprToStringI (indent : string) (x : expr) : string = let val self = exprToStringI indent @@ -153,6 +154,7 @@ struct | DValRec (p, e) => "DValRec (" ^ patToString p ^ ", " ^ exprToStringI indent e ^ ")" | DFun (name, cases) => "DFun (" ^ quote name ^ ", " ^ multilineListToString (fn indent => fn (ps, b) => "(" ^ listToString patToString ps ^ ", " ^ exprToStringI indent b ^ ")") indent cases ^ ")" | DDatatype (name, arms) => "DDatatype (" ^ quote name ^ ", " ^ listToString (fn (con, v) => "(" ^ quote con ^ ", " ^ optionToString etypeToString v ^ ")") arms ^ ")" + | DStruct (name, decls) => "DStruct (" ^ quote name ^ ",\n" ^ indent ^ "\t" ^ multilineListToString decToStringI (indent ^ "\t") decls ^ ")" val exprToString : expr -> string = exprToStringI "" |
