Skip to content

Commit

Permalink
syntax: type field of a structure
Browse files Browse the repository at this point in the history
  • Loading branch information
butterunderflow committed Feb 7, 2024
1 parent c61810d commit 3b71141
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions lib/syntax/parsetree.ml
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
open Sexplib.Conv

type constant = CBool of bool | CInt of int | CString of string
type program = top_level list [@@deriving sexp]

and top_level =
| TopLet of pattern * expr
| TopLetRec of (string * lambda) list
| TopTypeDef of type_def
| TopMod of string * mod_expr
| TopModRec of (string * functor_expr) list
[@@deriving sexp]

type pattern =
and pattern =
| PVal of constant
| PCons of string * pattern list
| PVar of string
[@@deriving sexp]

type type_expr =
and type_expr =
| TCons of string * type_expr list
| TVar of string
| TField of path * string
| TArrow of type_expr * type_expr
| TTuple of type_expr list
[@@deriving sexp]

type para = PAnn of string * type_expr | PBare of string [@@deriving sexp]
and para = PAnn of string * type_expr | PBare of string [@@deriving sexp]

type paras = para list [@@deriving sexp]
and paras = para list [@@deriving sexp]

and constant = CBool of bool | CInt of int | CString of string
[@@deriving sexp]

type expr =
and expr =
| EConst of constant
| EVar of string
| ELet of pattern * expr * expr
Expand All @@ -36,17 +47,9 @@ type expr =

and lambda = para * expr

type variant = string * type_expr option [@@deriving sexp]
and variant = string * type_expr option [@@deriving sexp]

type type_paras = string list [@@deriving sexp]

type top_level =
| TopLet of pattern * expr
| TopLetRec of (string * lambda) list
| TopTypeDef of type_def
| TopMod of string * mod_expr
| TopModRec of (string * functor_expr) list
[@@deriving sexp]
and type_paras = string list [@@deriving sexp]

and type_def =
| TDAdt of string * type_paras * variant list
Expand Down Expand Up @@ -84,5 +87,3 @@ and type_comp =
| TValueSpec of string * type_expr
| TAbstTySpec of string
| TManiTySpec of type_def

type program = top_level list [@@deriving sexp]

0 comments on commit 3b71141

Please sign in to comment.