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
8d030c7b
Commit
8d030c7b
authored
Oct 30, 2014
by
Maxime Perrotin
Browse files
Fix case sensitivity check in enumerations
parent
41299ab0
Changes
4
Hide whitespace changes
Inline
Side-by-side
ogParser.py
View file @
8d030c7b
...
@@ -627,10 +627,11 @@ def check_type_compatibility(primary, type_ref, context):
...
@@ -627,10 +627,11 @@ def check_type_compatibility(primary, type_ref, context):
# If type ref is an enumeration, check that the value is valid
# If type ref is an enumeration, check that the value is valid
# Note, when using the "present" operator of a CHOICE type, the
# Note, when using the "present" operator of a CHOICE type, the
# resulting value is actually an EnumeratedType
# resulting value is actually an EnumeratedType
enumerant
=
primary
.
inputString
.
replace
(
'_'
,
'-'
)
enumerant
=
primary
.
inputString
.
replace
(
'_'
,
'-'
).
lower
()
corr_type
=
basic_type
.
EnumValues
.
get
(
enumerant
)
for
each
in
basic_type
.
EnumValues
.
keys
():
if
corr_type
:
if
each
.
lower
()
==
enumerant
:
return
# Found -> all OK
return
else
:
else
:
err
=
(
'Value "'
+
primary
.
inputString
+
err
=
(
'Value "'
+
primary
.
inputString
+
'" not in this enumeration: '
+
'" not in this enumeration: '
+
...
@@ -3110,8 +3111,7 @@ def alternative_part(root, parent, context):
...
@@ -3110,8 +3111,7 @@ def alternative_part(root, parent, context):
ans
.
closedRange
=
[
cl0
,
cl1
]
ans
.
closedRange
=
[
cl0
,
cl1
]
elif
child
.
type
==
lexer
.
CONSTANT
:
elif
child
.
type
==
lexer
.
CONSTANT
:
ans
.
kind
=
'constant'
ans
.
kind
=
'constant'
ans
.
constant
,
err
,
warn
=
expression
(
ans
.
constant
,
err
,
warn
=
expression
(
child
.
getChild
(
0
),
context
)
child
.
getChild
(
0
),
context
)
errors
.
extend
(
err
)
errors
.
extend
(
err
)
warnings
.
extend
(
warn
)
warnings
.
extend
(
warn
)
ans
.
openRangeOp
=
ogAST
.
ExprEq
ans
.
openRangeOp
=
ogAST
.
ExprEq
...
@@ -3287,7 +3287,8 @@ def decision(root, parent, context):
...
@@ -3287,7 +3287,8 @@ def decision(root, parent, context):
ans
.
inputString
),
ans
.
inputString
),
[
ans_x
,
ans_y
],
[]])
[
ans_x
,
ans_y
],
[]])
else
:
else
:
warnings
.
append
(
'Unsupported range expression'
)
warnings
.
append
([
'Unsupported range expression'
,
[
ans_x
,
ans_y
],
[]])
if
not
reachable
:
if
not
reachable
:
warnings
.
append
([
'Decision "{}": '
warnings
.
append
([
'Decision "{}": '
'Unreachable branch "{}"'
'Unreachable branch "{}"'
...
@@ -3414,14 +3415,18 @@ def decision(root, parent, context):
...
@@ -3414,14 +3415,18 @@ def decision(root, parent, context):
# (5) check coverage of enumerated types
# (5) check coverage of enumerated types
if
is_enum
:
if
is_enum
:
# check duplicate answers
# check duplicate answers
answers
=
list
(
chain
.
from_iterable
(
covered_ranges
.
viewvalues
()))
answers
=
[
a
.
lower
()
for
a
in
chain
.
from_iterable
(
covered_ranges
.
viewvalues
())]
dupl
=
[
a
for
a
,
v
in
Counter
(
answers
).
items
()
if
v
>
1
]
dupl
=
[
a
for
a
,
v
in
Counter
(
answers
).
items
()
if
v
>
1
]
if
dupl
:
if
dupl
:
qerr
.
append
(
'Decision "{}": duplicate answers "{}"'
qerr
.
append
(
'Decision "{}": duplicate answers "{}"'
.
format
(
dec
.
inputString
,
'", "'
.
join
(
dupl
)))
.
format
(
dec
.
inputString
,
'", "'
.
join
(
dupl
)))
enumerants
=
[
en
.
replace
(
'-'
,
'_'
)
for
en
in
q_basic
.
EnumValues
.
keys
()]
enumerants
=
[
en
.
replace
(
'-'
,
'_'
).
lower
()
for
en
in
q_basic
.
EnumValues
.
keys
()]
# check for missing answers
# check for missing answers
if
set
(
answers
)
!=
set
(
enumerants
)
and
not
has_else
:
if
set
(
answers
)
!=
set
(
enumerants
)
and
not
has_else
:
print
set
(
answers
)
print
set
(
enumerants
)
qerr
.
append
(
'Decision "{}": Missing branches for answer(s) "{}"'
qerr
.
append
(
'Decision "{}": Missing branches for answer(s) "{}"'
.
format
(
dec
.
inputString
,
.
format
(
dec
.
inputString
,
'", "'
.
join
(
set
(
enumerants
)
-
set
(
answers
))))
'", "'
.
join
(
set
(
enumerants
)
-
set
(
answers
))))
...
...
sdlSymbols.py
View file @
8d030c7b
...
@@ -861,7 +861,7 @@ class ASN1Viewer(TextSymbol):
...
@@ -861,7 +861,7 @@ class ASN1Viewer(TextSymbol):
blackbold
=
[
'
\\
b{}
\\
b'
.
format
(
word
)
for
word
in
(
blackbold
=
[
'
\\
b{}
\\
b'
.
format
(
word
)
for
word
in
(
'DEFINITIONS'
,
'AUTOMATIC'
,
'TAGS'
,
'BEGIN'
,
'END'
,
'INTEGER'
,
'DEFINITIONS'
,
'AUTOMATIC'
,
'TAGS'
,
'BEGIN'
,
'END'
,
'INTEGER'
,
'OCTET'
,
'STRING'
,
'BIT'
,
'REAL'
,
'SEQUENCE'
,
'OF'
,
'WITH'
,
'OCTET'
,
'STRING'
,
'BIT'
,
'REAL'
,
'SEQUENCE'
,
'OF'
,
'WITH'
,
'IMPORTS'
,
'FROM'
,
'SIZE'
,
'CHOICE'
,
'BOOLEAN'
)]
'IMPORTS'
,
'FROM'
,
'SIZE'
,
'CHOICE'
,
'BOOLEAN'
,
'ENUMERATED'
)]
# pylint: disable=R0904
# pylint: disable=R0904
...
...
tests/regression/test-debug/dataview-uniq.asn
View file @
8d030c7b
...
@@ -13,7 +13,8 @@ SeqBoolFix ::= SEQUENCE (SIZE(2)) OF BOOLEAN
...
@@ -13,7 +13,8 @@ SeqBoolFix ::= SEQUENCE (SIZE(2)) OF BOOLEAN
SeqEnum ::= SEQUENCE (SIZE(1..5)) OF ENUMERATED { hello, world }
SeqEnum ::= SEQUENCE (SIZE(1..5)) OF ENUMERATED { hello, world }
SeqEnumFix ::= SEQUENCE (SIZE(2)) OF ENUMERATED { hello, world }
SeqEnumFix ::= SEQUENCE (SIZE(2)) OF ENUMERATED { hello, world }
Enum ::= ENUMERATED {a, b, c, d}
Enum ::= ENUMERATED {a, b, c, d, eE}
Choice ::= CHOICE {c1 BOOLEAN, cDe2 BOOLEAN}
END
END
...
...
tests/regression/test-debug/orchestrator.pr
View file @
8d030c7b
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
PROCESS orchestrator
PROCESS orchestrator
/* CIF COMMENT (405, 192), (71, 35) */
/* CIF COMMENT (405, 192), (71, 35) */
COMMENT 'Hello';
COMMENT 'Hello';
/* CIF TEXT (39, 94), (293, 2
3
3) */
/* CIF TEXT (39, 94), (293, 2
6
3) */
dcl seq tastE_Peek_id_list;
dcl seq tastE_Peek_id_list;
dcl fixed FixedString := 'Hello';
dcl fixed FixedString := 'Hello';
...
@@ -18,6 +18,8 @@ dcl seqen2 SeqEnumFix := { hello, world };
...
@@ -18,6 +18,8 @@ dcl seqen2 SeqEnumFix := { hello, world };
dcl myenum Enum := a;
dcl myenum Enum := a;
dcl check tasTE_Peek_id;
dcl check tasTE_Peek_id;
dcl choice choice;
/* CIF ENDTEXT */
/* CIF ENDTEXT */
/* CIF START (428, 223), (100, 45) */
/* CIF START (428, 223), (100, 45) */
START;
START;
...
@@ -67,7 +69,31 @@ endfor;
...
@@ -67,7 +69,31 @@ endfor;
/* CIF ANSWER (488, 1081), (70, 23) */
/* CIF ANSWER (488, 1081), (70, 23) */
('b'):
('b'):
ENDDECISION;
ENDDECISION;
/* CIF NEXTSTATE (419, 1119), (118, 50) */
/* CIF DECISION (433, 1119), (89, 50) */
DECISION myenum
/* CIF COMMENT (542, 1126), (183, 35) */
COMMENT 'Check case insensitivity';
/* CIF ANSWER (250, 1189), (70, 23) */
(a):
/* CIF ANSWER (330, 1189), (70, 23) */
(B):
/* CIF ANSWER (410, 1189), (70, 23) */
(c):
/* CIF ANSWER (488, 1189), (70, 23) */
(d):
/* CIF ANSWER (576, 1189), (70, 23) */
(Ee):
ENDDECISION;
/* CIF DECISION (408, 1227), (138, 50) */
DECISION present(choice)
/* CIF COMMENT (566, 1234), (183, 35) */
COMMENT 'Check case insensitivity';
/* CIF ANSWER (361, 1297), (70, 23) */
(cde2):
/* CIF ANSWER (532, 1297), (70, 23) */
ELSE:
ENDDECISION;
/* CIF NEXTSTATE (419, 1335), (116, 33) */
NEXTSTATE Wait_for_GUI;
NEXTSTATE Wait_for_GUI;
/* CIF STATE (423, 163), (118, 50) */
/* CIF STATE (423, 163), (118, 50) */
STATE Wait_for_GUI;
STATE Wait_for_GUI;
...
...
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