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
a954c6cb
Commit
a954c6cb
authored
Oct 25, 2014
by
Maxime Perrotin
Browse files
Add testcase for a standalone system
parent
98f3c48e
Changes
5
Hide whitespace changes
Inline
Side-by-side
AdaGenerator.py
View file @
a954c6cb
...
...
@@ -213,7 +213,7 @@ package {process_name} is'''.format(process_name=process_name,
if
signal
.
get
(
'name'
,
u
'START'
)
==
u
'START'
:
continue
pi_header
=
'procedure {sig_name}'
.
format
(
sig_name
=
signal
[
'name'
])
param_name
=
signal
.
get
(
'param_name'
)
or
'
MISSING_PARAM_NAME'
param_name
=
signal
.
get
(
'param_name'
)
or
'
{}_param'
.
format
(
signal
[
'name'
])
# Add (optional) PI parameter (only one is possible in TASTE PI)
if
'type'
in
signal
:
typename
=
signal
[
'type'
].
ReferencedTypeName
.
replace
(
'-'
,
'_'
)
...
...
ogParser.py
View file @
a954c6cb
...
...
@@ -1769,14 +1769,16 @@ def variables(root, ta_ast, context):
warnings
.
append
(
'Unsupported variables construct type: '
+
str
(
child
.
type
))
for
variable
in
var
:
if
not
hasattr
(
context
,
'variables'
):
errors
.
append
(
'Variables shall not be declared here'
)
# Add to the context and text area AST entries
if
variable
.
lower
()
in
context
.
variables
\
or
variable
.
lower
()
in
ta_ast
.
variables
:
el
if
(
variable
.
lower
()
in
context
.
variables
or
variable
.
lower
()
in
ta_ast
.
variables
)
:
errors
.
append
(
'Variable "{}" is declared more than once'
.
format
(
variable
))
else
:
context
.
variables
[
variable
.
lower
()]
=
(
asn1_sort
,
def_value
)
ta_ast
.
variables
[
variable
.
lower
()]
=
(
asn1_sort
,
def_value
)
ta_ast
.
variables
[
variable
.
lower
()]
=
(
asn1_sort
,
def_value
)
if
not
DV
:
errors
.
append
(
'Cannot do semantic checks on variable declarations'
)
return
errors
,
warnings
...
...
@@ -2257,6 +2259,7 @@ def text_area_content(root, ta_ast, context):
procedures '''
errors
=
[]
warnings
=
[]
signals
=
[]
for
child
in
root
.
getChildren
():
if
child
.
type
==
lexer
.
DCL
:
err
,
warn
=
dcl
(
child
,
ta_ast
,
context
)
...
...
@@ -2301,10 +2304,10 @@ def text_area_content(root, ta_ast, context):
context
.
timers
.
extend
(
timers
)
ta_ast
.
timers
=
timers
elif
child
.
type
==
lexer
.
SIGNAL
:
sig
,
err
,
warn
=
signal
(
child
)
errors
.
extend
(
err
)
warnings
.
extend
(
warn
)
ta_ast
.
signals
.
append
(
sig
)
# Signals can be declared at system level, but that must be parsed
# AFTER possible "USE Datamodel COMMENT 'asn1_filename';"
# in order to have the types properly defined
signals
.
append
(
child
)
elif
child
.
type
==
lexer
.
USE
:
# USE clauses can contain a CIF comment with the ASN.1 filename
for
each
in
child
.
getChildren
():
...
...
@@ -2320,6 +2323,18 @@ def text_area_content(root, ta_ast, context):
warnings
.
append
(
'Unsupported construct in text area content, type: '
+
str
(
child
.
type
))
if
ta_ast
.
asn1_files
:
# Parse ASN.1 files that are referenced in USE clauses
try
:
set_global_DV
(
ta_ast
.
asn1_files
)
except
TypeError
as
err
:
errors
.
append
(
str
(
err
))
for
each
in
signals
:
# Parse signals now - ASN.1 types should have been set
sig
,
err
,
warn
=
signal
(
each
)
errors
.
extend
(
err
)
warnings
.
extend
(
warn
)
ta_ast
.
signals
.
append
(
sig
)
return
errors
,
warnings
...
...
@@ -2468,26 +2483,27 @@ def system_definition(root, parent):
# Text zone where signals can be declared
textarea
,
err
,
warn
=
text_area
(
child
,
context
=
system
)
system
.
signals
.
extend
(
textarea
.
signals
)
if
textarea
.
variables
:
errors
.
append
(
'Variables shall be declared only in a process'
)
if
textarea
.
fpar
:
errors
.
append
(
'FPAR shall be declared only in procedures'
)
if
textarea
.
timers
:
errors
.
append
(
'Timers shall be declared only in a process'
)
# Update list of ASN.1 files - if any
asn1_files
.
extend
(
textarea
.
asn1_files
)
if
not
asn1_files
:
asn1_files
=
textarea
.
asn1_files
else
:
errors
.
append
(
'All ASN.1 Files must be set in the same text area'
)
errors
.
extend
(
err
)
warnings
.
extend
(
warn
)
system
.
text_areas
.
append
(
textarea
)
else
:
warnings
.
append
(
'Unsupported construct in system: '
+
str
(
child
.
type
))
if
asn1_files
:
# parse ASN.1 files before parsing the rest of the system
try
:
set_global_DV
(
asn1_files
)
except
TypeError
as
err
:
errors
.
append
(
str
(
err
))
#
if asn1_files:
#
# parse ASN.1 files before parsing the rest of the system
#
try:
#
set_global_DV(asn1_files)
#
except TypeError as err:
#
errors.append(str(err))
system
.
ast
.
asn1Modules
=
DV
.
asn1Modules
system
.
ast
.
asn1_filenames
=
asn1_files
for
each
in
signals
:
...
...
tests/regression/test-standalone/Makefile
0 → 100644
View file @
a954c6cb
include
../shared.mk
all
:
test-ada test-llvm
edit
:
$(OPENGEODE)
og.pr
test-parse
:
$(OPENGEODE)
og.pr
--check
test-ada
:
$(OPENGEODE)
og.pr
--toAda
$(ASN1SCC)
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
$(GNATMAKE)
-O
$(O)
-c
*
.adb
$(GNATBIND)
-n
og.ali
test-llvm
:
$(OPENGEODE)
og.pr
--llvm
-O
$(O)
$(LLC)
*
.ll
$(CC)
-O
$(O)
-c
*
.s
coverage
:
coverage run
-p
$(OPENGEODE)
og.pr
--toAda
.PHONY
:
all edit test-parse test-ada test-llvm coverage
tests/regression/test-standalone/dataview-uniq.asn
0 → 100644
View file @
a954c6cb
TASTE-Dataview DEFINITIONS ::=
BEGIN
MyChoice ::= CHOICE {
a CHOICE {
b CHOICE {
c BOOLEAN,
d BOOLEAN
},
e BOOLEAN
},
f BOOLEAN
}
Some-Thing ::= MyInteger
MyInteger ::= INTEGER (0..255)
My-OctStr ::= OCTET STRING (SIZE (0..20))
SeqOf ::= SEQUENCE (SIZE(0..100)) OF MyInteger
Type1 ::= INTEGER(0..1)
Type2 ::= BOOLEAN
Toto ::= SEQUENCE { elem-1 Type1, elem-2 Type2 }
SeqBool ::= SEQUENCE(SIZE(1..5)) OF BOOLEAN
default-seqof SeqOf ::= {4,7,9}
default-str My-OctStr ::= 'DEADBEEF'H
END
tests/regression/test-standalone/og.pr
0 → 100644
View file @
a954c6cb
SYSTEM og;
/* CIF TEXT (159, 221), (287, 158) */
-- Text area for declarations and comments
use dv comment 'dataview-uniq.asn';
--use dv2 comment 'dataview2.asn';
signal dd(Type2);
signal we;
/* CIF ENDTEXT */
CHANNEL c
FROM ENV TO og WITH dd;
FROM og TO ENV WITH we;
ENDCHANNEL;
BLOCK og;
SIGNALROUTE r
FROM ENV TO og WITH dd;
FROM og TO ENV WITH we;
CONNECT c AND r;
/* CIF PROCESS (225, 49), (150, 75) */
PROCESS og;
/* CIF TEXT (57, 58), (287, 140) */
-- Text area for declarations and comments
dcl haha SeqOf;
dcl hihi type2;
/* CIF ENDTEXT */
/* CIF START (155, 216), (70, 35) */
START;
/* CIF NEXTSTATE (155, 266), (70, 35) */
NEXTSTATE wait;
/* CIF STATE (296, 231), (70, 35) */
STATE wait;
/* CIF INPUT (289, 286), (84, 35) */
INPUT dd(hihi);
/* CIF NEXTSTATE (296, 336), (70, 35) */
NEXTSTATE wait;
ENDSTATE;
ENDPROCESS og;
ENDBLOCK;
ENDSYSTEM;
\ No newline at end of file
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