Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
5cefbcf0
Commit
5cefbcf0
authored
Jul 02, 2014
by
dbarbera
Browse files
Merge branch 'master' into llvm
parents
54e91fe2
ad11aa98
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
AdaGenerator.py
View file @
5cefbcf0
...
...
@@ -931,8 +931,11 @@ def _bitwise_operators(expr):
ada_string
+=
u
", Length => {left}.Length"
.
format
(
left
=
left_str
)
ada_string
+=
u
')'
else
:
ada_string
=
u
'({left} {op} {right})'
.
format
(
left
=
left_str
,
op
=
expr
.
operand
,
right
=
right_str
)
ada_string
=
u
'({left} {op}{short} {right})'
.
format
(
left
=
left_str
,
op
=
expr
.
operand
,
short
=
expr
.
shortcircuit
,
right
=
right_str
)
code
.
extend
(
left_stmts
)
code
.
extend
(
right_stmts
)
local_decl
.
extend
(
left_local
)
...
...
icons.py
View file @
5cefbcf0
...
...
@@ -2,7 +2,7 @@
# Resource object code
#
# Created:
Fri
Ju
n
2
7 18:30:08
2014
# Created:
Wed
Ju
l
2
08:06:50
2014
# by: The Resource Compiler for PySide (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!
ogAST.py
View file @
5cefbcf0
...
...
@@ -76,14 +76,19 @@ class ExprMinus(Expression):
class
ExprOr
(
Expression
):
operand
=
'or'
# Indicate that short circuit form is used ("or else")
shortcircuit
=
''
class
ExprAnd
(
Expression
):
operand
=
'and'
# Indicate that short circuit form is used ("and then")
shortcircuit
=
''
class
ExprXor
(
Expression
):
operand
=
'xor'
shortcircuit
=
''
class
ExprEq
(
Expression
):
...
...
ogParser.py
View file @
5cefbcf0
...
...
@@ -1282,6 +1282,22 @@ def expression(root, context):
root
.
getCharPositionInLine
())
expr
.
exprType
=
UNKNOWN_TYPE
if
root
.
type
in
(
lexer
.
OR
,
lexer
.
AND
):
# detect optional THEN in AND/OR expressions, indicating that the
# short-circuit version of the operator is needed, to prevent the
# evaluation of the right part if the left part does not evaluate
# to true.
for
idx
,
val
in
enumerate
(
root
.
children
):
if
val
.
type
==
lexer
.
THEN
:
expr
.
shortcircuit
=
' then'
root
.
children
.
pop
(
idx
)
break
elif
val
.
type
==
lexer
.
ELSE
:
expr
.
shortcircuit
=
' else'
root
.
children
.
pop
(
idx
)
break
if
root
.
type
in
(
lexer
.
PLUS
,
lexer
.
ASTERISK
,
lexer
.
DASH
,
...
...
sdl92.g
View file @
5cefbcf0
...
...
@@ -796,8 +796,8 @@ field_selection
: (('!'|'.') field_name);
expression : operand0 ( IMPLIES^ operand0)* ;
operand0 : operand1 (( OR^ | XOR^ ) operand1)*;
operand1 : operand2 ( AND^ operand2)*;
operand0 : operand1 ((
(
OR^
ELSE?)
| XOR^ ) operand1)*;
operand1 : operand2 ( AND^
THEN?
operand2)*;
operand2 : operand3
(( EQ^ | NEQ^ | GT^ | GE^ | LT^ | LE^ | IN^ )
operand3)*;
...
...
sdl92Lexer.py
View file @
5cefbcf0
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2014-0
6-27 18:30:11
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2014-0
7-02 08:11:12
import
sys
from
antlr3
import
*
...
...
sdl92Parser.py
View file @
5cefbcf0
This diff is collapsed.
Click to expand it.
tests/regression/test6/Makefile
View file @
5cefbcf0
...
...
@@ -7,6 +7,11 @@ test-ada:
../../../opengeode.py
--toAda
myfunction.pr system_structure.pr
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnatmake
-c
myfunction.adb
gcc
-c
test.c
gnatbind
-n
myfunction.ali
gnatlink
-o
testcase test.o myfunction.ali
-lgnat
./testcase
./testcase | diff expected -
test-llvm
:
../../../opengeode.py myfunction.pr system_structure.pr
--llvm
...
...
tests/regression/test6/expected
0 → 100644
View file @
5cefbcf0
[C Code] Running test
OK
tests/regression/test6/myfunction.pr
View file @
5cefbcf0
/* CIF PROCESS (148, 150), (150, 75) */
PROCESS myfunction;
/* CIF TEXT (
-533, -82
), (271, 323) */
-- Timers defined in the interface view
/* CIF TEXT (
0, 17
), (271, 323) */
-- Timers defined in the interface view
-- Use SET_TIMER (value, timer name)
-- and RESET_TIMER (timer name) in a
-- PROCEDURE CALL symbol to use them
...
...
@@ -21,66 +21,81 @@ dcl someInt t_uInt8 := 2;
-- To test 'op_not'
dcl opnot T_boolean := not true;
/* CIF ENDTEXT */
/* CIF PROCEDURE (
358, 391
), (91, 35) */
PROCEDURE factorial;
/* CIF TEXT (29, 42), (215, 48) */
fpar in N MyInteger,
/* CIF ENDTEXT */
/* CIF PROCEDURE (
982, 490
), (91, 35) */
PROCEDURE factorial;
/* CIF TEXT (29, 42), (215, 48) */
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):
/* 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 (58, -99), (100, 50) */
START;
/* CIF NEXTSTATE (58, -34), (100, 50) */
NEXTSTATE Wait;
/* CIF STATE (58, -34), (100, 50) */
STATE Wait;
/* CIF INPUT (277, 36), (100, 50) */
INPUT mytimer;
/* CIF PROCEDURECALL (259, 101), (135, 50) */
CALL writeln
('timer expired');
/* CIF PROCEDURECALL (247, 166), (160, 35) */
CALL factorial(3, someint);
/* CIF NEXTSTATE (277, 216), (100, 50) */
NEXTSTATE Wait;
/* CIF INPUT (-83, 36), (198, 50) */
INPUT start_something (toto);
/* CIF OUTPUT (-119, 101), (270, 50) */
OUTPUT result_data((toto+1) mod 2147483647);
/* CIF PROCEDURECALL (-59, 166), (150, 50) */
CALL writeln
/* CIF RETURN (315, 201), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF START (591, 0), (100, 50) */
START;
/* CIF TASK (586, 65), (110, 35) */
TASK someInt := 0;
/* CIF DECISION (504, 115), (273, 87) */
DECISION someint /=0 and then (10 / someInt > 0)
or else someint = 0
/* CIF COMMENT (793, 124), (179, 68) */
COMMENT 'Using "and else" is the
short-circuit form. The
second part should not
be evaluated.';
/* CIF ANSWER (561, 222), (70, 23) */
(true):
/* CIF TASK (541, 260), (110, 35) */
TASK someInt := 5;
/* CIF PROCEDURECALL (537, 310), (117, 38) */
CALL writeln('OK');
/* CIF ANSWER (664, 222), (70, 23) */
(false):
ENDDECISION;
/* CIF NEXTSTATE (591, 363), (100, 50) */
NEXTSTATE Wait;
/* CIF STATE (591, 363), (100, 50) */
STATE Wait;
/* CIF INPUT (810, 433), (100, 50) */
INPUT mytimer;
/* CIF PROCEDURECALL (769, 498), (182, 50) */
CALL writeln('timer expired');
/* CIF PROCEDURECALL (780, 563), (160, 35) */
CALL factorial(3, someint);
/* CIF NEXTSTATE (810, 613), (100, 50) */
NEXTSTATE Wait;
/* CIF INPUT (450, 433), (198, 50) */
INPUT start_something (toto);
/* CIF OUTPUT (414, 498), (270, 50) */
OUTPUT result_data((toto+1) mod 2147483647);
/* CIF PROCEDURECALL (474, 563), (150, 50) */
CALL writeln
('Hello Toto', toto);
/* CIF PROCEDURECALL (-50, 231), (132, 50) */
CALL set_timer
(1000, myTimer);
/* CIF TASK (-142, 296), (316, 35) */
TASK someReal := power(someReal, someInt mod 1);
/* CIF PROCEDURECALL (-154, 346), (340, 35) */
CALL writeln('1.5 ** 2 == ', someReal, ' (should be 2.25 )');
/* CIF TASK (-84, 396), (201, 35) */
TASK someReal := float(someInt);
/* CIF TASK (-104, 446), (241, 35) */
TASK someInt := fix(someReal) mod 255;
/* CIF TASK (-60, 496), (152, 35) */
TASK opnot := not opnot;
/* CIF TASK (-62, 546), (157, 35) */
TASK someint := -someint;
/* CIF TASK (-66, 596), (164, 35) */
TASK someint := (-8) mod 5;
/* CIF NEXTSTATE (-35, 646), (102, 50) */
NEXTSTATE wait;
ENDSTATE;
/* CIF PROCEDURECALL (451, 628), (196, 50) */
CALL set_timer(1000, myTimer);
/* CIF TASK (391, 693), (316, 35) */
TASK someReal := power(someReal, someInt mod 1);
/* CIF PROCEDURECALL (379, 743), (340, 35) */
CALL writeln('1.5 ** 2 == ', someReal, ' (should be 2.25 )');
/* CIF TASK (448, 793), (201, 35) */
TASK someReal := float(someInt);
/* CIF TASK (428, 843), (241, 35) */
TASK someInt := fix(someReal) mod 255;
/* CIF TASK (473, 893), (152, 35) */
TASK opnot := not opnot;
/* CIF TASK (470, 943), (157, 35) */
TASK someint := -someint;
/* CIF TASK (467, 993), (164, 35) */
TASK someint := (-8) mod 5;
/* CIF NEXTSTATE (498, 1043), (102, 50) */
NEXTSTATE wait;
ENDSTATE;
ENDPROCESS myfunction;
\ No newline at end of file
tests/regression/test6/test.c
0 → 100644
View file @
5cefbcf0
#include
<math.h>
#include
<stdio.h>
extern
void
adainit
();
void
myfunction_RI_result_data
(
long
long
*
val
)
{
printf
(
"[C] result_data: %lld
\n
"
,
*
val
);
}
void
myfunction_RI_set_mytimer
(
long
long
*
val
)
{
printf
(
"[C] SET MyTimer: %lld
\n
"
,
*
val
);
}
void
myfunction_RI_reset_mytimer
()
{
printf
(
"RESET MyTimer
\n
"
);
}
int
main
()
{
printf
(
"[C Code] Running test
\n
"
);
adainit
();
return
0
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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