summaryrefslogtreecommitdiffstats
path: root/Syntax.sml
diff options
context:
space:
mode:
Diffstat (limited to 'Syntax.sml')
-rw-r--r--Syntax.sml56
1 files changed, 53 insertions, 3 deletions
diff --git a/Syntax.sml b/Syntax.sml
index 5d45133..0d10dd2 100644
--- a/Syntax.sml
+++ b/Syntax.sml
@@ -15,7 +15,8 @@ struct
| PCon of string list * pat
datatype expr =
- EIdent of string list
+ EIdent of string
+ | EDot of structExpr * string
| EBuiltin of string
| EInt of int
| EStr of string
@@ -33,14 +34,63 @@ struct
DVal of pat * expr
| DValRec of pat * expr
| DFun of string * (pat list * expr) list
- | DDatatype of string * (string * etype option) list
+ | DDatatype of string list * string * (string * etype option) list
| DType of string * etype
| DStruct of string * structExpr
and structExpr =
- SIdent of string list
+ SIdent of string
+ | SDot of structExpr * string
| SStruct of dec list
+ datatype ty =
+ TInt
+ | TBool
+ | TString
+ | TVar of int
+ | TTuple of ty list
+ | TFun of ty * ty
+ | TList of ty
+ | TDatatype of string list
+
+ datatype structType =
+ TStruct of (string * structType) list * (string * ty) list
+(*| TFunctor of structType * structType *)
+
+ datatype typedPat =
+ TPWild
+ | TPVar of string
+ | TPInt of int
+ | TPTuple of (typedPat * ty) list
+ | TPCon of string list * (typedPat * ty)
+
+ datatype typedExpr =
+ TEIdent of string
+ | TEDot of (typedStructExpr * structType) * string
+ | TEBuiltin of string
+ | TEInt of int
+ | TEStr of string
+ | TETuple of (typedExpr * ty) list
+ | TEList of (typedExpr * ty) list
+ | TEApp of (typedExpr * ty) * (typedExpr * ty)
+ | TEAndAlso of (typedExpr * ty) * (typedExpr * ty)
+ | TEOrElse of (typedExpr * ty) * (typedExpr * ty)
+ | TELet of typedDec list * (typedExpr * ty)
+ | TELambda of (typedPat * ty) * (typedExpr * ty)
+ | TECase of (typedExpr * ty) * ((typedPat * ty) * (typedExpr * ty)) list
+
+ and typedDec =
+ TDVal of (typedPat * ty) * (typedExpr * ty)
+ | TDValRec of (typedPat * ty) * (typedExpr * ty)
+ | TDFun of string * ((typedPat * ty) list * (typedExpr * ty)) list
+ | TDDatatype of string * (string * ty option) list
+ | TDStruct of string * (typedStructExpr * structType)
+
+ and typedStructExpr =
+ TSIdent of string
+ | TSDot of (typedStructExpr * structType) * string
+ | TSStruct of typedDec list
+
(* Lambda language *)
type var = int