summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKathy Gray2013-07-23 18:56:44 +0100
committerKathy Gray2013-07-23 18:56:44 +0100
commit16a3fa0e32839bdf39684b7ba8b2ed039e2eb51d (patch)
tree84aa7c790b97977ec521350475b5192abf14a8d6 /src
parent33c8450d506db246be6255edcd17b601783c882f (diff)
Down to 7 shift/reduce conflicts (with 0 reduce/reduce). Possibly some syntax needs to change.
ott file now builds a pdf again
Diffstat (limited to 'src')
-rw-r--r--src/ast.ml170
-rw-r--r--src/parse_ast.ml126
-rw-r--r--src/parser.mly134
3 files changed, 206 insertions, 224 deletions
diff --git a/src/ast.ml b/src/ast.ml
index c072fd6e..f27c2a89 100644
--- a/src/ast.ml
+++ b/src/ast.ml
@@ -59,14 +59,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 terminal * x * terminal (* remove infix status *)
type
-base_kind =
- BK_aux of base_kind_aux * l
+kind_aux = (* kinds *)
+ K_kind of (base_kind * terminal) list
type
@@ -75,11 +80,6 @@ id =
type
-kind_aux = (* kinds *)
- K_kind of (base_kind * terminal) list
-
-
-type
efct_aux = (* effect *)
Effect_rreg of terminal (* read register *)
| Effect_wreg of terminal (* write register *)
@@ -91,6 +91,11 @@ efct_aux = (* effect *)
type
+kind =
+ K_aux of kind_aux * l
+
+
+type
nexp_aux = (* expression of kind $_$, for vector sizes and origins *)
Nexp_id of id (* identifier *)
| Nexp_constant of (terminal * int) (* constant *)
@@ -103,13 +108,14 @@ and nexp =
type
-kind =
- K_aux of kind_aux * l
+efct =
+ Effect_aux of efct_aux * l
type
-efct =
- Effect_aux of efct_aux * l
+kinded_id_aux = (* optionally kind-annotated identifier *)
+ KOpt_none of id (* identifier *)
+ | KOpt_kind of kind * id (* kind-annotated variable *)
type
@@ -121,12 +127,6 @@ type
type
-kinded_id_aux = (* optionally kind-annotated identifier *)
- KOpt_none of id (* identifier *)
- | KOpt_kind of kind * id (* kind-annotated variable *)
-
-
-type
effects_aux = (* effect set, of kind $_$ *)
Effects_var of terminal * id
| Effects_set of terminal * terminal * (efct * terminal) list * terminal (* effect set *)
@@ -140,13 +140,13 @@ order_aux = (* vector order specifications, of kind $_$ *)
type
-'a nexp_constraint =
- NC_aux of 'a nexp_constraint_aux * 'a annot
+kinded_id =
+ KOpt_aux of kinded_id_aux * l
type
-kinded_id =
- KOpt_aux of kinded_id_aux * l
+'a nexp_constraint =
+ NC_aux of 'a nexp_constraint_aux * 'a annot
type
@@ -167,6 +167,19 @@ type
type
+lit_aux = (* Literal constant *)
+ L_unit of terminal * terminal (* $() : _$ *)
+ | L_zero of terminal (* $_ : _$ *)
+ | L_one of terminal (* $_ : _$ *)
+ | L_true of terminal (* $_ : _$ *)
+ | L_false of terminal (* $_ : _$ *)
+ | L_num of (terminal * int) (* natural number constant *)
+ | L_hex of terminal * string (* bit vector constant, C-style *)
+ | L_bin of terminal * string (* bit vector constant, C-style *)
+ | L_string of terminal * string (* string constant *)
+
+
+type
typ_aux = (* Type expressions, of kind $_$ *)
Typ_wild of terminal (* Unspecified type *)
| Typ_var of id (* Type variable *)
@@ -193,31 +206,13 @@ type
type
-lit_aux = (* Literal constant *)
- L_unit of terminal * terminal (* $() : _$ *)
- | L_zero of terminal (* $_ : _$ *)
- | L_one of terminal (* $_ : _$ *)
- | L_true of terminal (* $_ : _$ *)
- | L_false of terminal (* $_ : _$ *)
- | L_num of (terminal * int) (* natural number constant *)
- | L_hex of terminal * string (* bit vector constant, C-style *)
- | L_bin of terminal * string (* bit vector constant, C-style *)
- | L_string of terminal * string (* string constant *)
-
-
-type
-'a typschm_aux = (* type scheme *)
- TypSchm_ts of 'a typquant * typ
-
-
-type
lit =
L_aux of lit_aux * l
type
-'a typschm =
- TypSchm_aux of 'a typschm_aux * 'a annot
+'a typschm_aux = (* type scheme *)
+ TypSchm_ts of 'a typquant * typ
type
@@ -246,7 +241,15 @@ and 'a fpat =
type
-'a exp_aux = (* Expression *)
+'a typschm =
+ TypSchm_aux of 'a typschm_aux * 'a annot
+
+
+type
+'a letbind =
+ LB_aux of 'a letbind_aux * 'a annot
+
+and 'a exp_aux = (* Expression *)
E_block of terminal * ('a exp * terminal) list * terminal (* block (parsing conflict with structs?) *)
| E_id of id (* identifier *)
| E_lit of lit (* literal constant *)
@@ -304,9 +307,6 @@ and 'a letbind_aux = (* Let binding *)
LB_val_explicit of 'a typschm * 'a pat * terminal * 'a exp (* value binding, explicit type ('a pat must be total) *)
| LB_val_implicit of terminal * 'a pat * terminal * 'a exp (* value binding, implicit type ('a pat must be total) *)
-and 'a letbind =
- LB_aux of 'a letbind_aux * 'a annot
-
type
naming_scheme_opt_aux = (* Optional variable-naming-scheme specification for variables of defined type *)
@@ -315,31 +315,26 @@ naming_scheme_opt_aux = (* Optional variable-naming-scheme specification for va
type
-'a tannot_opt_aux = (* Optional type annotation for functions *)
- Typ_annot_opt_none
- | Typ_annot_opt_some of terminal * typ
-
-
-type
rec_opt_aux = (* Optional recursive annotation for functions *)
Rec_nonrec (* non-recursive *)
| Rec_rec of terminal (* recursive *)
type
-'a effects_opt_aux = (* Optional effect annotation for functions *)
- Effects_opt_pure (* sugar for empty effect set *)
- | Effects_opt_effects of effects
+'a funcl_aux = (* Function clause *)
+ FCL_Funcl of id * 'a pat * terminal * 'a exp
type
-'a funcl_aux = (* Function clause *)
- FCL_Funcl of id * 'a pat * terminal * 'a exp
+'a tannot_opt_aux = (* Optional type annotation for functions *)
+ Typ_annot_opt_none
+ | Typ_annot_opt_some of terminal * typ
type
-naming_scheme_opt =
- Name_sect_aux of naming_scheme_opt_aux * l
+'a effects_opt_aux = (* Optional effect annotation for functions *)
+ Effects_opt_pure (* sugar for empty effect set *)
+ | Effects_opt_effects of effects
type
@@ -353,8 +348,8 @@ and index_range =
type
-'a tannot_opt =
- Typ_annot_opt_aux of 'a tannot_opt_aux * 'a annot
+naming_scheme_opt =
+ Name_sect_aux of naming_scheme_opt_aux * l
type
@@ -363,19 +358,18 @@ rec_opt =
type
-'a effects_opt =
- Effects_opt_aux of 'a effects_opt_aux * 'a annot
+'a funcl =
+ FCL_aux of 'a funcl_aux * 'a annot
type
-'a funcl =
- FCL_aux of 'a funcl_aux * 'a annot
+'a tannot_opt =
+ Typ_annot_opt_aux of 'a tannot_opt_aux * 'a annot
type
-'a default_typing_spec_aux = (* Default kinding or typing assumption *)
- DT_kind of terminal * base_kind * id
- | DT_typ of terminal * 'a typschm * id
+'a effects_opt =
+ Effects_opt_aux of 'a effects_opt_aux * 'a annot
type
@@ -388,18 +382,19 @@ type
type
-'a fundef_aux = (* Function definition *)
- FD_function of terminal * rec_opt * 'a tannot_opt * 'a effects_opt * ('a funcl * terminal) list
+'a val_spec_aux = (* Value type specification *)
+ VS_val_spec of terminal * 'a typschm * id
type
-'a val_spec_aux = (* Value type specification *)
- VS_val_spec of terminal * 'a typschm * id
+'a default_typing_spec_aux = (* Default kinding or typing assumption *)
+ DT_kind of terminal * base_kind * id
+ | DT_typ of terminal * 'a typschm * id
type
-'a default_typing_spec =
- DT_aux of 'a default_typing_spec_aux * 'a annot
+'a fundef_aux = (* Function definition *)
+ FD_function of terminal * rec_opt * 'a tannot_opt * 'a effects_opt * ('a funcl * terminal) list
type
@@ -408,13 +403,18 @@ type
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 default_typing_spec =
+ DT_aux of 'a default_typing_spec_aux * 'a annot
+
+
+type
+'a fundef =
+ FD_aux of 'a fundef_aux * 'a annot
type
@@ -433,18 +433,13 @@ type
type
-'a def =
- DEF_aux of 'a def_aux * 'a annot
-
-
-type
'a typ_lib_aux = (* library types and syntactic sugar for them *)
Typ_lib_unit of terminal (* unit type with value $()$ *)
| Typ_lib_bool of terminal (* booleans $_$ and $_$ *)
| Typ_lib_bit of terminal (* pure bit values (not mutable bits) *)
| Typ_lib_nat of terminal (* natural numbers 0,1,2,... *)
| Typ_lib_string of terminal * string (* UTF8 strings *)
- | Typ_lib_enum of terminal * nexp * nexp * order (* natural numbers nexp .. nexp+nexp-1, ordered by $order$ *)
+ | Typ_lib_enum of terminal * nexp * nexp * order (* natural numbers nexp .. nexp+nexp-1, ordered by order *)
| Typ_lib_enum1 of terminal * nexp * terminal (* sugar for \texttt{enum nexp 0 inc} *)
| Typ_lib_enum2 of terminal * nexp * terminal * nexp * terminal (* sugar for \texttt{enum (nexp'-nexp+1) nexp inc} or \texttt{enum (nexp-nexp'+1) nexp' dec} *)
| Typ_lib_vector of terminal * nexp * nexp * order * typ (* vector of typ, indexed by natural range *)
@@ -461,8 +456,8 @@ type
type
-'a defs = (* Definition sequence *)
- Defs of ('a def) list
+'a def =
+ DEF_aux of 'a def_aux * 'a annot
type
@@ -475,4 +470,9 @@ type
CT_aux of 'a ctor_def_aux * 'a annot
+type
+'a defs = (* Definition sequence *)
+ Defs of ('a def) list
+
+
diff --git a/src/parse_ast.ml b/src/parse_ast.ml
index 9d2b93cc..da716969 100644
--- a/src/parse_ast.ml
+++ b/src/parse_ast.ml
@@ -59,12 +59,6 @@ base_kind_aux = (* base kind *)
type
-id_aux = (* Identifier *)
- Id of x
- | DeIid of terminal * x * terminal (* remove infix status *)
-
-
-type
efct_aux = (* effect *)
Effect_rreg of terminal (* read register *)
| Effect_wreg of terminal (* write register *)
@@ -76,13 +70,14 @@ efct_aux = (* effect *)
type
-base_kind =
- BK_aux of base_kind_aux * l
+id_aux = (* Identifier *)
+ Id of x
+ | DeIid of terminal * x * terminal (* remove infix status *)
type
-id =
- Id_aux of id_aux * l
+base_kind =
+ BK_aux of base_kind_aux * l
type
@@ -91,6 +86,11 @@ efct =
type
+id =
+ Id_aux of id_aux * l
+
+
+type
kind_aux = (* kinds *)
K_kind of (base_kind * terminal) list
@@ -152,11 +152,6 @@ type
type
-'a typquant =
- TypQ_aux of 'a typquant_aux * 'a annot
-
-
-type
lit_aux = (* Literal constant *)
L_unit of terminal * terminal (* $() : _$ *)
| L_zero of terminal (* $_ : _$ *)
@@ -170,8 +165,8 @@ lit_aux = (* Literal constant *)
type
-'a typschm_aux = (* type scheme *)
- TypSchm_ts of 'a typquant * atyp
+'a typquant =
+ TypQ_aux of 'a typquant_aux * 'a annot
type
@@ -180,8 +175,8 @@ lit =
type
-'a typschm =
- TypSchm_aux of 'a typschm_aux * 'a annot
+'a typschm_aux = (* type scheme *)
+ TypSchm_ts of 'a typquant * atyp
type
@@ -210,6 +205,11 @@ and 'a fpat =
type
+'a typschm =
+ TypSchm_aux of 'a typschm_aux * 'a annot
+
+
+type
'a exp_aux = (* Expression *)
E_block of terminal * ('a exp * terminal) list * terminal (* block (parsing conflict with structs?) *)
| E_id of id (* identifier *)
@@ -273,15 +273,8 @@ and 'a letbind =
type
-naming_scheme_opt_aux = (* Optional variable-naming-scheme specification for variables of defined type *)
- Name_sect_none
- | Name_sect_some of terminal * terminal * terminal * terminal * string * terminal
-
-
-type
-'a tannot_opt_aux = (* Optional type annotation for functions *)
- Typ_annot_opt_none
- | Typ_annot_opt_some of terminal * terminal
+'a funcl_aux = (* Function clause *)
+ FCL_Funcl of id * 'a pat * terminal * 'a exp
type
@@ -297,23 +290,30 @@ type
type
-'a funcl_aux = (* Function clause *)
- FCL_Funcl of id * 'a pat * terminal * 'a exp
+'a tannot_opt_aux = (* Optional type annotation for functions *)
+ Typ_annot_opt_none
+ | Typ_annot_opt_some of terminal * terminal
type
-naming_scheme_opt =
- Name_sect_aux of naming_scheme_opt_aux * l
+naming_scheme_opt_aux = (* Optional variable-naming-scheme specification for variables of defined type *)
+ Name_sect_none
+ | Name_sect_some of terminal * terminal * terminal * terminal * string * terminal
type
-index_range_aux = (* index specification, for bitfields in register types *)
- BF_single of (terminal * int) (* single index *)
- | BF_range of (terminal * int) * terminal * (terminal * int) (* index range *)
- | BF_concat of index_range * terminal * index_range (* concatenation of index ranges *)
+'a funcl =
+ FCL_aux of 'a funcl_aux * 'a annot
-and index_range =
- BF_aux of index_range_aux * l
+
+type
+rec_opt =
+ Rec_aux of rec_opt_aux * l
+
+
+type
+'a effects_opt =
+ Effects_opt_aux of 'a effects_opt_aux * 'a annot
type
@@ -322,18 +322,23 @@ type
type
-rec_opt =
- Rec_aux of rec_opt_aux * l
+index_range_aux = (* index specification, for bitfields in register types *)
+ BF_single of (terminal * int) (* single index *)
+ | BF_range of (terminal * int) * terminal * (terminal * int) (* index range *)
+ | BF_concat of index_range * terminal * index_range (* concatenation of index ranges *)
+
+and index_range =
+ BF_aux of index_range_aux * l
type
-'a effects_opt =
- Effects_opt_aux of 'a effects_opt_aux * 'a annot
+naming_scheme_opt =
+ Name_sect_aux of naming_scheme_opt_aux * l
type
-'a funcl =
- FCL_aux of 'a funcl_aux * 'a annot
+'a fundef_aux = (* Function definition *)
+ FD_function of terminal * rec_opt * 'a tannot_opt * 'a effects_opt * ('a funcl * terminal) list
type
@@ -346,8 +351,9 @@ type
type
-'a fundef_aux = (* Function definition *)
- FD_function of terminal * rec_opt * 'a tannot_opt * 'a effects_opt * ('a funcl * terminal) list
+'a default_typing_spec_aux = (* Default kinding or typing assumption *)
+ DT_kind of terminal * base_kind * id
+ | DT_typ of terminal * 'a typschm * id
type
@@ -356,9 +362,8 @@ type
type
-'a default_typing_spec_aux = (* Default kinding or typing assumption *)
- DT_kind of terminal * base_kind * id
- | DT_typ of terminal * 'a typschm * id
+'a fundef =
+ FD_aux of 'a fundef_aux * 'a annot
type
@@ -367,8 +372,8 @@ type
type
-'a fundef =
- FD_aux of 'a fundef_aux * 'a annot
+'a default_typing_spec =
+ DT_aux of 'a default_typing_spec_aux * 'a annot
type
@@ -377,11 +382,6 @@ type
type
-'a default_typing_spec =
- DT_aux of 'a default_typing_spec_aux * 'a annot
-
-
-type
'a def_aux = (* Top-level definition *)
DEF_type of 'a type_def (* type definition *)
| DEF_fundef of 'a fundef (* function definition *)
@@ -397,6 +397,11 @@ type
type
+'a def =
+ DEF_aux of 'a def_aux * 'a annot
+
+
+type
'a typ_lib_aux = (* library types and syntactic sugar for them *)
Typ_lib_unit of terminal (* unit type with value $()$ *)
| Typ_lib_bool of terminal (* booleans $_$ and $_$ *)
@@ -420,8 +425,8 @@ type
type
-'a def =
- DEF_aux of 'a def_aux * 'a annot
+'a defs = (* Definition sequence *)
+ Defs of ('a def) list
type
@@ -434,9 +439,4 @@ type
CT_aux of 'a ctor_def_aux * 'a annot
-type
-'a defs = (* Definition sequence *)
- Defs of ('a def) list
-
-
diff --git a/src/parser.mly b/src/parser.mly
index ac797b1c..823792d6 100644
--- a/src/parser.mly
+++ b/src/parser.mly
@@ -242,19 +242,19 @@ atomic_typs:
| atomic_typ
{ [$1] }
| atomic_typ atomic_typs
- { $1::$2 }
+ { $1::$2 }
app_typ:
| atomic_typ
{ $1 }
| id atomic_typs
- { tloc (ATyp_app($1,$2)) }
+ { tloc (ATyp_app($1,$2)) }
star_typ_list:
| app_typ
{ [($1,None)] }
| app_typ Star star_typ_list
- { ($1,fst $2)::$3 }
+ { ($1,fst $2)::$3 }
star_typ:
| star_typ_list
@@ -270,19 +270,19 @@ exp_typ:
| Num StarStar typ
{ if (2 = (fst $1))
then tloc (ATyp_exp((fst $1,snd $1),$2,$3))
- else Parse_error_locn(loc (), "Only 2 is a valid exponent base in Nats") }
+ else Parse_error_locn(loc (), "Only 2 is a valid exponent base in Nats") }
nexp_typ:
| exp_typ
{ $1 }
| atomic_typ Plus typ
- { tloc (ATyp_sum($1,fst $2,$3)) }
+ { tloc (ATyp_sum($1,fst $2,$3)) }
typ:
| nexp_typ
{ $1 }
| star_typ MinusGt atomic_typ effect_typ
- { tloc (ATyp_fn($1,$2,$3,$4)) }
+ { tloc (ATyp_fn($1,$2,$3,$4)) }
lit:
| True
@@ -328,18 +328,11 @@ atomic_pat:
| Lparen pat Rparen
{ $2 }
-
-atomic_pats:
- | atomic_pat
- { [$1] }
- | atomic_pat atomic_pats
- { $1::$2 }
-
app_pat:
| atomic_pat
{ $1 }
- | id atomic_pats
- { ploc (P_app($1,$2)) }
+ | id pat
+ { ploc (P_app($1,[$2])) }
pat_colons:
| atomic_pat Colon atomic_pat
@@ -385,14 +378,12 @@ atomic_exp:
| Lcurly semi_exps Rcurly
{ eloc (E_block($1,$2,$3)) }
| id
- { eloc (E_id($1)) }
+ { eloc (E_id($1)) }
| lit
{ eloc (E_lit($1)) }
| Lparen exp Rparen
{ $2 }
-/* | Lparen typ Rparen exp
- { eloc (E_cast($1,$2,$3,$4)) }
-*/ | Lparen comma_exps Rparen
+ | Lparen comma_exps Rparen
{ eloc (E_tup($1,$2,$3)) }
| Lsquare comma_exps Rsquare
{ eloc (E_vector($1,$2,$3)) }
@@ -405,7 +396,6 @@ atomic_exp:
| Switch exp Lcurly case_exps Rcurly
{ eloc (E_case($1,$2,$3,$4,$5)) }
-
field_exp:
| atomic_exp
{ $1 }
@@ -423,14 +413,10 @@ vaccess_exp:
app_exp:
| vaccess_exp
{ $1 }
- | atomic_exp exps
+ | id Lparen exp Rparen
{ eloc (E_app($1,$2)) }
-
-exps:
- | atomic_exp
- { [$1] }
- | atomic_exp exps
- { $1::$2 }
+ | id Lparen comma_exps Rparen
+ { eloc (E_app($1,$3)) }
right_atomic_exp:
| If_ exp Then exp Else exp
@@ -444,21 +430,18 @@ starstar_exp:
| starstar_exp StarStar app_exp
{ eloc (E_app_infix($1,SymX_l($2, locn 2 2), $3)) }
-
starstar_right_atomic_exp:
| right_atomic_exp
{ $1 }
| starstar_exp StarStar right_atomic_exp
{ eloc (E_app_infix($1,SymX_l($2, locn 2 2), $3)) }
-
star_exp:
| starstar_exp
{ $1 }
| star_exp Star starstar_exp
{ eloc (E_app_infix($1,SymX_l($2, locn 2 2), $3)) }
-
star_right_atomic_exp:
| starstar_right_atomic_exp
{ $1 }
@@ -471,7 +454,6 @@ plus_exp:
| plus_exp Plus star_exp
{ eloc (E_app_infix($1,SymX_l($2, locn 2 2), $3)) }
-
plus_right_atomic_exp:
| star_right_atomic_exp
{ $1 }
@@ -484,7 +466,6 @@ cons_exp:
| plus_exp ColonColon cons_exp
{ eloc (E_cons($1,fst $2,$3)) }
-
cons_right_atomic_exp:
| plus_right_atomic_exp
{ $1 }
@@ -497,7 +478,6 @@ at_exp:
| cons_exp At at_exp
{ eloc (E_app_infix($1,SymX_l($2, locn 2 2), $3)) }
-
at_right_atomic_exp:
| cons_right_atomic_exp
{ $1 }
@@ -507,6 +487,7 @@ at_right_atomic_exp:
eq_exp:
| at_exp
{ $1 }
+ /* Adds one shift/reduce conflict */
| eq_exp Eq at_exp
{ eloc (E_app_infix($1,SymX_l($2, locn 2 2), $3)) }
| eq_exp GtEq at_exp
@@ -516,7 +497,6 @@ eq_exp:
| eq_exp ColonEq at_exp
{ eloc (E_assign($1,$2,$3)) }
-
eq_right_atomic_exp:
| at_right_atomic_exp
{ $1 }
@@ -529,7 +509,6 @@ and_exp:
| eq_exp AmpAmp and_exp
{ eloc (E_app_infix($1,SymX_l($2, locn 2 2), $3)) }
-
and_right_atomic_exp:
| eq_right_atomic_exp
{ $1 }
@@ -550,11 +529,12 @@ or_right_atomic_exp:
{ eloc (E_app_infix($1,SymX_l($2, locn 2 2), $3)) }
exp:
- | app_exp
+ | or_exp
{ $1 }
- | right_atomic_exp
+ | or_right_atomic_exp
{ $1 }
+
comma_exps:
| exp Comma exp
{ [($1,$2);($3,None)] }
@@ -586,25 +566,26 @@ case_exps:
{ $1::$2 }
patsexp:
- | atomic_pats1 MinusGt exp
+ | atomic_pats MinusGt exp
{ Patsexp($1,$2,$3,loc ()) }
-atomic_pats1:
+atomic_pats:
| atomic_pat
{ [$1] }
- | atomic_pat atomic_pats1
+ | atomic_pat atomic_pats
{ $1::$2 }
letbind:
| Let_ atomic_pat Eq exp
{ }
- | typquant atomic_typ atomic_pat Eq exp
+ | Let_ typquant atomic_typ atomic_pat Eq exp
{ }
+ /* This is ambiguous causing 4 shift/reduce and 5 reduce/reduce conflicts because the parser can't tell until the end of typ whether it was parsing a type or a pattern, and this seem to be too late. Solutions are to have a different keyword for this and the above solution besides let (while still absolutely having a keyword here)
| Let_ atomic_typ atomic_pat Eq exp
- { }
+ { } */
funcl:
- | id atomic_pats1 Eq exp
+ | id atomic_pats Eq exp
{ reclloc (FCL_Funcl($1,$2,fst $3,$4)) }
funcl_ands:
@@ -613,33 +594,33 @@ funcl_ands:
| funcl And funcl_ands
{ $1::$3 }
-
fun_def:
- | Function_ Rec typquant typ effect_typ funcl_ands
+ | Function_ Rec typquant atomic_typ effect_typ funcl_ands
{ $1,$2,$3,$4,$5 }
- | Function_ Rec typquant typ effect_typ funcl_ands
+ | Function_ Rec typquant atomic_typ funcl_ands
+ { $1,$2,$3,$4,$5 }
+ | Function_ Rec atomic_typ effect_typ funcl_ands
{ }
- | Function_ Rec typ funcl_ands
+ | Function_ Rec atomic_typ funcl_ands
{ $1,$2,$3,$4 }
+ /* The below causes 2 shift/reduce conflicts because it can't here tell the difference between the start of the function the potential start of a type */
| Function_ Rec funcl_ands
{ $1,$2,$3 }
- | Function_ typquant typ effect_typ funcl_ands
+ | Function_ typquant atomic_typ effect_typ funcl_ands
{ $1,$2,$3,$4 }
- | Function_ typquant typ funcl_ands
+ | Function_ typquant atomic_typ funcl_ands
{ $1,$2,$3 }
- | Function_ typ funcl_ands
+ | Function_ atomic_typ funcl_ands
{ $1,$2,$3 }
| Function_ funcl_ands
{ $1,$2 }
val_spec:
- | Val typschm id
+ | Val typquant atomic_typ id
+ { Val_spec($1,$2,$3) }
+ | Val atomic_typ id
{ Val_spec($1,$2,$3) }
-
-texp:
- | typ
- { Te_abbrev($1) }
kinded_id:
| id
@@ -683,12 +664,6 @@ typquant:
| Forall kinded_ids Dot
{ typql(TypQ_no_constraint($1,$2,$3)) }
-typschm:
- | typquant typ
- { TypS($1,$2) }
- | typ
- { TypS(None,$1) }
-
name_sect:
| Lsquare id Eq String Rsquare
{ Name_sect_some($1,$2,fst $3,(fst $4),(snd $4),$5) }
@@ -699,7 +674,7 @@ c_def_body:
| typ id Semi
{ [(($1,$2),Some)] }
| typ id Semi c_def_body
- { (($1,$2)$3)::$4 }
+ { (($1,$2)$3)::$4 }
index_range_atomic:
| Num
@@ -723,18 +698,22 @@ r_def_body:
| index_range Semi r_def_body
{ ($1,$2)::$3 }
-
type_def:
- | Typedef id name_sect Eq typschm
+ | Typedef id name_sect Eq typquant typ
{}
- | Typedef id Eq typschm
+ | Typedef id name_sect Eq typ
{ }
+ | Typedef id Eq typquant typ
+ { }
+ | Typedef id Eq typ
+ { }
+ /* The below adds 4 shift/reduce conflicts. Unclear why */
| Typedef id name_sect Eq Const Struct typquant Lcurly c_def_body Rcurly
{}
- | Typedef id Eq Const Struct typquant Lcurly c_def_body Rcurly
- {}
| Typedef id name_sect Eq Const Struct Lcurly c_def_body Rcurly
{}
+ | Typedef id Eq Const Struct typquant Lcurly c_def_body Rcurly
+ {}
| Typedef id Eq Const Struct Lcurly c_def_body Rcurly
{}
| Typedef id name_sect Eq Const Union typquant Lcurly c_def_body Rcurly
@@ -751,21 +730,24 @@ type_def:
default_typ:
| Default atomic_kind id
- { $1,$2,$3 }
- | Default typ id
{ $1,$2,$3 }
-
+ | Default atomic_typ id
+ { $1,$2,$3 }
scattered_def:
- | Function_ Rec typschm effect_typ id
+ | Function_ Rec typquant atomic_typ effect_typ id
{ (DEF_scattered_function(None,$1,(Rec_rec ($2)),$3,$4,$5)) }
- | Function_ Rec typschm id
+ | Function_ Rec atomic_typ effect_typ id
+ { (DEF_scattered_function(None,$1,(Rec_rec ($2)),$3,$4,$5)) }
+ | Function_ Rec atomic_typ id
{ (DEF_scattered_function(None,$1,(Rec_rec ($2)),$3,$4)) }
| Function_ Rec id
{ DEF_scattered_function(None,$1,$2,None,None,$3) }
- | Function_ typschm effect_typ id
+ | Function_ typquant atomic_typ effect_typ id
{ (DEF_scattered_function(None,$1,(Rec_rec ()),$2,$3,$4)) }
- | Function_ typschm id
+ | Function_ atomic_typ effect_typ id
+ { (DEF_scattered_function(None,$1,(Rec_rec ($2)),$3,)) }
+ | Function_ atomic_typ id
{ (DEF_scattered_function(None,$1,(Rec_rec ($2)),$3,)) }
| Function_ id
{ DEF_scattered_function(None,$1,$2,None,None,) }
@@ -789,7 +771,7 @@ def:
{ dloc (DEF_spec($1)) }
| default_typ
{ dloc (DEF_default($1)) }
- | Register typ id
+ | Register atomic_typ id
{ dloc (DEF_reg_dec($1,$2,$3)) }
| Scattered scattered_def
{ dloc (match ($2) with
@@ -797,7 +779,7 @@ def:
| DEF_scattered_variant(_,t,i,n,e,c,u,ty) -> DEF_scattered_variant($1,t,i,n,e,c,u,ty)) }
| Function_ Clause funcl
{ dloc (DEF_funcl($1,$2,$3)) }
- | Union id Member typ id
+ | Union id Member atomic_typ id
{ dloc (DEF_scattered_unioncl($1,$2,$3,$4,$5)) }
| End id
{ dloc (DEF_scattered_end($1,$2)) }