summaryrefslogtreecommitdiff
path: root/language/l2.lem
diff options
context:
space:
mode:
authorKathy Gray2014-07-08 15:07:45 +0100
committerKathy Gray2014-07-08 15:07:45 +0100
commite482abd733622647f97b4ebecc6cefeb6b1fccee (patch)
treec4d1fbb605fb28a7f23522d4435423328c45328a /language/l2.lem
parent54bfa59acb4244e29bc9064f09fc800e252fea39 (diff)
Extend language to support register aliases and to support interrupts, traps and the like.
Diffstat (limited to 'language/l2.lem')
-rw-r--r--language/l2.lem162
1 files changed, 88 insertions, 74 deletions
diff --git a/language/l2.lem b/language/l2.lem
index 3b86d2db..e3a52dfa 100644
--- a/language/l2.lem
+++ b/language/l2.lem
@@ -76,30 +76,30 @@ type base_effect =
| BE_aux of base_effect_aux * l
-type id_aux = (* Identifier *)
- | Id of x
- | DeIid of x (* remove infix status *)
-
-
type effect_aux = (* effect set, of kind Effects *)
| Effect_var of kid
| Effect_set of list base_effect (* effect set *)
+type id_aux = (* Identifier *)
+ | Id of x
+ | DeIid of x (* remove infix status *)
+
+
type order_aux = (* vector order specifications, of kind Order *)
| Ord_var of kid (* variable *)
| Ord_inc (* increasing (little-endian) *)
| Ord_dec (* decreasing (big-endian) *)
-type id =
- | Id_aux of id_aux * l
-
-
type effect =
| Effect_aux of effect_aux * l
+type id =
+ | Id_aux of id_aux * l
+
+
type order =
| Ord_aux of order_aux * l
@@ -143,6 +143,10 @@ type typquant_aux = (* type quantifiers and constraints *)
| TypQ_no_forall (* sugar, omitting quantifier and constraints *)
+type typquant =
+ | TypQ_aux of typquant_aux * l
+
+
type typ_aux = (* Type expressions, of kind $Type$ *)
| Typ_wild (* Unspecified type *)
| Typ_id of id (* Defined type *)
@@ -164,10 +168,6 @@ and typ_arg =
| Typ_arg_aux of typ_arg_aux * l
-type typquant =
- | TypQ_aux of typquant_aux * l
-
-
type lit_aux = (* Literal constant *)
| L_unit (* $() : unit$ *)
| L_zero (* $bitzero : bit$ *)
@@ -243,6 +243,7 @@ type exp_aux 'a = (* Expression *)
| E_case of (exp 'a) * list (pexp 'a) (* pattern matching *)
| E_let of (letbind 'a) * (exp 'a) (* let expression *)
| E_assign of (lexp 'a) * (exp 'a) (* imperative assignment *)
+ | E_exit of (exp 'a) (* expression to halt all current execution, potentially calling a system, trap, or interrupt handler with exp *)
| E_internal_cast of annot 'a * (exp 'a) (* This is an internal cast, generated during type checking that will resolve into a syntactic cast after *)
| E_internal_exp of annot 'a (* This is an internal use of an nexp (in the annot) for passing length information after resolution of constraints *)
@@ -293,6 +294,23 @@ and letbind 'a =
| LB_aux of (letbind_aux 'a) * annot 'a
+type alias_spec_aux 'a = (* Register alias expression forms. Other than where noted, each id must refer to an unaliased register of type vector *)
+ | AL_subreg of id * id (* id must refer to a register, id' to a declared subregister of id *)
+ | AL_bit of id * (exp 'a)
+ | AL_slice of id * (exp 'a) * (exp 'a)
+ | AL_concat of id * id (* both id and id' must refer to a register *)
+
+
+type type_union_aux = (* Type union constructors *)
+ | Tu_id of id
+ | Tu_ty_id of typ * id
+
+
+type name_scm_opt_aux = (* Optional variable-naming-scheme specification for variables of defined type *)
+ | Name_sect_none
+ | Name_sect_some of string
+
+
type rec_opt_aux = (* Optional recursive annotation for functions *)
| Rec_nonrec (* non-recursive *)
| Rec_rec (* recursive *)
@@ -303,22 +321,33 @@ type effect_opt_aux = (* Optional effect annotation for functions *)
| Effect_opt_effect of effect
-type type_union_aux = (* Type union constructors *)
- | Tu_id of id
- | Tu_ty_id of typ * id
+type tannot_opt_aux = (* Optional type annotation for functions *)
+ | Typ_annot_opt_some of typquant * typ
type funcl_aux 'a = (* Function clause *)
| FCL_Funcl of id * (pat 'a) * (exp 'a)
-type tannot_opt_aux = (* Optional type annotation for functions *)
- | Typ_annot_opt_some of typquant * typ
+type alias_spec 'a =
+ | AL_aux of (alias_spec_aux 'a) * annot 'a
-type name_scm_opt_aux = (* Optional variable-naming-scheme specification for variables of defined type *)
- | Name_sect_none
- | Name_sect_some of string
+type type_union =
+ | Tu_aux of type_union_aux * l
+
+
+type name_scm_opt =
+ | Name_sect_aux of name_scm_opt_aux * l
+
+
+type index_range_aux = (* index specification, for bitfields in register types *)
+ | BF_single of integer (* single index *)
+ | BF_range of integer * integer (* index range *)
+ | BF_concat of index_range * index_range (* concatenation of index ranges *)
+
+and index_range =
+ | BF_aux of index_range_aux * l
type rec_opt =
@@ -329,33 +358,36 @@ type effect_opt =
| Effect_opt_aux of effect_opt_aux * l
-type type_union =
- | Tu_aux of type_union_aux * l
+type tannot_opt =
+ | Typ_annot_opt_aux of tannot_opt_aux * l
type funcl 'a =
| FCL_aux of (funcl_aux 'a) * l
-type tannot_opt =
- | Typ_annot_opt_aux of tannot_opt_aux * l
-
+type val_spec_aux 'a = (* Value type specification *)
+ | VS_val_spec of typschm * id
+ | VS_extern_no_rename of typschm * id
+ | VS_extern_spec of typschm * id * string (* Specify the type and id of a function from Lem, where the string must provide an explicit path to the required function but will not be checked *)
-type name_scm_opt =
- | Name_sect_aux of name_scm_opt_aux * l
+type dec_spec_aux 'a = (* Register declarations *)
+ | DEC_reg of typ * id
+ | DEC_alias of id * (alias_spec 'a)
+ | DEC_typ_alias of typ * id * (alias_spec 'a)
-type index_range_aux = (* index specification, for bitfields in register types *)
- | BF_single of integer (* single index *)
- | BF_range of integer * integer (* index range *)
- | BF_concat of index_range * index_range (* concatenation of index ranges *)
-and index_range =
- | BF_aux of index_range_aux * l
+type type_def_aux 'a = (* Type definition body *)
+ | TD_abbrev of id * name_scm_opt * typschm (* type abbreviation *)
+ | TD_record of id * name_scm_opt * typquant * list (typ * id) * bool (* struct type definition *)
+ | TD_variant of id * name_scm_opt * typquant * list type_union * bool (* union type definition *)
+ | TD_enum of id * name_scm_opt * list id * bool (* enumeration type definition *)
+ | TD_register of id * nexp * nexp * list (index_range * id) (* register mutable bitfield type definition *)
-type dec_spec_aux 'a = (* Register declarations *)
- | DEC_reg of typ * id
+type fundef_aux 'a = (* Function definition *)
+ | FD_function of rec_opt * tannot_opt * effect_opt * list (funcl 'a)
type scattered_def_aux 'a = (* Function and type union definitions that can be spread across
@@ -367,51 +399,33 @@ type scattered_def_aux 'a = (* Function and type union definitions that can be
| SD_scattered_end of id (* scattered definition end *)
-type fundef_aux 'a = (* Function definition *)
- | FD_function of rec_opt * tannot_opt * effect_opt * list (funcl 'a)
-
-
type default_spec_aux 'a = (* Default kinding or typing assumption *)
| DT_kind of base_kind * kid
| DT_typ of typschm * id
-type type_def_aux 'a = (* Type definition body *)
- | TD_abbrev of id * name_scm_opt * typschm (* type abbreviation *)
- | TD_record of id * name_scm_opt * typquant * list (typ * id) * bool (* struct type definition *)
- | TD_variant of id * name_scm_opt * typquant * list type_union * bool (* union type definition *)
- | TD_enum of id * name_scm_opt * list id * bool (* enumeration type definition *)
- | TD_register of id * nexp * nexp * list (index_range * id) (* register mutable bitfield type definition *)
-
-
-type val_spec_aux 'a = (* Value type specification *)
- | VS_val_spec of typschm * id
- | VS_extern_no_rename of typschm * id
- | VS_extern_spec of typschm * id * string (* Specify the type and id of a function from Lem, where the string must provide an explicit path to the required function but will not be checked *)
+type val_spec 'a =
+ | VS_aux of (val_spec_aux 'a) * annot 'a
type dec_spec 'a =
| DEC_aux of (dec_spec_aux 'a) * annot 'a
-type scattered_def 'a =
- | SD_aux of (scattered_def_aux 'a) * annot 'a
+type type_def 'a =
+ | TD_aux of (type_def_aux 'a) * annot 'a
type fundef 'a =
| FD_aux of (fundef_aux 'a) * annot 'a
-type default_spec 'a =
- | DT_aux of (default_spec_aux 'a) * l
-
-
-type type_def 'a =
- | TD_aux of (type_def_aux 'a) * annot 'a
+type scattered_def 'a =
+ | SD_aux of (scattered_def_aux 'a) * annot 'a
-type val_spec 'a =
- | VS_aux of (val_spec_aux 'a) * annot 'a
+type default_spec 'a =
+ | DT_aux of (default_spec_aux 'a) * l
type def 'a = (* Top-level definition *)
@@ -488,6 +502,16 @@ type tid = (* A type identifier or type variable *)
| Tid_var of kid
+type tag = (* Data indicating where the identifier arises and thus information necessary in compilation *)
+ | Tag_empty
+ | Tag_global (* Globally let-bound or enumeration based value/variable *)
+ | Tag_ctor (* Data constructor from a type union *)
+ | Tag_extern of maybe string (* External function, specied only with a val statement *)
+ | Tag_default (* Type has come from default declaration, identifier may not be bound locally *)
+ | Tag_spec
+ | Tag_enum
+
+
type t = (* Internal types *)
| T_id of x
| T_var of x
@@ -506,16 +530,6 @@ and t_args = (* Arguments to type constructors *)
| T_args of list t_arg
-type tag = (* Data indicating where the identifier arises and thus information necessary in compilation *)
- | Tag_empty
- | Tag_global (* Globally let-bound or enumeration based value/variable *)
- | Tag_ctor (* Data constructor from a type union *)
- | Tag_extern of maybe string (* External function, specied only with a val statement *)
- | Tag_default (* Type has come from default declaration, identifier may not be bound locally *)
- | Tag_spec
- | Tag_enum
-
-
type tinf = (* Type variables, type, and constraints, bound to an identifier *)
| Tinf_typ of t
| Tinf_quant_typ of (map tid kinf) * list nec * tag * t
@@ -565,10 +579,10 @@ let fresh_kid denv = Var "x" (*TODO When strings can be manipulated, this should
-type E = env
+type I = inf
-type I = inf
+type E = env