diff --git a/AST.ml b/AST.ml index 426c24366..f4f3dd925 100644 --- a/AST.ml +++ b/AST.ml @@ -333,6 +333,7 @@ and single_instr = | Skip of kwd_skip | RecordPatch of record_patch reg | MapPatch of map_patch reg +| SetPatch of set_patch reg | MapRemove of map_remove reg | SetRemove of set_remove reg @@ -352,6 +353,13 @@ and map_remove = { map : path } +and set_patch = { + kwd_patch : kwd_patch; + path : path; + kwd_with : kwd_with; + set_inj : set_injection reg +} + and map_patch = { kwd_patch : kwd_patch; path : path; @@ -721,6 +729,7 @@ let instr_to_region = function | Single Fail {region; _} | Single RecordPatch {region; _} | Single MapPatch {region; _} +| Single SetPatch {region; _} | Single MapRemove {region; _} | Single SetRemove {region; _} | Block {region; _} -> region @@ -1019,6 +1028,7 @@ and print_single_instr = function | Skip kwd_skip -> print_token kwd_skip "skip" | RecordPatch {value; _} -> print_record_patch value | MapPatch {value; _} -> print_map_patch value +| SetPatch {value; _} -> print_set_patch value | MapRemove {value; _} -> print_map_remove value | SetRemove {value; _} -> print_set_remove value @@ -1255,6 +1265,13 @@ and print_record_patch node = print_token kwd_with "with"; print_record_injection record_inj +and print_set_patch node = + let {kwd_patch; path; kwd_with; set_inj} = node in + print_token kwd_patch "patch"; + print_path path; + print_token kwd_with "with"; + print_set_injection set_inj + and print_map_patch node = let {kwd_patch; path; kwd_with; map_inj} = node in print_token kwd_patch "patch"; diff --git a/AST.mli b/AST.mli index d411b1ed7..b86951cbb 100644 --- a/AST.mli +++ b/AST.mli @@ -317,6 +317,7 @@ and single_instr = | Skip of kwd_skip | RecordPatch of record_patch reg | MapPatch of map_patch reg +| SetPatch of set_patch reg | MapRemove of map_remove reg | SetRemove of set_remove reg @@ -336,6 +337,13 @@ and map_remove = { map : path } +and set_patch = { + kwd_patch : kwd_patch; + path : path; + kwd_with : kwd_with; + set_inj : set_injection reg +} + and map_patch = { kwd_patch : kwd_patch; path : path; diff --git a/Parser.mly b/Parser.mly index 448eb9ad5..1c80c517c 100644 --- a/Parser.mly +++ b/Parser.mly @@ -474,6 +474,7 @@ single_instr: | Skip { Skip $1 } | record_patch { RecordPatch $1 } | map_patch { MapPatch $1 } +| set_patch { SetPatch $1 } | map_remove { MapRemove $1 } | set_remove { SetRemove $1 } @@ -501,6 +502,17 @@ map_remove: in {region; value} } +set_patch: + Patch path With set_injection { + let region = cover $1 $4.region in + let value = { + kwd_patch = $1; + path = $2; + kwd_with = $3; + set_inj = $4} + in {region; value} + } + map_patch: Patch path With map_injection { let region = cover $1 $4.region in