Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
61bf8b40
Commit
61bf8b40
authored
Apr 25, 2014
by
Maxime Perrotin
Browse files
Bugfix in DECISION handling
parent
9faa0058
Changes
20
Hide whitespace changes
Inline
Side-by-side
AdaGenerator.py
View file @
61bf8b40
...
...
@@ -1302,6 +1302,7 @@ def _decision(dec):
code
.
append
(
'tmp{idx} := {q};'
.
format
(
idx
=
dec
.
tmpVar
,
q
=
q_str
))
sep
=
'if '
for
a
in
dec
.
answers
:
code
.
extend
(
traceability
(
a
))
if
a
.
kind
in
(
'open_range'
,
'constant'
):
# Note: removed and a.transition here because empty transitions
# have a different meaning, and a "null;" statement has to be
...
...
@@ -1317,7 +1318,7 @@ def _decision(dec):
exp
=
'not '
+
exp
else
:
exp
=
'tmp{idx} {op} {ans}'
.
format
(
idx
=
dec
.
tmpVar
,
op
=
OPERANDS
[
a
.
openRangeOp
]
,
ans
=
ans_str
)
op
=
a
.
openRangeOp
.
operand
,
ans
=
ans_str
)
else
:
exp
=
'{q} {op} {ans}'
.
format
(
q
=
q_str
,
op
=
a
.
openRangeOp
.
operand
,
...
...
ogParser.py
View file @
61bf8b40
...
...
@@ -320,6 +320,27 @@ def fix_special_operators(op_name, expr_list, context):
and
not
basic
.
kind
.
endswith
(
'StringType'
):
# Currently supported printable types
raise
TypeError
(
'Write operator does not support type'
)
elif
op_name
.
lower
()
==
'set_timer'
:
if
len
(
expr_list
)
!=
2
:
raise
TypeError
(
'SET_TIMER has 2 parameters: (int, timer_name)'
)
basic
=
find_basic_type
(
expr_list
[
0
].
exprType
)
if
not
basic
.
kind
.
startswith
(
'Integer'
):
raise
TypeError
(
'SET_TIMER first parameter is not an integer'
)
timer
=
expr_list
[
1
].
inputString
for
each
in
context
.
timers
:
if
each
.
lower
()
==
timer
.
lower
():
break
else
:
raise
TypeError
(
'Timer {} is not defined'
.
format
(
timer
))
elif
op_name
.
lower
==
'reset_timer'
:
if
len
(
expr_list
)
!=
1
:
raise
TypeError
(
'RESET_TIMER has 1 parameter: timer_name'
)
timer
=
expr_list
[
0
].
inputString
for
each
in
context
.
timers
:
if
each
.
lower
()
==
timer
.
lower
():
break
else
:
raise
TypeError
(
'Timer {} is not defined'
.
format
(
timer
))
else
:
# TODO: other operators
return
...
...
@@ -2233,7 +2254,8 @@ def alternative_part(root, parent, context):
c
.
getChild
(
0
),
context
)
errors
.
extend
(
err
)
warnings
.
extend
(
warn
)
ans
.
openRangeOp
=
ogAST
.
ExprEq
if
not
ans
.
openRangeOp
:
ans
.
openRangeOp
=
ogAST
.
ExprEq
else
:
ans
.
openRangeOp
=
OPKIND
[
c
.
type
]
elif
child
.
type
==
lexer
.
INFORMAL_TEXT
:
...
...
tests/regression/Makefile
View file @
61bf8b40
EXAMPLES
=
test1 test2 test3 test4 test5 test6 test7 test8 test9 test10
EXAMPLES
=
test1 test2 test3 test4 test5 test6 test7 test8 test9 test10
test11
all
:
for
v
in
$(EXAMPLES)
;
do
make
-C
$$
v clean all
||
exit
1
;
done
...
...
tests/regression/test1/Makefile
View file @
61bf8b40
...
...
@@ -6,7 +6,7 @@ generate-code:
compile
:
generate-code
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnat
gcc
-c
og.adb
&&
echo
'All OK!'
gnat
make
-c
og.adb
&&
echo
'All OK!'
parse
:
../../../opengeode.py og.pr system_structure.pr
--check
...
...
tests/regression/test10/Makefile
View file @
61bf8b40
...
...
@@ -6,8 +6,8 @@ generate-code:
compile
:
generate-code
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnat
gcc
-c
*
.adb
gcc
-c
test.c
gnat
make
-c
*
.adb
gcc
-c
test.c
gcc
-o
test
test.o challenge.o taste_dataview.o taste_basictypes.o
-lgnat
-lm
./test
&&
echo
'All OK!'
...
...
tests/regression/test11/DataView.py
0 → 100644
View file @
61bf8b40
#!/usr/bin/env python
# ASN.1 Data model
asn1Files
=
[]
asn1Modules
=
[]
exportedTypes
=
{}
exportedVariables
=
{}
importedModules
=
{}
types
=
{}
asn1Files
.
append
(
"./dataview-uniq.asn"
)
asn1Modules
.
append
(
"TASTE-Dataview"
)
exportedTypes
[
"TASTE-Dataview"
]
=
[
"Some-Thing"
,
"MyInteger"
,
"My-OctStr"
,
"SeqOf"
]
exportedVariables
[
"TASTE-Dataview"
]
=
[
"default-seqof"
,
"default-str"
]
importedModules
[
"TASTE-Dataview"
]
=
[]
types
[
"Some-Thing"
]
=
type
(
"Some-Thing"
,
(
object
,),
{
"Line"
:
6
,
"CharPositionInLine"
:
0
,
"type"
:
type
(
"Some-Thing_type"
,
(
object
,),
{
"Line"
:
6
,
"CharPositionInLine"
:
15
,
"kind"
:
"ReferenceType"
,
"ReferencedTypeName"
:
"MyInteger"
,
"Min"
:
"0"
,
"Max"
:
"255"
})
})
types
[
"MyInteger"
]
=
type
(
"MyInteger"
,
(
object
,),
{
"Line"
:
8
,
"CharPositionInLine"
:
0
,
"type"
:
type
(
"MyInteger_type"
,
(
object
,),
{
"Line"
:
8
,
"CharPositionInLine"
:
16
,
"kind"
:
"IntegerType"
,
"Min"
:
"0"
,
"Max"
:
"255"
})
})
types
[
"My-OctStr"
]
=
type
(
"My-OctStr"
,
(
object
,),
{
"Line"
:
10
,
"CharPositionInLine"
:
0
,
"type"
:
type
(
"My-OctStr_type"
,
(
object
,),
{
"Line"
:
10
,
"CharPositionInLine"
:
17
,
"kind"
:
"OctetStringType"
,
"Min"
:
"0"
,
"Max"
:
"20"
})
})
types
[
"SeqOf"
]
=
type
(
"SeqOf"
,
(
object
,),
{
"Line"
:
12
,
"CharPositionInLine"
:
0
,
"type"
:
type
(
"SeqOf_type"
,
(
object
,),
{
"Line"
:
12
,
"CharPositionInLine"
:
10
,
"kind"
:
"SequenceOfType"
,
"Min"
:
"0"
,
"Max"
:
"100"
,
"type"
:
type
(
"SeqOf_type"
,
(
object
,),
{
"Line"
:
12
,
"CharPositionInLine"
:
37
,
"kind"
:
"ReferenceType"
,
"ReferencedTypeName"
:
"MyInteger"
,
"Min"
:
"0"
,
"Max"
:
"255"
})
})
})
tests/regression/test11/Makefile
0 → 100644
View file @
61bf8b40
all
:
compile
generate-code
:
../../../opengeode.py
--toAda
og.pr system_structure.pr
compile
:
generate-code
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnatmake
-c
*
.adb
gcc
-c
test.c
gcc
-o
test
test.o og.o taste_dataview.o
-lgnat
./test
>
result
diff result expected
&&
echo
'All OK!'
parse
:
../../../opengeode.py og.pr system_structure.pr
--check
coverage
:
coverage run
-p
../../../opengeode.py og.pr system_structure.pr
--toAda
clean
:
rm
-rf
result
*
.adb
*
.ads
*
.pyc runSpark.sh spark.idx
*
.o
*
.ali gnat.cfg examiner bin
*
.wrn
*
.gpr
tests/regression/test11/dataview-uniq.asn
0 → 100644
View file @
61bf8b40
TASTE-Dataview DEFINITIONS ::=
BEGIN
Some-Thing ::= MyInteger
MyInteger ::= INTEGER (0..255)
My-OctStr ::= OCTET STRING (SIZE (0..20))
SeqOf ::= SEQUENCE (SIZE(0..100)) OF MyInteger
default-seqof SeqOf ::= {4,7,9}
default-str My-OctStr ::= 'DEADBEEF'H
END
tests/regression/test11/expected
0 → 100644
View file @
61bf8b40
[C Code] Running test
1
2
3
4
5
6
end of test
tests/regression/test11/og.pr
0 → 100644
View file @
61bf8b40
PROCESS og;
/* CIF TEXT (0, 0), (229, 98) */
-- Testing decisions
dcl test myInteger := 3;
/* CIF ENDTEXT */
/* CIF START (482, 35), (70, 35) */
START;
/* CIF LABEL (474, 85), (85, 35) */
again:
/* CIF DECISION (482, 135), (70, 50) */
DECISION test;
/* CIF ANSWER (85, 205), (70, 23) */
(3):
/* CIF PROCEDURECALL (67, 243), (106, 35) */
CALL writeln('1');
/* CIF TASK (77, 293), (87, 35) */
TASK test := 5;
/* CIF JOIN (103, 343), (35, 35) */
JOIN again;
/* CIF ANSWER (582, 205), (70, 23) */
(>5):
/* CIF PROCEDURECALL (561, 243), (113, 35) */
CALL writeln('4');
/* CIF TASK (574, 293), (87, 35) */
TASK test := 7;
/* CIF LABEL (568, 343), (98, 35) */
and_again:
/* CIF DECISION (582, 393), (70, 50) */
DECISION test;
/* CIF ANSWER (681, 463), (70, 23) */
(<=5):
/* CIF DECISION (681, 501), (70, 50) */
DECISION test;
/* CIF ANSWER (576, 571), (70, 23) */
(>=5):
/* CIF PROCEDURECALL (545, 609), (132, 35) */
CALL writeln('6');
/* CIF ANSWER (746, 571), (70, 23) */
else:
/* CIF PROCEDURECALL (707, 609), (148, 35) */
CALL writeln('[ERROR]');
ENDDECISION;
/* CIF ANSWER (444, 463), (70, 23) */
(/=5):
/* CIF PROCEDURECALL (422, 501), (113, 35) */
CALL writeln('5');
/* CIF TASK (435, 551), (87, 35) */
TASK test := 5;
/* CIF JOIN (461, 601), (35, 35) */
JOIN and_again;
ENDDECISION;
/* CIF ANSWER (321, 205), (70, 23) */
(<5):
/* CIF PROCEDURECALL (299, 243), (113, 35) */
CALL writeln('3');
/* CIF TASK (309, 293), (94, 35) */
TASK test := 6;
/* CIF JOIN (338, 343), (35, 35) */
JOIN again;
/* CIF ANSWER (201, 205), (70, 23) */
(=5):
/* CIF PROCEDURECALL (183, 243), (106, 35) */
CALL writeln('2');
/* CIF TASK (189, 293), (94, 35) */
TASK test := 4;
/* CIF JOIN (219, 343), (35, 35) */
JOIN again;
/* CIF ANSWER (904, 205), (70, 23) */
else:
/* CIF PROCEDURECALL (865, 243), (148, 35) */
CALL writeln('[ERROR]');
ENDDECISION;
/* CIF PROCEDURECALL (433, 689), (167, 35) */
CALL writeln('end of test');
/* CIF NEXTSTATE (472, 739), (90, 35) */
NEXTSTATE all_done;
/* CIF STATE (1078, 167), (90, 35) */
STATE all_done;
ENDSTATE;
ENDPROCESS og;
\ No newline at end of file
tests/regression/test11/system_structure.pr
0 → 100644
View file @
61bf8b40
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM og;
/* CIF Keep Specific Geode PARAMNAMES ze_param */
SIGNAL go (My_OctStr);
/* CIF Keep Specific Geode PARAMNAMES ze_rezult */
SIGNAL rezult (My_OctStr);
CHANNEL c
FROM ENV TO og WITH go;
FROM og TO ENV WITH rezult;
ENDCHANNEL;
BLOCK og;
SIGNALROUTE r
FROM ENV TO og WITH go;
FROM og TO ENV WITH rezult;
CONNECT c and r;
PROCESS og REFERENCED;
ENDBLOCK;
ENDSYSTEM;
\ No newline at end of file
tests/regression/test11/test.c
0 → 100644
View file @
61bf8b40
#include
<math.h>
#include
<stdio.h>
/* Ada code external interface */
extern
void
og_start
();
int
main
()
{
printf
(
"[C Code] Running test
\n
"
);
og_start
();
return
0
;
}
tests/regression/test2/Makefile
View file @
61bf8b40
...
...
@@ -5,7 +5,7 @@ generate-code:
compile
:
generate-code
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnat
gcc
-c
orchestrator.adb
&&
echo
'All OK!'
gnat
make
-c
orchestrator.adb
&&
echo
'All OK!'
parse
:
../../../opengeode.py orchestrator.pr system_structure.pr
--check
...
...
tests/regression/test3/Makefile
View file @
61bf8b40
...
...
@@ -6,7 +6,7 @@ generate-code:
compile
:
generate-code
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnat
gcc
-c
fce.adb
&&
echo
'All OK!'
gnat
make
-c
fce.adb
&&
echo
'All OK!'
parse
:
../../../opengeode.py fce.pr system_structure.pr
--check
...
...
tests/regression/test4/Makefile
View file @
61bf8b40
...
...
@@ -6,7 +6,7 @@ generate-code:
compile
:
generate-code
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnat
gcc
-c
orchestrator.adb
&&
echo
'All OK!'
gnat
make
-c
orchestrator.adb
&&
echo
'All OK!'
parse
:
../../../opengeode.py orchestrator.pr system_structure.pr
--check
...
...
tests/regression/test5/Makefile
View file @
61bf8b40
...
...
@@ -6,7 +6,7 @@ generate-code:
compile
:
generate-code
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnat
gcc
-c
function0.adb
&&
echo
'All OK!'
gnat
make
-c
function0.adb
&&
echo
'All OK!'
parse
:
../../../opengeode.py function0.pr system_structure.pr
--check
...
...
tests/regression/test6/Makefile
View file @
61bf8b40
...
...
@@ -6,7 +6,7 @@ generate-code:
compile
:
generate-code
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnat
gcc
-c
myfunction.adb
&&
echo
'All OK!'
gnat
make
-c
myfunction.adb
&&
echo
'All OK!'
parse
:
../../../opengeode.py myfunction.pr system_structure.pr
--check
...
...
tests/regression/test7/Makefile
View file @
61bf8b40
...
...
@@ -6,7 +6,7 @@ generate-code:
compile
:
generate-code
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnat
gcc
-c
orchestrator.adb
&&
echo
'All OK!'
gnat
make
-c
orchestrator.adb
&&
echo
'All OK!'
parse
:
../../../opengeode.py orchestrator.pr system_structure.pr
--check
...
...
tests/regression/test8/Makefile
View file @
61bf8b40
...
...
@@ -6,7 +6,7 @@ generate-code:
compile
:
generate-code
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnat
gcc
-c
orchestrator.adb
&&
echo
'All OK!'
gnat
make
-c
orchestrator.adb
&&
echo
'All OK!'
parse
:
../../../opengeode.py
--check
orchestrator.pr system_structure.pr
...
...
tests/regression/test9/Makefile
View file @
61bf8b40
...
...
@@ -6,7 +6,7 @@ generate-code:
compile
:
generate-code
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnat
gcc
-c
challenge.adb
&&
echo
'All OK!'
gnat
make
-c
challenge.adb
&&
echo
'All OK!'
parse
:
../../../opengeode.py challenge.pr system_structure.pr
--check
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment