Skip to content

Commit 1ab81f8

Browse files
author
Jérôme FERET
committed
do not warn about arity issues on refinement of rules
1 parent 3838505 commit 1ab81f8

File tree

3 files changed

+36
-27
lines changed

3 files changed

+36
-27
lines changed

core/grammar/eval.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,15 @@ let rules_of_ast ~debug_mode ~warning ?deps_machinery ~compile_mode_on
122122
Some d'
123123
in
124124
let unrate = compile_pure_alg ~debug_mode ~compile_mode_on rate in
125-
fun ccs ->
125+
fun (ccs, bool) ->
126126
(match Array.length ccs with
127127
| 0 | 1 ->
128128
let () =
129-
warning ~pos (fun f ->
130-
Format.pp_print_text f
131-
"Useless molecular ambiguity, the rules is always considered \
132-
as unary.")
129+
if not bool then
130+
warning ~pos (fun f ->
131+
Format.pp_print_text f
132+
"Useless molecular ambiguity, the rules is always \
133+
considered as unary.")
133134
in
134135
unrate, None
135136
| 2 -> crp, Some (unrate, dist')
@@ -140,9 +141,9 @@ let rules_of_ast ~debug_mode ~warning ?deps_machinery ~compile_mode_on
140141
^ " connected components.",
141142
pos )))
142143
in
143-
let build deps (origin, ccs, syntax, (neg, pos)) =
144+
let build deps ((origin, ccs, syntax, (neg, pos)), bool) =
144145
let ccs' = Array.map fst ccs in
145-
let rate, unrate = unary_infos ccs' in
146+
let rate, unrate = unary_infos (ccs', bool) in
146147
( Option_util.map
147148
(fun x ->
148149
let origin =
@@ -643,7 +644,6 @@ let compile ~outputs ~pause ~return ~sharing ~debug_mode ~compile_mode_on
643644
preenv' result.Ast.rules
644645
in
645646
let rule_nd = Array.of_list compiled_rules in
646-
647647
pause @@ fun () ->
648648
outputs (Data.Log "\t -interventions");
649649
let preenv, alg_deps'', pert, has_tracking =

core/term/pattern_compiler.ml

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ let complete_with_candidate outs prevs ag ag_tail id todo p_id dst_info p_switch
122122
LKappa.ra_syntax = ag.LKappa.ra_syntax;
123123
}
124124
:: ag_tail),
125-
todo )
125+
todo,
126+
false )
126127
:: acc
127128
) else if s = LKappa.Erased && p_switch = LKappa.Freed then (
128129
let ports' = Array.copy ag.LKappa.ra_ports in
@@ -139,7 +140,8 @@ let complete_with_candidate outs prevs ag ag_tail id todo p_id dst_info p_switch
139140
LKappa.ra_syntax = ag.LKappa.ra_syntax;
140141
}
141142
:: ag_tail),
142-
todo )
143+
todo,
144+
false )
143145
:: acc
144146
) else
145147
acc
@@ -165,7 +167,8 @@ let complete_with_candidate outs prevs ag ag_tail id todo p_id dst_info p_switch
165167
LKappa.ra_syntax = ag.LKappa.ra_syntax;
166168
}
167169
:: ag_tail),
168-
todo' )
170+
todo',
171+
false )
169172
:: acc
170173
| [], _ -> acc
171174
| _ :: _ :: _, _ -> assert false
@@ -194,15 +197,17 @@ let new_agent_with_one_link sigs ty_id port link dst_info switch =
194197
}
195198

196199
let rec add_one_implicit_info sigs id (((port, ty_id), dst_info, s) as info) acc
197-
out todo = function
200+
fresh_only_acc out todo = function
198201
| [] ->
199202
( List.rev_append acc
200203
[ new_agent_with_one_link sigs ty_id port id dst_info s ],
201-
todo )
204+
todo,
205+
fresh_only_acc )
202206
:: out
203207
| ag :: ag_tail ->
204208
let out_tail =
205-
add_one_implicit_info sigs id info (ag :: acc) out todo ag_tail
209+
add_one_implicit_info sigs id info (ag :: acc) fresh_only_acc out todo
210+
ag_tail
206211
in
207212
if ty_id = ag.LKappa.ra_type then
208213
complete_with_candidate out_tail acc ag ag_tail id todo port dst_info s
@@ -212,11 +217,13 @@ let rec add_one_implicit_info sigs id (((port, ty_id), dst_info, s) as info) acc
212217
let add_implicit_infos sigs l =
213218
let rec aux acc = function
214219
| [] -> acc
215-
| (m, []) :: t -> aux (m :: acc) t
216-
| (m, (id, info, dst_info, s) :: todo') :: t ->
217-
aux acc (add_one_implicit_info sigs id (info, dst_info, s) [] t todo' m)
220+
| (m, [], only_fresh) :: t -> aux ((m, only_fresh) :: acc) t
221+
| (m, (id, info, dst_info, s) :: todo', only_fresh) :: t ->
222+
aux acc
223+
(add_one_implicit_info sigs id (info, dst_info, s) [] only_fresh t todo'
224+
m)
218225
in
219-
aux [] l
226+
aux [] (List.rev_map (fun (a, b) -> a, b, true) (List.rev l))
220227

221228
let is_linked_on_port me i id = function
222229
| (LKappa.LNK_VALUE (j, _), _), _ when i = j -> id <> me
@@ -609,7 +616,8 @@ let incr_origin = function
609616
| (Operator.ALG _ | Operator.MODIF _) as x -> x
610617
| Operator.RULE i -> Operator.RULE (succ i)
611618

612-
let connected_components_of_mixture ~debug_mode created mix (env, origin) =
619+
let connected_components_of_mixture ~debug_mode created (mix, bool) (env, origin)
620+
=
613621
let sigs = Pattern.PreEnv.sigs env in
614622
let rec aux env transformations instantiations links_transf acc id = function
615623
| [] ->
@@ -635,10 +643,11 @@ let connected_components_of_mixture ~debug_mode created mix (env, origin) =
635643
complete_with_creation sigs transformations' links_transf [] actions' 0
636644
created
637645
in
638-
( ( origin,
639-
Tools.array_rev_of_list acc,
640-
{ instantiations with Instantiation.actions = actions'' },
641-
transformations'' ),
646+
( ( ( origin,
647+
Tools.array_rev_of_list acc,
648+
{ instantiations with Instantiation.actions = actions'' },
649+
transformations'' ),
650+
bool ),
642651
(env, Option_util.map incr_origin origin) )
643652
| h :: t ->
644653
let wk = Pattern.begin_new env in
@@ -705,7 +714,7 @@ let connected_components_sum_of_ambiguous_rule ~debug_mode ~compile_mode_on
705714
let () =
706715
if compile_mode_on then
707716
Format.eprintf "@[<v>_____(%i)@,%a@]@." (List.length all_mixs)
708-
(Pp.list Pp.cut (fun f x ->
717+
(Pp.list Pp.cut (fun f (x, _) ->
709718
Format.fprintf f "@[%a%a@]"
710719
(LKappa.print_rule_mixture ~noCounters sigs counters_info
711720
~ltypes:true created)
@@ -728,7 +737,7 @@ let connected_components_sum_of_ambiguous_mixture ~debug_mode ~compile_mode_on
728737
( cc_env,
729738
List.rev_map
730739
(function
731-
| _, l, event, ([], []) -> l, event.Instantiation.tests
740+
| (_, l, event, ([], [])), _b -> l, event.Instantiation.tests
732741
| _ -> assert false)
733742
rules )
734743

core/term/pattern_compiler.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ val connected_components_sum_of_ambiguous_rule :
2828
?origin:Operator.rev_dep ->
2929
LKappa.rule_mixture ->
3030
Raw_mixture.t ->
31-
(Operator.rev_dep option
31+
((Operator.rev_dep option
3232
* (Pattern.id * Pattern.cc) array
3333
* Instantiation.abstract Instantiation.event
3434
* (Instantiation.abstract Primitives.Transformation.t list
35-
* Instantiation.abstract Primitives.Transformation.t list))
35+
* Instantiation.abstract Primitives.Transformation.t list)) * bool)
3636
list
3737
* (Pattern.PreEnv.t * Operator.rev_dep option)
3838

0 commit comments

Comments
 (0)