I added the patching of sets.

Syntax: patch s with set ... end
This commit is contained in:
Christian Rinderknecht 2019-03-21 23:12:46 +01:00
parent 98590b2e4a
commit c76ec00c9b
No known key found for this signature in database
GPG Key ID: 9446816CFD267040
3 changed files with 37 additions and 0 deletions

17
AST.ml
View File

@ -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";

View File

@ -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;

View File

@ -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