diff --git a/AST.ml b/AST.ml index 4551e27dd..f156992a9 100644 --- a/AST.ml +++ b/AST.ml @@ -446,6 +446,7 @@ and expr = and map_expr = MapLookUp of map_lookup reg +| MapInj of map_injection reg and map_lookup = { path : path; @@ -618,7 +619,8 @@ let rec expr_to_region = function | ParExpr {region; _} -> region and map_expr_to_region = function - MapLookUp {region; _} -> region + MapLookUp {region; _} +| MapInj {region; _} -> region and logic_expr_to_region = function BoolExpr e -> bool_expr_to_region e @@ -1091,6 +1093,8 @@ and print_map_expr = function print_token lbracket "["; print_expr inside; print_token rbracket "]" +| MapInj inj -> + print_map_injection inj and print_path = function Name var -> print_var var diff --git a/AST.mli b/AST.mli index 4b0f88eab..825d0f63e 100644 --- a/AST.mli +++ b/AST.mli @@ -430,6 +430,7 @@ and expr = and map_expr = MapLookUp of map_lookup reg +| MapInj of map_injection reg and map_lookup = { path : path; diff --git a/Parser.mly b/Parser.mly index 14b8dcc17..26b60bdda 100644 --- a/Parser.mly +++ b/Parser.mly @@ -358,8 +358,8 @@ local_decl: | const_decl { LocalConst $1 } | var_decl { LocalVar $1 } -unqualified_decl: - var COLON type_expr EQUAL extended_expr option(SEMI) { +unqualified_decl(OP): + var COLON type_expr OP extended_expr option(SEMI) { let stop = match $6 with Some region -> region | None -> $5.region in @@ -387,13 +387,13 @@ unqualified_decl: opt_type = $3}; rpar = Region.ghost} in ConstrExpr (NoneExpr {region; value}) -(* | `EMap inj -> - MapExpr ( ) *) + | `EMap inj -> + MapExpr (MapInj inj) in $1, $2, $3, $4, init, $6, stop } const_decl: - Const unqualified_decl { + Const unqualified_decl(EQUAL) { let name, colon, const_type, equal, init, terminator, stop = $2 in let region = cover $1 stop in @@ -409,7 +409,7 @@ const_decl: } var_decl: - Var unqualified_decl { + Var unqualified_decl(ASS) { let name, colon, var_type, assign, init, terminator, stop = $2 in let region = cover $1 stop in @@ -430,9 +430,8 @@ extended_expr: | LBRACKET RBRACKET { {region = cover $1 $2; value = `EList ($1,$2)} } | C_None { {region = $1; value = `ENone $1} } -(* | map_injection { {region = $1.region; value = `EMap $1} } - *) + instruction: single_instr { Single $1 }