Commit 31745dd6 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Detect inputs consumed both at N and N-i levels

parent 87e58fdb
...@@ -2895,6 +2895,28 @@ def state(root, parent, context): ...@@ -2895,6 +2895,28 @@ def state(root, parent, context):
input_part(child, parent=state_def, context=context) input_part(child, parent=state_def, context=context)
errors.extend(err) errors.extend(err)
warnings.extend(warn) warnings.extend(warn)
def gather_inputlist(state_ast):
''' List all the inputs consumed by a given composite state
in any substate - used to check that an input consumed at level
N is not already consumed at N-1, causing conflicts '''
res = []
for lists in (inps for inps in state_ast.mapping.viewvalues()
if not isinstance(inps, int)):
res.extend(li for i in lists for li in i.inputlist)
subinputs = map(gather_inputlist, state_ast.composite_states)
map(res.extend, subinputs)
return res
for comp in context.composite_states:
# if the current state is a composite state, check that none of
# the inputs from the list is already consumed in a substate
if any(st.lower() == comp.statename.lower()
for st in state_def.statelist):
subinputs = [res.lower() for res in gather_inputlist(comp)]
for each in inp.inputlist:
if each.lower() in subinputs:
sterr.append('Input "{}" is already consumed '
'in substate "{}"'
.format(each, comp.statename.lower()))
try: try:
for statename in state_def.statelist: for statename in state_def.statelist:
# check that input is not already defined # check that input is not already defined
......
...@@ -27,6 +27,33 @@ exit_aggreg; ...@@ -27,6 +27,33 @@ exit_aggreg;
PROCESS og; PROCESS og;
STATE AGGREGATION wait; STATE AGGREGATION wait;
SUBSTRUCTURE SUBSTRUCTURE
STATE b;
SUBSTRUCTURE
/* CIF START (146, 55), (70, 35) */
START;
/* CIF PROCEDURECALL (77, 105), (208, 35) */
CALL writeln('[b] startup');
/* CIF NEXTSTATE (146, 155), (70, 35) */
NEXTSTATE b1;
/* CIF STATE (392, 144), (70, 35) */
STATE b2;
/* CIF INPUT (388, 199), (79, 35) */
INPUT for_b;
/* CIF PROCEDURECALL (308, 249), (239, 35) */
CALL writeln('[b] Going to b1');
/* CIF NEXTSTATE (392, 299), (70, 35) */
NEXTSTATE b1;
ENDSTATE;
/* CIF STATE (146, 155), (70, 35) */
STATE b1;
/* CIF INPUT (138, 210), (80, 35) */
INPUT for_b;
/* CIF PROCEDURECALL (58, 260), (239, 35) */
CALL writeln('[b] Going to b2');
/* CIF NEXTSTATE (143, 310), (70, 35) */
NEXTSTATE b2;
ENDSTATE;
ENDSUBSTRUCTURE;
STATE a; STATE a;
SUBSTRUCTURE SUBSTRUCTURE
in (hehe); in (hehe);
...@@ -41,7 +68,7 @@ exit_aggreg; ...@@ -41,7 +68,7 @@ exit_aggreg;
ENDPROCEDURE; ENDPROCEDURE;
/* CIF START (306, 314), (72, 35) */ /* CIF START (306, 314), (72, 35) */
START hehe ; START hehe ;
/* CIF NEXTSTATE (308, 364), (70, 35) */ /* CIF NEXTSTATE (307, 364), (70, 35) */
NEXTSTATE a1; NEXTSTATE a1;
/* CIF START (0, 57), (70, 35) */ /* CIF START (0, 57), (70, 35) */
START; START;
...@@ -74,39 +101,12 @@ exit_aggreg; ...@@ -74,39 +101,12 @@ exit_aggreg;
NEXTSTATE a2; NEXTSTATE a2;
ENDSTATE; ENDSTATE;
ENDSUBSTRUCTURE; ENDSUBSTRUCTURE;
STATE b;
SUBSTRUCTURE
/* CIF START (146, 55), (70, 35) */
START;
/* CIF PROCEDURECALL (77, 105), (208, 35) */
CALL writeln('[b] startup');
/* CIF NEXTSTATE (146, 155), (70, 35) */
NEXTSTATE b1;
/* CIF STATE (392, 144), (70, 35) */
STATE b2;
/* CIF INPUT (388, 199), (79, 35) */
INPUT for_b;
/* CIF PROCEDURECALL (308, 249), (239, 35) */
CALL writeln('[b] Going to b1');
/* CIF NEXTSTATE (392, 299), (70, 35) */
NEXTSTATE b1;
ENDSTATE;
/* CIF STATE (146, 155), (70, 35) */
STATE b1;
/* CIF INPUT (138, 210), (80, 35) */
INPUT for_b;
/* CIF PROCEDURECALL (58, 260), (239, 35) */
CALL writeln('[b] Going to b2');
/* CIF NEXTSTATE (143, 310), (70, 35) */
NEXTSTATE b2;
ENDSTATE;
ENDSUBSTRUCTURE;
/* CIF STATE (170, 160), (70, 35) */
STATE b;
ENDSTATE;
/* CIF STATE (170, 50), (70, 35) */ /* CIF STATE (170, 50), (70, 35) */
STATE a; STATE a;
ENDSTATE; ENDSTATE;
/* CIF STATE (170, 160), (70, 35) */
STATE b;
ENDSTATE;
ENDSUBSTRUCTURE; ENDSUBSTRUCTURE;
/* CIF TEXT (997, 328), (289, 140) */ /* CIF TEXT (997, 328), (289, 140) */
-- Text area for declarations and comments -- Text area for declarations and comments
...@@ -117,15 +117,6 @@ dcl x myInteger; ...@@ -117,15 +117,6 @@ dcl x myInteger;
START; START;
/* CIF NEXTSTATE (0, 299), (70, 35) */ /* CIF NEXTSTATE (0, 299), (70, 35) */
NEXTSTATE wait; NEXTSTATE wait;
/* CIF STATE (390, 307), (67, 35) */
STATE wait;
/* CIF INPUT (368, 362), (110, 35) */
INPUT exit_aggreg;
/* CIF PROCEDURECALL (325, 412), (195, 34) */
CALL writeln('got exit_aggreg');
/* CIF NEXTSTATE (379, 461), (87, 35) */
NEXTSTATE the_end;
ENDSTATE;
/* CIF STATE (649, 303), (87, 35) */ /* CIF STATE (649, 303), (87, 35) */
STATE the_end; STATE the_end;
/* CIF INPUT (640, 358), (107, 35) */ /* CIF INPUT (640, 358), (107, 35) */
...@@ -135,17 +126,14 @@ dcl x myInteger; ...@@ -135,17 +126,14 @@ dcl x myInteger;
/* CIF NEXTSTATE (658, 458), (70, 35) */ /* CIF NEXTSTATE (658, 458), (70, 35) */
NEXTSTATE wait; NEXTSTATE wait;
ENDSTATE; ENDSTATE;
/* CIF STATE (0, 299), (70, 35) */ /* CIF STATE (390, 307), (67, 35) */
STATE wait; STATE wait;
/* CIF INPUT (-19, 354), (107, 35) */ /* CIF INPUT (368, 362), (110, 35) */
INPUT reset_all(x) INPUT exit_aggreg;
/* CIF COMMENT (108, 338), (227, 50) */ /* CIF PROCEDURECALL (325, 412), (195, 34) */
COMMENT 'Transition is handled by CALL writeln('got exit_aggreg');
a state in the state aggregation'; /* CIF NEXTSTATE (379, 461), (87, 35) */
/* CIF PROCEDURECALL (-115, 404), (300, 35) */ NEXTSTATE the_end;
CALL writeln('[ERROR] Should never be called');
/* CIF NEXTSTATE (0, 454), (70, 35) */
NEXTSTATE -;
ENDSTATE; ENDSTATE;
ENDPROCESS og; ENDPROCESS og;
ENDBLOCK; ENDBLOCK;
......
...@@ -6,27 +6,16 @@ edit: ...@@ -6,27 +6,16 @@ edit:
$(OPENGEODE) challenge.pr system_structure.pr $(OPENGEODE) challenge.pr system_structure.pr
test-parse: test-parse:
$(OPENGEODE) challenge.pr system_structure.pr --check $(OPENGEODE) challenge.pr system_structure.pr --check 2>&1 | grep ERROR | wc | grep "1 9 61" && echo OK
test-ada: challenge.ali dataview-uniq.o | test_ada.o test-ada: test-parse
$(GNATBIND) -n challenge.ali
$(GNATLINK) -o test_ada test_ada.o challenge.ali -lgnat -lm
./test_ada | diff expected -
test-c: challenge.c test_c.o dataview-uniq.o test-c: test-parse
$(CC) challenge.c -c -o challenge.o
$(CC) test_c.o dataview-uniq.o challenge.o -lm -o test_c
./test_c
./test_c | diff expected -
test-llvm: challenge.o dataview-uniq.o | test_llvm.o test-llvm: test-parse
$(CC) challenge.o dataview-uniq.o test_llvm.o -o test_llvm -lm
./test_llvm | diff expected -
test-vhdl : test-c test-vhdl : test-parse
bambu challenge.c test_c.c --experimental-setup=BAMBU
coverage: coverage:
coverage run -p $(OPENGEODE) challenge.pr system_structure.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage .PHONY: all edit test-parse test-ada test-llvm coverage
Markdown is supported
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