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):
input_part(child, parent=state_def, context=context)
errors.extend(err)
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:
for statename in state_def.statelist:
# check that input is not already defined
......
......@@ -27,6 +27,33 @@ exit_aggreg;
PROCESS og;
STATE AGGREGATION wait;
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;
SUBSTRUCTURE
in (hehe);
......@@ -41,7 +68,7 @@ exit_aggreg;
ENDPROCEDURE;
/* CIF START (306, 314), (72, 35) */
START hehe ;
/* CIF NEXTSTATE (308, 364), (70, 35) */
/* CIF NEXTSTATE (307, 364), (70, 35) */
NEXTSTATE a1;
/* CIF START (0, 57), (70, 35) */
START;
......@@ -74,39 +101,12 @@ exit_aggreg;
NEXTSTATE a2;
ENDSTATE;
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) */
STATE a;
ENDSTATE;
/* CIF STATE (170, 160), (70, 35) */
STATE b;
ENDSTATE;
ENDSUBSTRUCTURE;
/* CIF TEXT (997, 328), (289, 140) */
-- Text area for declarations and comments
......@@ -117,15 +117,6 @@ dcl x myInteger;
START;
/* CIF NEXTSTATE (0, 299), (70, 35) */
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) */
STATE the_end;
/* CIF INPUT (640, 358), (107, 35) */
......@@ -135,17 +126,14 @@ dcl x myInteger;
/* CIF NEXTSTATE (658, 458), (70, 35) */
NEXTSTATE wait;
ENDSTATE;
/* CIF STATE (0, 299), (70, 35) */
/* CIF STATE (390, 307), (67, 35) */
STATE wait;
/* CIF INPUT (-19, 354), (107, 35) */
INPUT reset_all(x)
/* CIF COMMENT (108, 338), (227, 50) */
COMMENT 'Transition is handled by
a state in the state aggregation';
/* CIF PROCEDURECALL (-115, 404), (300, 35) */
CALL writeln('[ERROR] Should never be called');
/* CIF NEXTSTATE (0, 454), (70, 35) */
NEXTSTATE -;
/* 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;
ENDPROCESS og;
ENDBLOCK;
......
......@@ -6,27 +6,16 @@ edit:
$(OPENGEODE) challenge.pr system_structure.pr
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
$(GNATBIND) -n challenge.ali
$(GNATLINK) -o test_ada test_ada.o challenge.ali -lgnat -lm
./test_ada | diff expected -
test-ada: test-parse
test-c: challenge.c test_c.o dataview-uniq.o
$(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-c: test-parse
test-llvm: challenge.o dataview-uniq.o | test_llvm.o
$(CC) challenge.o dataview-uniq.o test_llvm.o -o test_llvm -lm
./test_llvm | diff expected -
test-llvm: test-parse
test-vhdl : test-c
bambu challenge.c test_c.c --experimental-setup=BAMBU
test-vhdl : test-parse
coverage:
coverage run -p $(OPENGEODE) challenge.pr system_structure.pr --toAda
.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