Skip to content

Commit fbe13db

Browse files
committed
Add remaining constructs to AST diff
1 parent 59b7035 commit fbe13db

File tree

1 file changed

+55
-4
lines changed

1 file changed

+55
-4
lines changed

src/lib/parse_ast_diff.ml

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,13 +797,54 @@ let diff_scattered_def (SD_aux (lhs, l)) (SD_aux (rhs, _)) =
797797
| SD_funcl funcl1 -> (
798798
match rhs with SD_funcl funcl2 -> diff_funcl funcl1 funcl2 | _ -> Some l
799799
)
800-
| _ -> None
800+
| SD_enum id1 -> (
801+
match rhs with SD_enum id2 -> diff_id id1 id2 | _ -> Some l
802+
)
803+
| SD_enumcl (id1, m1) -> (
804+
match rhs with SD_enumcl (id2, m2) -> diff_id id1 id2 &&& lazy (diff_id m1 m2) | _ -> Some l
805+
)
806+
| SD_variant (id1, typq1) -> (
807+
match rhs with SD_variant (id2, typq2) -> diff_id id1 id2 &&& lazy (diff_typquant typq1 typq2) | _ -> Some l
808+
)
809+
| SD_unioncl (id1, tu1) -> (
810+
match rhs with SD_unioncl (id2, tu2) -> diff_id id1 id2 &&& lazy (diff_type_union tu1 tu2) | _ -> Some l
811+
)
812+
| SD_mapping (id1, tannot_opt1) -> (
813+
match rhs with
814+
| SD_mapping (id2, tannot_opt2) -> diff_id id1 id2 &&& lazy (diff_tannot_opt tannot_opt1 tannot_opt2)
815+
| _ -> Some l
816+
)
817+
| SD_mapcl (id1, mcl1) -> (
818+
match rhs with SD_mapcl (id2, mcl2) -> diff_id id1 id2 &&& lazy (diff_mapcl mcl1 mcl2) | _ -> Some l
819+
)
820+
| SD_end id1 -> (
821+
match rhs with SD_end id2 -> diff_id id1 id2 | _ -> Some l
822+
)
823+
824+
let diff_subst (IS_aux (lhs, l)) (IS_aux (rhs, _)) =
825+
match lhs with
826+
| IS_id (l_id1, r_id1) -> (
827+
match rhs with IS_id (l_id2, r_id2) -> diff_id l_id1 l_id2 &&& lazy (diff_id r_id1 r_id2) | _ -> Some l
828+
)
829+
| IS_typ (v1, atyp1) -> (
830+
match rhs with IS_typ (v2, atyp2) -> diff_kid v1 v2 &&& lazy (diff_atyp atyp1 atyp2) | _ -> Some l
831+
)
801832

802833
let diff_dec_spec (DEC_aux (lhs, l)) (DEC_aux (rhs, _)) =
803834
let (DEC_reg (atyp1, id1, opt_exp1)) = lhs in
804835
let (DEC_reg (atyp2, id2, opt_exp2)) = rhs in
805836
diff_id id1 id2 &&& lazy (diff_atyp atyp1 atyp2) &&& lazy (diff_option ~at:l diff_exp opt_exp1 opt_exp2)
806837

838+
let diff_outcome (OV_aux (lhs, l)) (OV_aux (rhs, _)) =
839+
let (OV_outcome (id1, typschm1, typq1)) = lhs in
840+
let (OV_outcome (id2, typschm2, typq2)) = rhs in
841+
diff_id id1 id2 &&& lazy (diff_typschm typschm1 typschm2) &&& lazy (diff_typquant typq1 typq2)
842+
843+
let diff_default_typing_spec (DT_aux (lhs, l)) (DT_aux (rhs, _)) =
844+
let (DT_order (k1, atyp1)) = lhs in
845+
let (DT_order (k2, atyp2)) = rhs in
846+
diff_kind k1 k2 &&& lazy (diff_atyp atyp1 atyp2)
847+
807848
let rec diff_def (DEF_aux (lhs, l)) (DEF_aux (rhs, _)) =
808849
match lhs with
809850
| DEF_type td1 -> (
@@ -838,9 +879,19 @@ let rec diff_def (DEF_aux (lhs, l)) (DEF_aux (rhs, _)) =
838879
| DEF_val vs1 -> (
839880
match rhs with DEF_val vs2 -> diff_val_spec vs1 vs2 | _ -> Some l
840881
)
841-
| DEF_outcome _ -> None
842-
| DEF_instantiation _ -> None
843-
| DEF_default _ -> None
882+
| DEF_outcome (o1, defs1) -> (
883+
match rhs with
884+
| DEF_outcome (o2, defs2) -> diff_outcome o1 o2 &&& lazy (diff_list ~at:l diff_def defs1 defs2)
885+
| _ -> Some l
886+
)
887+
| DEF_instantiation (id1, substs1) -> (
888+
match rhs with
889+
| DEF_instantiation (id2, substs2) -> diff_id id1 id2 &&& lazy (diff_list ~at:l diff_subst substs1 substs2)
890+
| _ -> Some l
891+
)
892+
| DEF_default dtspec1 -> (
893+
match rhs with DEF_default dtspec2 -> diff_default_typing_spec dtspec1 dtspec2 | _ -> Some l
894+
)
844895
| DEF_scattered sdef1 -> (
845896
match rhs with DEF_scattered sdef2 -> diff_scattered_def sdef1 sdef2 | _ -> Some l
846897
)

0 commit comments

Comments
 (0)