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
9d05f204
Commit
9d05f204
authored
May 02, 2017
by
Maxime Perrotin
Browse files
Start working on Append constructs
parent
6e273ea2
Changes
3
Hide whitespace changes
Inline
Side-by-side
opengeode/ogParser.py
View file @
9d05f204
...
...
@@ -666,7 +666,7 @@ def check_type_compatibility(primary, type_ref, context): # type: -> [warnings]
'''
Check if an ogAST.Primary (raw value, enumerated, ASN.1 Value...)
is compatible with a given type (type_ref is an ASN1Scc type)
Does not
return a
nything if OK, otherwise
raises TypeError
Possibly
return
s
a
list of warnings; can
raises TypeError
'''
warnings
=
[]
# function returns a list of warnings
assert
type_ref
is
not
None
...
...
@@ -749,9 +749,10 @@ def check_type_compatibility(primary, type_ref, context): # type: -> [warnings]
if
type_ref
.
__name__
!=
'Apnd'
and
\
(
len
(
primary
.
value
)
<
int
(
basic_type
.
Min
)
or
len
(
primary
.
value
)
>
int
(
basic_type
.
Max
)):
#print traceback.print_stack()
raise
TypeError
(
str
(
len
(
primary
.
value
))
+
' element
s
in SEQUENCE OF, while constraint is ['
+
str
(
basic_type
.
Min
)
+
'..'
+
str
(
basic_type
.
Max
)
+
']'
)
' element
(s)
in SEQUENCE OF, while constraint is ['
+
str
(
basic_type
.
Min
)
+
'
..
'
+
str
(
basic_type
.
Max
)
+
']'
)
for
elem
in
primary
.
value
:
warnings
.
extend
(
check_type_compatibility
(
elem
,
basic_type
.
type
,
...
...
@@ -1039,7 +1040,7 @@ def fix_expression_types(expr, context): # type: -> [warnings]
# the type of the raw PrimSequenceOf can be set now
value
.
exprType
.
type
=
asn_type
if
isinstance
(
expr
,
ogAST
.
ExprIn
):
if
isinstance
(
expr
,
(
ogAST
.
ExprIn
,
ogAST
.
ExprAppend
)
):
return
warnings
if
not
expr
.
right
.
is_raw
and
not
expr
.
left
.
is_raw
:
...
...
@@ -1438,6 +1439,13 @@ def append_expression(root, context):
left
=
find_basic_type
(
expr
.
left
.
exprType
)
right
=
find_basic_type
(
expr
.
right
.
exprType
)
# check that the appended value is of the right type
# TODO : need a complete analysis just like the in_expression above
# try:
# warnings.extend(compare_types(expr.right.exprType, ref_type))
# except TypeError as err:
# errors.append(error(root, str(err)))
for
bty
in
(
left
,
right
):
if
bty
.
kind
!=
'SequenceOfType'
and
not
is_string
(
bty
):
msg
=
'Append can only be applied to types SequenceOf or String'
...
...
tests/regression/test-sequenceof2/dataview.asn
View file @
9d05f204
TASTE-Dataview DEFINITIONS ::=
BEGIN
MySeqOf ::= SEQUENCE (SIZE (
1
..10)) OF BOOLEAN
MySeqOf ::= SEQUENCE (SIZE (
3
..10)) OF BOOLEAN
MyBoolean ::= BOOLEAN
...
...
tests/regression/test-sequenceof2/test.pr
View file @
9d05f204
...
...
@@ -20,11 +20,11 @@ system test;
/* CIF ENDTEXT */
/* CIF START (198, 56), (70, 35) */
START;
/* CIF task (13
3
, 111), (
199
, 35) */
/* CIF task (13
2
, 111), (
201
, 35) */
task s2 := { true, true, false, true };
/* CIF PROCEDURECALL (157, 161), (152, 35) */
call writeln ( length (s1) )
/* CIF comment (329, 161), (18
8
, 35) */
/* CIF comment (329, 161), (18
9
, 35) */
comment 'Uninitialized => will return 0';
/* CIF task (183, 216), (99, 35) */
task s1 := s2 (1,3)
...
...
@@ -33,7 +33,7 @@ system test;
s1 (1, 3) := { true, false, true} provokes a bug';
/* CIF PROCEDURECALL (157, 271), (152, 35) */
call writeln ( length (s1) );
/* CIF task (1
70
, 326), (1
2
6, 35) */
/* CIF task (1
49
, 326), (16
7
, 35) */
task s1 := s1 // { false };
/* CIF PROCEDURECALL (157, 381), (152, 35) */
call writeln ( length (s1) );
...
...
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