summaryrefslogtreecommitdiff
path: root/src/parser.mly
diff options
context:
space:
mode:
authorAlasdair2020-12-01 03:26:33 +0000
committerAlasdair2021-01-05 11:11:04 +0000
commit8b2a3fa0eae0f49b78c0c5f845d3824d21f98df3 (patch)
treef9e9fe3752446e3e0fdab6427e8e9fad087bdc7e /src/parser.mly
parentc4723c747fec4557776858641b03e1eb4a0a5878 (diff)
Enum value feature request for Alexandre
Diffstat (limited to 'src/parser.mly')
-rw-r--r--src/parser.mly26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/parser.mly b/src/parser.mly
index 538fe3e8..60861eb4 100644
--- a/src/parser.mly
+++ b/src/parser.mly
@@ -1231,9 +1231,11 @@ type_def:
| Struct id typaram Eq Lcurly struct_fields Rcurly
{ mk_td (TD_record ($2, $3, $6, false)) $startpos $endpos }
| Enum id Eq enum_bar
- { mk_td (TD_enum ($2, $4, false)) $startpos $endpos }
+ { mk_td (TD_enum ($2, [], $4, false)) $startpos $endpos }
| Enum id Eq Lcurly enum Rcurly
- { mk_td (TD_enum ($2, $5, false)) $startpos $endpos }
+ { mk_td (TD_enum ($2, [], $5, false)) $startpos $endpos }
+ | Enum id With enum_functions Eq Lcurly enum Rcurly
+ { mk_td (TD_enum ($2, $4, $7, false)) $startpos $endpos }
| Newtype id Eq type_union
{ mk_td (TD_variant ($2, TypQ_aux (TypQ_tq [], loc $endpos($2) $startpos($3)), [$4], false)) $startpos $endpos }
| Newtype id typaram Eq type_union
@@ -1245,17 +1247,27 @@ type_def:
| Bitfield id Colon typ Eq Lcurly r_def_body Rcurly
{ mk_td (TD_bitfield ($2, $4, $7)) $startpos $endpos }
+enum_functions:
+ | id MinusGt typ Comma enum_functions
+ { ($1, $3) :: $5 }
+ | id MinusGt typ
+ { [($1, $3)] }
+
enum_bar:
| id
- { [$1] }
+ { [($1, None)] }
| id Bar enum_bar
- { $1 :: $3 }
+ { ($1, None) :: $3 }
enum:
| id
- { [$1] }
+ { [($1, None)] }
+ | id EqGt exp
+ { [($1, Some $3)] }
| id Comma enum
- { $1 :: $3 }
+ { ($1, None) :: $3 }
+ | id EqGt exp Comma enum
+ { ($1, Some $3) :: $5 }
struct_field:
| id Colon typ
@@ -1500,7 +1512,7 @@ def:
| Overload id Eq Lcurly id_list Rcurly
{ DEF_overload ($2, $5) }
| Overload id Eq enum_bar
- { DEF_overload ($2, $4) }
+ { DEF_overload ($2, List.map fst $4) }
| scattered_def
{ DEF_scattered $1 }
| default_def