Commit 48af9940 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Merge branch 'master' of https://github.com/maxime-esa/opengeode

Conflicts:
	AdaGenerator.py
parents 4c83e542 8d8927b6
......@@ -2,7 +2,7 @@
 
# Resource object code
#
# Created: Thu Jul 17 20:45:57 2014
# Created: Tue Jul 22 16:47:55 2014
# by: The Resource Compiler for PySide (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!
This diff is collapsed.
......@@ -670,7 +670,7 @@ range_condition
closed_range
: a=INT ':' b=INT
: a=expression ':' b=expression
-> ^(CLOSED_RANGE $a $b);
......
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2014-07-17 20:45:59
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2014-07-22 16:47:59
import sys
from antlr3 import *
......
This diff is collapsed.
EXAMPLES=test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13
EXAMPLES=test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test-substrings
coverage:
for v in $(EXAMPLES) ; do make -C $$v coverage && mv $$v/.coverage* . || exit 1 ; done ; coverage combine
......
all: test-ada
edit:
../../../opengeode.py myfunction.pr system_structure.pr
check:
../../../opengeode.py myfunction.pr system_structure.pr --check
test-parse:
../../../opengeode.py myfunction.pr system_structure.pr --check
test-ada:
../../../opengeode.py --toAda myfunction.pr system_structure.pr || exit 1
asn1.exe -Ada dataview-uniq.asn -typePrefix asn1Scc -equal
asn1.exe -c dataview-uniq.asn -typePrefix asn1Scc
gnatmake -c myfunction.adb
gcc -c test.c
gnatbind -n myfunction.ali
gnatlink -o testcase test.o myfunction.ali -lgnat
./testcase | diff expected -
coverage:
coverage run -p ../../../opengeode.py myfunction.pr system_structure.pr --toAda
clean:
rm -rf *.adb *.ads *.pyc runSpark.sh spark.idx *.o *.ali gnat.cfg examiner bin *.wrn *.gpr datav*.? ber.c xer.c asn1crt.? acn.c real.c
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
END
TASTE-Dataview DEFINITIONS ::=
BEGIN
IMPORTS T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean FROM TASTE-BasicTypes;
-- A few simple types to start with ASN.1
MyInteger ::= T-UInt8
MyReal ::= REAL (0.0 .. 1000.0)
LargerReal ::= REAL (0.0 .. 1000000000)
MyEnum ::= ENUMERATED { hello(12), world(13), howareyou(111) }
MySeq ::= SEQUENCE {
a MyInteger,
b ENUMERATED { taste(1), welcomes(2), you(3) }
}
MyChoice ::= CHOICE {
a BOOLEAN,
b MySeq
}
MySeqOf ::= SEQUENCE (SIZE (2)) OF MyEnum
SeqInt ::= SEQUENCE (SIZE(1..2)) OF T-UInt8
MyOctStr ::= OCTET STRING (SIZE (3))
String ::= OCTET STRING (SIZE(0..100))
-- You can also declare variables (they will be visible in C, Ada and SDL)
myVar MySeqOf ::= { hello, world }
END
[C Code] Running test
TRUE
TRUE
Hello
12
13
-12
-13
2
2
1
1
TRUE
TRUE
1
1
1
5
/* CIF PROCESS (200, 143), (150, 75) */
PROCESS myfunction;
/* CIF TEXT (7, 43), (327, 41) */
-- Test substrings in various contexts and operators
/* CIF ENDTEXT */
/* CIF TEXT (0, 133), (282, 108) */
dcl str MyOctStr := 'abc';
dcl variable_str String := 'Hello!';
dcl seqof MySeqOf := {hello, world};
dcl seqint seqInt := {1};
/* CIF ENDTEXT */
/* CIF PROCEDURE (1416, 490), (91, 35) */
PROCEDURE factorial;
/* CIF TEXT (29, 42), (215, 53) */
fpar in N MyInteger,
in/out result MyInteger;
/* CIF ENDTEXT */
/* CIF START (298, 33), (70, 35) */
START;
/* CIF TASK (284, 83), (97, 35) */
TASK result := 1;
/* CIF TASK (223, 133), (220, 53) */
TASK for x in range(1, n+1):
result := (result * x) mod 255
endfor;
/* CIF RETURN (315, 201), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF START (114, 247), (65, 37) */
START;
/* CIF DECISION (85, 299), (123, 50) */
DECISION hello in seqof
/* CIF COMMENT (228, 300), (179, 53) */
COMMENT 'Check IN operator with
enumerated type';
/* CIF ANSWER (14, 369), (70, 23) */
(true):
/* CIF PROCEDURECALL (-39, 407), (177, 35) */
CALL writeln(hello in seqof)
/* CIF COMMENT (158, 407), (111, 35) */
COMMENT 'print "TRUE"';
/* CIF ANSWER (279, 369), (70, 23) */
(false):
ENDDECISION;
/* CIF DECISION (69, 457), (155, 50) */
DECISION hello in seqof(0,0)
/* CIF COMMENT (252, 458), (236, 53) */
COMMENT 'Check IN operator with
list substring - first element only
should go to branch TRUE';
/* CIF ANSWER (18, 518), (66, 33) */
(true):
/* CIF PROCEDURECALL (-49, 566), (201, 35) */
CALL writeln(hello in seqof(0,1))
/* CIF COMMENT (172, 566), (111, 35) */
COMMENT 'print "TRUE"';
/* CIF ANSWER (296, 519), (70, 23) */
(false):
ENDDECISION;
/* CIF PROCEDURECALL (51, 616), (190, 35) */
CALL writeln(variable_str(0,4))
/* CIF COMMENT (253, 589), (113, 35) */
COMMENT 'print "Hello"';
/* CIF TASK (58, 666), (176, 53) */
TASK for x in seqof:
call writeln(num(x));
endfor
/* CIF COMMENT (252, 646), (96, 53) */
COMMENT 'print:
12
13';
/* CIF TASK (57, 734), (178, 53) */
TASK for x in seqof(0,1):
call writeln(-num(x));
endfor
/* CIF COMMENT (253, 707), (96, 53) */
COMMENT 'print:
-12
-13';
/* CIF PROCEDURECALL (56, 802), (180, 35) */
CALL writeln(length(seqof))
/* CIF COMMENT (256, 790), (77, 35) */
COMMENT 'print 2';
/* CIF PROCEDURECALL (42, 852), (209, 35) */
CALL writeln(length(seqof(0,1)))
/* CIF COMMENT (271, 840), (77, 35) */
COMMENT 'print 2';
/* CIF LABEL (65, 902), (162, 35) */
variable_length_seq:
/* CIF TASK (75, 952), (142, 53) */
TASK for x in seqint:
call writeln(x);
endfor
/* CIF COMMENT (237, 925), (96, 53) */
COMMENT 'print:
1';
/* CIF TASK (71, 1020), (150, 53) */
TASK for x in seqint(0,0):
call writeln(x);
endfor
/* CIF COMMENT (241, 993), (96, 53) */
COMMENT 'print:
1';
/* CIF DECISION (85, 1088), (123, 50) */
DECISION 1 in seqint
/* CIF COMMENT (227, 1066), (179, 53) */
COMMENT 'Check IN operator with
variable-length seqOf';
/* CIF ANSWER (17, 1158), (66, 33) */
(true):
/* CIF PROCEDURECALL (-38, 1206), (177, 35) */
CALL writeln(1 in seqint)
/* CIF COMMENT (159, 1206), (111, 35) */
COMMENT 'print "TRUE"';
/* CIF ANSWER (277, 1158), (70, 23) */
(false):
ENDDECISION;
/* CIF DECISION (83, 1256), (126, 50) */
DECISION 1 in seqint(0,0)
/* CIF COMMENT (228, 1234), (179, 53) */
COMMENT 'Check IN operator with
variable-length seqOf';
/* CIF ANSWER (15, 1326), (70, 23) */
(true):
/* CIF PROCEDURECALL (-39, 1364), (179, 35) */
CALL writeln(1 in seqint(0,0))
/* CIF COMMENT (160, 1364), (111, 35) */
COMMENT 'print "TRUE"';
/* CIF ANSWER (278, 1326), (70, 23) */
(false):
ENDDECISION;
/* CIF PROCEDURECALL (56, 1414), (180, 35) */
CALL writeln(length(seqint))
/* CIF COMMENT (256, 1402), (77, 35) */
COMMENT 'print 1';
/* CIF PROCEDURECALL (40, 1464), (212, 35) */
CALL writeln(length(seqint(0,0)))
/* CIF COMMENT (272, 1452), (77, 35) */
COMMENT 'print 1';
/* CIF TASK (66, 1514), (161, 35) */
TASK seqint := seqint // {2};
/* CIF TASK (53, 1564), (186, 35) */
TASK seqint := seqint(0,0) // {5};
/* CIF TASK (75, 1614), (142, 53) */
TASK for x in seqint:
call writeln(x);
endfor
/* CIF COMMENT (239, 1611), (96, 53) */
COMMENT 'print:
1
5';
/* CIF NEXTSTATE (114, 1682), (65, 33) */
NEXTSTATE Wait;
/* CIF STATE (418, 313), (70, 35) */
STATE wait;
ENDSTATE;
ENDPROCESS myfunction;
\ No newline at end of file
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM myfunction;
/* CIF Keep Specific Geode PARAMNAMES tutu */
SIGNAL start_something (T_Int32);
/* CIF Keep Specific Geode PARAMNAMES titi */
SIGNAL result_data (T_Int32);
CHANNEL c
FROM ENV TO myfunction WITH start_something;
FROM myfunction TO ENV WITH result_data;
ENDCHANNEL;
BLOCK myfunction;
SIGNALROUTE r
FROM ENV TO myfunction WITH start_something;
FROM myfunction TO ENV WITH result_data;
CONNECT c and r;
PROCESS myfunction REFERENCED;
ENDBLOCK;
ENDSYSTEM;
\ No newline at end of file
#include <math.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include "dataview-uniq.h"
extern void adainit();
extern void myfunction_start_something(asn1SccT_Int32 *);
extern void myfunction_mytimer();
void myfunction_RI_result_data(long long *val)
{
printf("[C] result_data: %lld\n", *val);
}
int main()
{
asn1SccT_Int32 test = 5;
printf("[C Code] Running test\n");
adainit();
myfunction_start_something(&test);
return 0;
}
......@@ -25,7 +25,7 @@ MyInteger ::= T-UInt8
MyReal ::= REAL (0.0 .. 1000.0)
LargerReal ::= REAL (0.0 .. 1000000000)
MyEnum ::= ENUMERATED { hello, world, howareyou }
MyEnum ::= ENUMERATED { hello(12), world(13), howareyou(111) }
MySeq ::= SEQUENCE {
a MyInteger,
......
......@@ -18,6 +18,7 @@ Hello!
-2 is FALSE
2 2 1
FALSE TRUE
13 14
OK
[C] result_data: 6
Hello Toto 5
......
/* CIF PROCESS (200, 143), (150, 75) */
PROCESS myfunction;
/* CIF TEXT (0, 17), (296, 428) */
/* CIF TEXT (0, 17), (296, 458) */
-- Timers defined in the interface view
-- Use SET_TIMER (value, timer name)
-- and RESET_TIMER (timer name) in a
......@@ -29,6 +29,8 @@ dcl variable_str String := 'Hello!';
dcl other String := 'World';
dcl bar SeqInt := { 1,1 };
dcl testenum MyEnum := world;
/* CIF ENDTEXT */
/* CIF PROCEDURE (1172, 490), (91, 35) */
PROCEDURE factorial;
......@@ -49,126 +51,146 @@ endfor;
ENDPROCEDURE;
/* CIF START (603, 0), (76, 39) */
START;
/* CIF TASK (562, 54), (157, 98) */
/* CIF DECISION (587, 54), (107, 50) */
DECISION someint + 1
/* CIF COMMENT (714, 61), (146, 35) */
COMMENT 'Test closed range';
/* CIF ANSWER (546, 124), (99, 33) */
(0:998):
/* CIF ANSWER (707, 124), (99, 23) */
(2:otherint):
ENDDECISION;
/* CIF TASK (562, 192), (157, 98) */
TASK for x in range(4):
call writeln(x);
endfor,
for x in range(0,4,1):
call writeln(x);
endfor
/* CIF COMMENT (739, 85), (208, 35) */
/* CIF COMMENT (739, 223), (208, 35) */
COMMENT 'Check consistent behaviour';
/* CIF PROCEDURECALL (553, 167), (175, 35) */
/* CIF PROCEDURECALL (553, 305), (175, 35) */
CALL writeln(-(someint + 1))
/* CIF COMMENT (748, 167), (226, 38) */
/* CIF COMMENT (748, 305), (226, 38) */
COMMENT 'Test unary on expression result
should display -3';
/* CIF PROCEDURECALL (542, 217), (197, 35) */
/* CIF PROCEDURECALL (542, 355), (197, 35) */
CALL writeln(not(true or false))
/* CIF COMMENT (759, 217), (187, 38) */
/* CIF COMMENT (759, 355), (187, 38) */
COMMENT 'test unary on expression
should display FALSE';
/* CIF PROCEDURECALL (586, 267), (110, 35) */
/* CIF PROCEDURECALL (586, 405), (110, 35) */
CALL writeln(str)
/* CIF COMMENT (716, 267), (231, 35) */
/* CIF COMMENT (716, 405), (231, 35) */
COMMENT 'Test writeln with an octet string';
/* CIF PROCEDURECALL (586, 317), (110, 35) */
/* CIF PROCEDURECALL (586, 455), (110, 35) */
CALL writeln(str)
/* CIF COMMENT (716, 317), (254, 35) */
/* CIF COMMENT (716, 455), (254, 35) */
COMMENT 'Write again to check local variables';
/* CIF PROCEDURECALL (558, 367), (165, 35) */
/* CIF PROCEDURECALL (558, 505), (165, 35) */
CALL writeln(variable_str)
/* CIF COMMENT (743, 367), (275, 35) */
/* CIF COMMENT (743, 505), (275, 35) */
COMMENT 'Write a non-fixed length OCTET STRING';
/* CIF PROCEDURECALL (541, 417), (199, 38) */
/* CIF PROCEDURECALL (541, 555), (199, 38) */
CALL writeln(variable_str // '!!!')
/* CIF COMMENT (760, 418), (117, 35) */
/* CIF COMMENT (760, 556), (117, 35) */
COMMENT 'with APPEND';
/* CIF PROCEDURECALL (465, 470), (352, 35) */
/* CIF PROCEDURECALL (465, 608), (352, 35) */
CALL writeln(if someint>0 then variable_str else other fi)
/* CIF COMMENT (837, 470), (275, 35) */
/* CIF COMMENT (837, 608), (275, 35) */
COMMENT 'Write a non-fixed lenght OCTET STRING';
/* CIF PROCEDURECALL (552, 520), (177, 35) */
/* CIF PROCEDURECALL (552, 658), (177, 35) */
CALL writeln(1 + (-otherint))
/* CIF COMMENT (749, 520), (266, 35) */
/* CIF COMMENT (749, 658), (266, 35) */
COMMENT 'Test the op_minus in a sub-expression';
/* CIF PROCEDURECALL (430, 570), (421, 35) */
/* CIF PROCEDURECALL (430, 708), (421, 35) */
CALL writeln(-someint, if someint>0 then ' is ' else 'Foo' fi, not true)
/* CIF COMMENT (871, 570), (291, 35) */
/* CIF COMMENT (871, 708), (291, 35) */
COMMENT 'Various tests with strings, ternary, op_not';
/* CIF PROCEDURECALL (514, 620), (254, 35) */
/* CIF PROCEDURECALL (514, 758), (254, 35) */
CALL write(if someint>0 then 2 else 1 fi)
/* CIF COMMENT (788, 620), (220, 35) */
/* CIF COMMENT (788, 758), (220, 35) */
COMMENT 'test ternary with raw numbers';
/* CIF PROCEDURECALL (496, 670), (289, 35) */
/* CIF PROCEDURECALL (496, 808), (289, 35) */
CALL write(if someint>0 then someint else 1 fi)
/* CIF COMMENT (805, 670), (308, 35) */
/* CIF COMMENT (805, 808), (308, 35) */
COMMENT 'test ternary with mixed variable/raw number';
/* CIF PROCEDURECALL (577, 720), (128, 35) */
/* CIF PROCEDURECALL (577, 858), (128, 35) */
CALL writeln(bar(1))
/* CIF COMMENT (725, 720), (100, 35) */
/* CIF COMMENT (725, 858), (100, 35) */
COMMENT 'test index';
/* CIF PROCEDURECALL (532, 770), (217, 35) */
/* CIF PROCEDURECALL (532, 908), (217, 35) */
CALL writeln(opnot, ' ', not opnot)
/* CIF COMMENT (769, 770), (191, 35) */
/* CIF COMMENT (769, 908), (191, 35) */
COMMENT 'test op_not with variable';
/* CIF TASK (480, 820), (321, 35) */
/* CIF TASK (480, 958), (321, 35) */
TASK someInt := if someint = 0 then someint else 0 fi;
/* CIF DECISION (504, 870), (273, 87) */
/* CIF TASK (542, 1008), (197, 35) */
TASK otherint := num(testenum);
/* CIF PROCEDURECALL (513, 1058), (256, 35) */
CALL writeln(otherint, num(testenum)+1)
/* CIF COMMENT (789, 1028), (401, 98) */
COMMENT 'Will display 1 2 with the Ada generator
* even if the ASN.1 model specifies explicit values *
because Ada has no operator to get the explicit value,
even if it is set as representation clause. Enumerated values
are logical states, not integers in Ada - as in ASN.1
';
/* CIF DECISION (504, 1134), (273, 87) */
DECISION someint /=0 and then (10 / someInt > 0)
or else someint = 0
/* CIF COMMENT (793, 879), (179, 68) */
/* CIF COMMENT (793, 1143), (179, 68) */
COMMENT 'Using "and else" is the
short-circuit form. The
second part should not
be evaluated.';
/* CIF ANSWER (561, 977), (70, 23) */
/* CIF ANSWER (561, 1241), (70, 23) */
(true):
/* CIF TASK (541, 1015), (110, 35) */
/* CIF TASK (541, 1279), (110, 35) */
TASK someInt := 2;
/* CIF PROCEDURECALL (537, 1065), (117, 38) */
/* CIF PROCEDURECALL (537, 1329), (117, 38) */
CALL writeln('OK');
/* CIF ANSWER (664, 977), (70, 23) */
/* CIF ANSWER (664, 1241), (70, 23) */
(false):
ENDDECISION;
/* CIF NEXTSTATE (608, 1118), (65, 33) */
/* CIF NEXTSTATE (608, 1382), (65, 33) */
NEXTSTATE Wait;
/* CIF STATE (608, 1118), (65, 33) */
/* CIF STATE (608, 1382), (65, 33) */
STATE Wait;
/* CIF INPUT (865, 1171), (89, 33) */
/* CIF INPUT (865, 1435), (89, 33) */
INPUT mytimer;
/* CIF PROCEDURECALL (818, 1219), (182, 33) */
/* CIF PROCEDURECALL (818, 1483), (182, 33) */
CALL writeln('timer expired');
/* CIF PROCEDURECALL (829, 1267), (160, 33) */
/* CIF PROCEDURECALL (829, 1531), (160, 33) */
CALL factorial(3, someint);
/* CIF NEXTSTATE (877, 1315), (65, 33) */
/* CIF NEXTSTATE (877, 1579), (65, 33) */
NEXTSTATE Wait;
/* CIF INPUT (421, 1171), (181, 33) */
/* CIF INPUT (421, 1435), (181, 33) */
INPUT start_something (toto);
/* CIF OUTPUT (376, 1219), (270, 33) */
/* CIF OUTPUT (376, 1483), (270, 33) */
OUTPUT result_data((toto+1) mod 2147483647);
/* CIF PROCEDURECALL (436, 1267), (150, 48) */
/* CIF PROCEDURECALL (436, 1531), (150, 48) */
CALL writeln
('Hello Toto', toto);
/* CIF PROCEDURECALL (413, 1330), (196, 33) */
/* CIF PROCEDURECALL (413, 1594), (196, 33) */
CALL set_timer(1000, myTimer);
/* CIF TASK (346, 1378), (330, 35) */
/* CIF TASK (346, 1642), (330, 35) */
TASK largeReal := power(someReal, 2);
/* CIF PROCEDURECALL (282, 1428), (458, 35) */
/* CIF PROCEDURECALL (282, 1692), (458, 35) */
CALL writeln(someReal, ' ** 2' , ' == ', largeReal, ' (should be 2.25 )');
/* CIF TASK (411, 1478), (201, 35) */
/* CIF TASK (411, 1742), (201, 35) */
TASK someReal := float(someInt);
/* CIF TASK (391, 1528), (241, 35) */
/* CIF TASK (391, 1792), (241, 35) */
TASK someInt := fix(someReal) mod 255;
/* CIF TASK (435, 1578), (152, 35) */
/* CIF TASK (435, 1842), (152, 35) */
TASK opnot := not opnot;
/* CIF TASK (430, 1628), (163, 35) */
/* CIF TASK (430, 1892), (163, 35) */
TASK 'someint := -someint'
/* CIF COMMENT (613, 1628), (196, 35) */
/* CIF COMMENT (613, 1892), (196, 35) */
COMMENT 'XXX should raise an error!';
/* CIF TASK (429, 1678), (164, 35) */
/* CIF TASK (429, 1942), (164, 35) */
TASK someint := (-8) mod 5;
/* CIF NEXTSTATE (480, 1728), (63, 33) */
/* CIF NEXTSTATE (480, 1992), (63, 33) */
NEXTSTATE wait;
ENDSTATE;
ENDPROCESS myfunction;
\ No newline at end of file
......@@ -20,6 +20,7 @@ paths = [
'regression/test11',
'regression/test12',
'regression/test13',
'regression/test-substrings',
]
......
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