diff options
| author | Kathy Gray | 2013-10-11 15:11:45 +0100 |
|---|---|---|
| committer | Kathy Gray | 2013-10-11 15:11:45 +0100 |
| commit | afe5cdfeead6f22fb8449497b0c4f02206ba4472 (patch) | |
| tree | 60e2827df542dbe8efdc2b29115c1e2b0ceff7c3 /language/l2.ml | |
| parent | 40b4aefdd9d225acf7c6a22237e89ecb4148f2e6 (diff) | |
Supporting all expressions, although vector cacentation pattern matching can only match simple patterns (until type information is available).
Diffstat (limited to 'language/l2.ml')
| -rw-r--r-- | language/l2.ml | 204 |
1 files changed, 97 insertions, 107 deletions
diff --git a/language/l2.ml b/language/l2.ml index 786d04ab..c5cfd00b 100644 --- a/language/l2.ml +++ b/language/l2.ml @@ -20,14 +20,19 @@ base_kind_aux = (* base kind *) type +base_kind = + BK_aux of base_kind_aux * l + + +type id_aux = (* Identifier *) Id of x | DeIid of x (* remove infix status *) type -base_kind = - BK_aux of base_kind_aux * l +kind_aux = (* kinds *) + K_kind of (base_kind) list type @@ -36,8 +41,8 @@ id = type -kind_aux = (* kinds *) - K_kind of (base_kind) list +kind = + K_aux of kind_aux * l type @@ -53,8 +58,9 @@ and nexp = type -kind = - K_aux of kind_aux * l +kinded_id_aux = (* optionally kind-annotated identifier *) + KOpt_none of id (* identifier *) + | KOpt_kind of kind * id (* kind-annotated variable *) type @@ -66,22 +72,6 @@ nexp_constraint_aux = (* constraint over kind $_$ *) type -kinded_id_aux = (* optionally kind-annotated identifier *) - KOpt_none of id (* identifier *) - | KOpt_kind of kind * id (* kind-annotated variable *) - - -type -nexp_constraint = - NC_aux of nexp_constraint_aux * l - - -type -kinded_id = - KOpt_aux of kinded_id_aux * l - - -type efct_aux = (* effect *) Effect_rreg (* read register *) | Effect_wreg (* write register *) @@ -93,9 +83,13 @@ efct_aux = (* effect *) type -quant_item_aux = (* Either a kinded identifier or a nexp constraint for a typquant *) - QI_id of kinded_id (* An optionally kinded identifier *) - | QI_const of nexp_constraint (* A constraint for this type *) +kinded_id = + KOpt_aux of kinded_id_aux * l + + +type +nexp_constraint = + NC_aux of nexp_constraint_aux * l type @@ -104,8 +98,9 @@ efct = type -quant_item = - QI_aux of quant_item_aux * l +quant_item_aux = (* Either a kinded identifier or a nexp constraint for a typquant *) + QI_id of kinded_id (* An optionally kinded identifier *) + | QI_const of nexp_constraint (* A constraint for this type *) type @@ -122,9 +117,8 @@ order_aux = (* vector order specifications, of kind $_$ *) type -typquant_aux = (* type quantifiers and constraints *) - TypQ_tq of (quant_item) list - | TypQ_no_forall (* sugar, omitting quantifier and constraints *) +quant_item = + QI_aux of quant_item_aux * l type @@ -138,22 +132,9 @@ order = type -lit_aux = (* Literal constant *) - L_unit (* $() : _$ *) - | L_zero (* $_ : _$ *) - | L_one (* $_ : _$ *) - | L_true (* $_ : _$ *) - | L_false (* $_ : _$ *) - | L_num of int (* natural number constant *) - | L_hex of string (* bit vector constant, C-style *) - | L_bin of string (* bit vector constant, C-style *) - | L_undef (* constant representing undefined values *) - | L_string of string (* string constant *) - - -type -typquant = - TypQ_aux of typquant_aux * l +typquant_aux = (* type quantifiers and constraints *) + TypQ_tq of (quant_item) list + | TypQ_no_forall (* sugar, omitting quantifier and constraints *) type @@ -178,8 +159,22 @@ and typ_arg = type -lit = - L_aux of lit_aux * l +typquant = + TypQ_aux of typquant_aux * l + + +type +lit_aux = (* Literal constant *) + L_unit (* $() : _$ *) + | L_zero (* $_ : _$ *) + | L_one (* $_ : _$ *) + | L_true (* $_ : _$ *) + | L_false (* $_ : _$ *) + | L_num of int (* natural number constant *) + | L_hex of string (* bit vector constant, C-style *) + | L_bin of string (* bit vector constant, C-style *) + | L_undef (* constant representing undefined values *) + | L_string of string (* string constant *) type @@ -188,6 +183,16 @@ typschm_aux = (* type scheme *) type +lit = + L_aux of lit_aux * l + + +type +typschm = + TypSchm_aux of typschm_aux * l + + +type 'a pat_aux = (* Pattern *) P_lit of lit (* literal constant pattern *) | P_wild (* wildcard *) @@ -213,11 +218,6 @@ and 'a fpat = type -typschm = - TypSchm_aux of typschm_aux * l - - -type 'a exp_aux = (* Expression *) E_block of ('a exp) list (* block (parsing conflict with structs?) *) | E_id of id (* identifier *) @@ -283,14 +283,9 @@ and 'a letbind = type -rec_opt_aux = (* Optional recursive annotation for functions *) - Rec_nonrec (* non-recursive *) - | Rec_rec (* recursive *) - - -type -'a funcl_aux = (* Function clause *) - FCL_Funcl of id * 'a pat * 'a exp +naming_scheme_opt_aux = (* Optional variable-naming-scheme specification for variables of defined type *) + Name_sect_none + | Name_sect_some of string type @@ -305,19 +300,29 @@ type type -naming_scheme_opt_aux = (* Optional variable-naming-scheme specification for variables of defined type *) - Name_sect_none - | Name_sect_some of string +rec_opt_aux = (* Optional recursive annotation for functions *) + Rec_nonrec (* non-recursive *) + | Rec_rec (* recursive *) type -rec_opt = - Rec_aux of rec_opt_aux * l +'a funcl_aux = (* Function clause *) + FCL_Funcl of id * 'a pat * 'a exp type -'a funcl = - FCL_aux of 'a funcl_aux * 'a annot +index_range_aux = (* index specification, for bitfields in register types *) + BF_single of int (* single index *) + | BF_range of int * int (* index range *) + | BF_concat of index_range * index_range (* concatenation of index ranges *) + +and index_range = + BF_aux of index_range_aux * l + + +type +naming_scheme_opt = + Name_sect_aux of naming_scheme_opt_aux * l type @@ -331,28 +336,27 @@ type type -index_range_aux = (* index specification, for bitfields in register types *) - BF_single of int (* single index *) - | BF_range of int * int (* index range *) - | BF_concat of index_range * index_range (* concatenation of index ranges *) - -and index_range = - BF_aux of index_range_aux * l +rec_opt = + Rec_aux of rec_opt_aux * l type -naming_scheme_opt = - Name_sect_aux of naming_scheme_opt_aux * l +'a funcl = + FCL_aux of 'a funcl_aux * 'a annot type -'a fundef_aux = (* Function definition *) - FD_function of rec_opt * 'a tannot_opt * 'a effects_opt * ('a funcl) list +'a val_spec_aux = (* Value type specification *) + VS_val_spec of typschm * id type -'a val_spec_aux = (* Value type specification *) - VS_val_spec of typschm * id +'a type_def_aux = (* Type definition body *) + TD_abbrev of id * naming_scheme_opt * typschm (* type abbreviation *) + | TD_record of id * naming_scheme_opt * typquant * ((typ * id)) list * bool (* struct type definition *) + | TD_variant of id * naming_scheme_opt * typquant * ((typ * id)) list * bool (* union type definition *) + | TD_enum of id * naming_scheme_opt * (id) list * bool (* enumeration type definition *) + | TD_register of id * nexp * nexp * ((index_range * id)) list (* register mutable bitfield type definition *) type @@ -362,12 +366,8 @@ type type -'a type_def_aux = (* Type definition body *) - TD_abbrev of id * naming_scheme_opt * typschm (* type abbreviation *) - | TD_record of id * naming_scheme_opt * typquant * ((typ * id)) list * bool (* struct type definition *) - | TD_variant of id * naming_scheme_opt * typquant * ((typ * id)) list * bool (* union type definition *) - | TD_enum of id * naming_scheme_opt * (id) list * bool (* enumeration type definition *) - | TD_register of id * nexp * nexp * ((index_range * id)) list (* register mutable bitfield type definition *) +'a fundef_aux = (* Function definition *) + FD_function of rec_opt * 'a tannot_opt * 'a effects_opt * ('a funcl) list type @@ -381,13 +381,13 @@ ne = (* internal numeric expressions *) type -'a fundef = - FD_aux of 'a fundef_aux * 'a annot +'a val_spec = + VS_aux of 'a val_spec_aux * 'a annot type -'a val_spec = - VS_aux of 'a val_spec_aux * 'a annot +'a type_def = + TD_aux of 'a type_def_aux * 'a annot type @@ -396,8 +396,8 @@ type type -'a type_def = - TD_aux of 'a type_def_aux * 'a annot +'a fundef = + FD_aux of 'a fundef_aux * 'a annot type @@ -427,8 +427,8 @@ type type -'a ctor_def_aux = (* Datatype constructor definition clause *) - CT_ct of id * typschm +'a def = + DEF_aux of 'a def_aux * 'a annot type @@ -450,13 +450,8 @@ type type -'a def = - DEF_aux of 'a def_aux * 'a annot - - -type -'a ctor_def = - CT_aux of 'a ctor_def_aux * 'a annot +'a defs = (* Definition sequence *) + Defs of ('a def) list type @@ -464,9 +459,4 @@ type Typ_lib_aux of 'a typ_lib_aux * l -type -'a defs = (* Definition sequence *) - Defs of ('a def) list - - |
