Commit 3c8dfce3 authored by Valentin Perrelle's avatar Valentin Perrelle Committed by Virgile Prevosto
Browse files

[Aorai] Add a check to prevent the use of metavariables with non-deterministic automata

parent 5669df8c
......@@ -1536,9 +1536,28 @@ let type_cond_auto auto =
{ original_auto with states = List.rev states; trans = List.rev trans }
(* Check Metavariable compatibility *)
let checkMetavariableCompatibility auto =
let is_extended_trans trans =
match trans.cross with
| Otherwise -> false
| Seq [ elt ] ->
elt.nested <> [] || not (is_single elt)
| Seq _ -> true
in
let has_metavariables = not (Datatype.String.Map.is_empty auto.metavariables)
and deterministic = Aorai_option.Deterministic.get ()
and uses_extended_guards = List.exists is_extended_trans auto.trans in
if has_metavariables && (not deterministic || uses_extended_guards) then
Aorai_option.abort
"The use of metavariables is incompatible with non-deterministic \
automata, such as automa using extended transitions."
(** Stores the buchi automaton and its variables and
functions as it is returned by the parsing *)
let setAutomata auto =
checkMetavariableCompatibility auto;
let auto = type_cond_auto auto in
automata:=Some auto;
check_states "typed automata";
......
/* run.config*
OPT: -aorai-automata @PTEST_DIR@/@PTEST_NAME@.ya -aorai-test 1 -load-module tests/aorai/Aorai_test.cmxs -aorai-test-number @PTEST_NUMBER@ @PROVE_OPTIONS@
*/
void main(void) {}
%init: a;
%accept: b;
%deterministic;
$x : int;
a : { CALL(main)* } -> b;
b : -> b;
[kernel] Parsing tests/aorai/metavariables-incompatible.i (no preprocessing)
[aorai] Welcome to the Aorai plugin
[aorai] User Error: The use of metavariables is incompatible with non-deterministic automata, such as automa using extended transitions.
[kernel] Plug-in aorai aborted: invalid user input.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment