Commit 8484a06f authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add test-aggregation1 and parse it

parent ac19d247
......@@ -2,7 +2,7 @@
 
# Resource object code
#
# Created: Mon Oct 12 21:34:01 2015
# Created: Tue Oct 13 21:25:22 2015
# by: The Resource Compiler for PySide (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!
......@@ -3585,7 +3585,8 @@ def nextstate(root, context):
try:
composite, = (comp for comp in context.composite_states
if comp.statename.lower() == next_state_id.lower())
if not composite.content.start:
if not isinstance(composite, ogAST.StateAggregation) \
and not composite.content.start:
errors.append('Composite state "{}" has no unnamed '
'START symbol'.format(composite.statename))
except ValueError:
......
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2015-10-12 21:34:03
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2015-10-13 21:25:24
import sys
from antlr3 import *
......
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2015-10-12 21:34:02
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2015-10-13 21:25:23
 
import sys
from antlr3 import *
include ../shared.mk
all: test-ada test-llvm
edit:
$(OPENGEODE) challenge.pr system_structure.pr
test-parse:
$(OPENGEODE) challenge.pr system_structure.pr --check
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
test-c: challenge.c test_c.o dataview-uniq.o
$(CC) -include missing.h challenge.c -c -o challenge.o
$(CC) test_c.o challenge.c dataview-uniq.o -lm -o test_c
./test_c
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
coverage:
coverage run -p $(OPENGEODE) challenge.pr system_structure.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage
#include <stdio.h>
#include "dataview-uniq.h"
#include "challenge.h"
typedef enum {off, safe, on___hello___wait_in_sub_hello} states_t;
typedef struct
{
states_t state;
asn1SccT_UInt32 on___result;
asn1SccT_UInt8 on___myresult;
asn1SccT_UInt32 result;
} context_t;
context_t context;
void CInit()
{
context.on___result = 9;
context.on___myresult = 4;
context.result = 0;
}
#define on___via_toto_START 4
#define on___hello___START 7
#define on___START 5
void runTransition(int Id);
void ___on___hello___entry();
void ___on___entry();
void ___on___inner_proc(asn1SccT_UInt8 toto);
void ___on___exit();
void run()
{
switch(context.state)
{
case off:
{
runTransition(3);
break;
}
case safe:
{
break;
}
case on___hello___wait_in_sub_hello:
{
runTransition(6);
break;
}
default:
{
break;
}
}
}
void go_off()
{
switch(context.state)
{
case off:
{
break;
}
case safe:
{
break;
}
case on___hello___wait_in_sub_hello:
{
break;
}
default:
{
break;
}
}
}
void any_one()
{
switch(context.state)
{
case off:
{
break;
}
case safe:
{
break;
}
case on___hello___wait_in_sub_hello:
{
break;
}
default:
{
break;
}
}
}
void any_two()
{
switch(context.state)
{
case off:
{
break;
}
case safe:
{
break;
}
case on___hello___wait_in_sub_hello:
{
break;
}
default:
{
break;
}
}
}
void ___on___hello___entry()
{
// writeln('8') (14,33)
printf("8");
printf("\n");
// writeln('Hello!') (16,33)
printf("Hello!");
printf("\n");
// RETURN (None,None) at 195, 286
return;
}
void ___on___entry()
{
// writeln('ENTERING NESTED STATE') (46,25)
printf("ENTERING NESTED STATE");
printf("\n");
// RETURN (None,None) at 208, 178
return;
}
void ___on___inner_proc(asn1SccT_UInt8 toto)
{
asn1SccT_Boolean result = true;
// JOIN hey_joe (None,None) at None, None
goto hey_joe;
// CONNECTION leaving (67,20)
leaving:
// RETURN (None,None) at 496, 347
return;
// CONNECTION hey_joe (61,20)
hey_joe:
// writeln('10') (63,25)
printf("10");
printf("\n");
// result := false (65,25)
result = false;
// JOIN leaving (None,None) at None, None
goto leaving;
}
void ___on___exit()
{
// writeln('LEAVING the nested state') (82,25)
printf("LEAVING the nested state");
printf("\n");
// RETURN (None,None) at 180, 219
return;
}
void runTransition(int Id)
{
int trId = Id;
asn1SccT_UInt32 tmp16;
asn1SccT_UInt32 tmp17;
while (trId != -1)
{
switch(trId)
{
case 0:
{
// writeln('1') (152,13)
printf("1");
printf("\n");
// NEXT_STATE OFF (154,18) at -1, 215
trId = -1;
context.state = off;
goto next_transition;
break;
}
case 1:
{
// NEXT_STATE Safe (160,22) at 234, 245
trId = -1;
context.state = safe;
goto next_transition;
break;
}
case 2:
{
// NEXT_STATE off (164,22) at 144, 245
trId = -1;
context.state = off;
goto next_transition;
break;
}
case 3:
{
// writeln('2') (171,17)
printf("2");
printf("\n");
// NEXT_STATE on (173,22) at -32, 371
// COMMENT Enter substate via entry point (175,12)
trId = on___START;
goto next_transition;
break;
}
case 4:
{
// entry (None,None)
___on___entry();
// writeln('3') (89,21)
printf("3");
printf("\n");
// exit (None,None)
___on___exit();
// RETURN ret0 (None,None) at 1215, 107
trId = 1;
goto next_transition;
break;
}
case 5:
{
// entry (None,None)
___on___entry();
// writeln('7') (95,21)
printf("7");
printf("\n");
// JOIN on___inside_label (None,None) at None, None
goto on___inside_label;
break;
}
case 6:
{
// writeln('27 == ', result) (136,25)
printf("27 == ");
if((int)(context.on___result) >= 0) printf(" ");
printf("%d", context.on___result);
printf("\n");
// myresult := 88 (138,25)
context.on___myresult = 88;
// result := 33 (139,0)
context.on___result = 33;
// JOIN on___to_label (141,25) at 24, 229
goto on___to_label;
break;
}
case 7:
{
// entry (None,None)
___on___hello___entry();
// NEXT_STATE on___hello___wait_in_sub_hello (23,34) at 312, 183
trId = -1;
context.state = on___hello___wait_in_sub_hello;
goto next_transition;
break;
}
default:
{
break;
}
}
goto next_transition;
// CONNECTION on___another_floating (114,23)
on___another_floating:
// writeln('9') (116,21)
printf("9");
printf("\n");
// myresult := 1 (118,21)
context.on___myresult = 1;
// inner_proc(myresult) (120,21)
___on___inner_proc(context.on___myresult);
// exit (None,None)
___on___exit();
// RETURN (None,None) at 565, 672
trId = 2;
goto next_transition;
// CONNECTION on___to_label (126,23)
on___to_label:
// JOIN on___another_floating (128,21) at 159, 374
goto on___another_floating;
// CONNECTION on___nslabel (110,16)
on___nslabel:
// NEXT_STATE on___hello (112,26) at 938, 416
trId = on___hello___START;
goto next_transition;
// CONNECTION on___inside_label (97,16)
on___inside_label:
// pow(3,3, result) (99,21)
tmp16 = 3;
tmp17 = 3;
pow(&tmp16, &tmp17, &context.on___result);
// DECISION result (-1,-1)
// ANSWER myresult (103,25)
if((context.on___result) == context.on___myresult)
{
;
}
// ANSWER ELSE (None,None)
else
{
// myresult := 5 (107,33)
context.on___myresult = 5;
}
// JOIN on___nslabel (None,None) at None, None
goto on___nslabel;
next_transition:
;
}
}
// Provided interface "run"
void run();
// Provided interface "go_off"
void go_off();
// Provided interface "any_one"
void any_one();
// Provided interface "any_two"
void any_two();
#define pow challenge_RI_pow
// Sync required interface "pow
void pow(asn1SccT_UInt32 * a,asn1SccT_UInt32 * b,asn1SccT_UInt32 * res);
\ No newline at end of file
/* CIF PROCESS (150, 150), (150, 75) */
PROCESS challenge;
STATE AGGREGATION Safe;
SUBSTRUCTURE
STATE A;
SUBSTRUCTURE
START;
NEXTSTATE HA;
STATE HA;
ENDSTATE;
ENDSUBSTRUCTURE;
STATE B;
SUBSTRUCTURE
START;
NEXTSTATE BEH;
STATE BEH;
ENDSTATE;
ENDSUBSTRUCTURE;
ENDSUBSTRUCTURE;
STATE on;
SUBSTRUCTURE
in (via_toto);
out (ret0);
STATE hello;
SUBSTRUCTURE
/* CIF PROCEDURE (892, 436), (73, 35) */
PROCEDURE entry;
/* CIF START (178, 136), (70, 35) */
START;
/* CIF PROCEDURECALL (160, 186), (106, 35) */
CALL writeln('8');
/* CIF PROCEDURECALL (145, 236), (136, 35) */
CALL writeln('Hello!');
/* CIF RETURN (195, 286), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF START (349, 133), (70, 35) */
START;
/* CIF NEXTSTATE (312, 183), (144, 35) */
NEXTSTATE wait_in_sub_hello;
/* CIF STATE (582, 147), (144, 35) */
STATE wait_in_sub_hello;
ENDSTATE;
ENDSUBSTRUCTURE;
/* CIF TEXT (242, 251), (334, 95) */
dcl myresult T_UInt8 := 4;
-- Use a variable with the same name as a variable
-- in the outer scope, to check that code generators
-- use the proper one
dcl result T_UInt32 := 9;
/* CIF ENDTEXT */
/* CIF PROCEDURE (554, 54), (73, 35) */
PROCEDURE entry
/* CIF COMMENT (643, 31), (190, 83) */
COMMENT 'Special Entry
procedure - called
automatically upon
entrance to the nested
state';
/* CIF START (191, 78), (70, 35) */
START;
/* CIF PROCEDURECALL (100, 128), (251, 35) */
CALL writeln('ENTERING NESTED STATE');
/* CIF RETURN (208, 178), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF PROCEDURE (239, 522), (102, 35) */
PROCEDURE inner_proc;
/* CIF TEXT (31, 41), (364, 93) */
fpar in toto T_UInt8;
-- Redefine a variable declared in outer scope
dcl result t_Boolean := true;
/* CIF ENDTEXT */
/* CIF START (479, 97), (70, 35) */
START;
/* CIF LABEL (471, 147), (86, 35) */
hey_joe:
/* CIF PROCEDURECALL (457, 197), (113, 35) */
CALL writeln('10');
/* CIF TASK (453, 247), (121, 35) */
TASK result := false;
/* CIF LABEL (473, 297), (82, 35) */
leaving:
/* CIF RETURN (496, 347), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF PROCEDURE (558, 143), (70, 33) */
PROCEDURE exit
/* CIF COMMENT (648, 118), (157, 93) */
COMMENT 'Special exit
procedure - called
automatically when
leaving the nested
state';
/* CIF START (163, 119), (70, 35) */
START;
/* CIF PROCEDURECALL (68, 169), (259, 35) */
CALL writeln('LEAVING the nested state');
/* CIF RETURN (180, 219), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF START (1188, 7), (89, 35) */
START via_toto ;
/* CIF PROCEDURECALL (1179, 57), (106, 35) */
CALL writeln('3');
/* CIF RETURN (1215, 107), (35, 35) */
RETURN ret0;
/* CIF START (938, 8), (70, 35) */
START;
/* CIF PROCEDURECALL (920, 58), (106, 35) */
CALL writeln('7');
/* CIF LABEL (917, 108), (111, 35) */
inside_label:
/* CIF PROCEDURECALL (904, 158), (137, 35) */
CALL pow(3,3, result);
/* CIF DECISION (936, 208), (74, 50) */
DECISION result;
/* CIF ANSWER (861, 278), (92, 23) */
(myresult):
/* CIF ANSWER (985, 278), (70, 23) */
ELSE:
/* CIF TASK (962, 316), (115, 35) */
TASK myresult := 5;
ENDDECISION;
/* CIF LABEL (929, 366), (88, 35) */
nslabel:
/* CIF NEXTSTATE (938, 416), (70, 35) */
NEXTSTATE hello;
/* CIF LABEL (512, 472), (141, 35) */
CONNECTION another_floating:
/* CIF PROCEDURECALL (526, 522), (113, 35) */
CALL writeln('9');
/* CIF TASK (525, 572), (115, 35) */
TASK myresult := 1;
/* CIF PROCEDURECALL (500, 622), (164, 35) */
CALL inner_proc(myresult);
/* CIF RETURN (565, 672), (35, 35) */
RETURN ;
/* CIF End Label */
ENDCONNECTION;
/* CIF LABEL (132, 324), (90, 35) */
CONNECTION to_label:
/* CIF JOIN (159, 374), (35, 35) */
JOIN another_floating;
/* CIF End Label */
ENDCONNECTION;
/* CIF STATE (0, 0), (70, 35) */
STATE hello;
/* CIF INPUT (6, 55), (70, 35) */
INPUT run;
/* CIF PROCEDURECALL (-46, 111), (175, 35) */
CALL writeln('27 == ', result);
/* CIF TASK (-21, 161), (125, 53) */
TASK myresult := 88,
result := 33;
/* CIF JOIN (24, 229), (35, 35) */
JOIN to_label;
ENDSTATE;
ENDSUBSTRUCTURE;
/* CIF TEXT (51, 0), (298, 56) */
-- This system tests nested states
dcl result T_uint32 :=0;
/* CIF ENDTEXT */
/* CIF START (0, 113), (68, 37) */
START;
/* CIF PROCEDURECALL (-19, 165), (106, 35) */
CALL writeln('1');
/* CIF NEXTSTATE (-1, 215), (70, 35) */
NEXTSTATE OFF;
/* CIF STATE (234, 140), (65, 35) */
STATE on;
/* CIF CONNECT (267, 195), (0, 35) */
CONNECT ret0;
/* CIF NEXTSTATE (234, 245), (67, 35) */
NEXTSTATE Safe;
/* CIF CONNECT (179, 195), (0, 35) */
CONNECT ;
/* CIF NEXTSTATE (144, 245), (70, 35) */
NEXTSTATE off;
ENDSTATE;
/* CIF STATE (-1, 215), (70, 35) */
STATE OFF;
/* CIF INPUT (-1, 270), (70, 35) */
INPUT run;
/* CIF PROCEDURECALL (-19, 320), (106, 35) */
CALL writeln('2');
/* CIF NEXTSTATE (-32, 371), (132, 35) */
NEXTSTATE on
/* CIF COMMENT (119, 371), (219, 35) */
COMMENT 'Enter substate via entry point';
ENDSTATE;
state safe;
endstate;
ENDPROCESS challenge;
TASTE-BasicTypes DEFINITIONS ::=
BEGIN
-- Set of TASTE predefined basic types
T-Int32 ::= INTEGER (-2147483648 .. 2147483647)
T-UInt32 ::= INTEGER (0 .. 4294967295)
T-Int8 ::= INTEGER (-128 .. 127)
T-UInt8 ::= INTEGER (0 .. 255)
T-Boolean ::= BOOLEAN
BitString ::= BIT STRING (SIZE(32))
OctString ::= OCTET STRING (SIZE(4))
SeqBit ::= SEQUENCE (SIZE(32)) OF BOOLEAN
SeqBit2 ::= SEQUENCE (SIZE(1..32)) OF BOOLEAN
END