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
0def3517
Commit
0def3517
authored
Oct 03, 2015
by
Maxime Perrotin
Browse files
Accept numerical types with MIN/MAX
parent
8ef2596a
Changes
1
Hide whitespace changes
Inline
Side-by-side
opengeode/ogParser.py
View file @
0def3517
...
...
@@ -777,13 +777,20 @@ def check_type_compatibility(primary, type_ref, context):
if
basic_type
.
kind
==
'StandardStringType'
:
return
elif
basic_type
.
kind
.
endswith
(
'StringType'
):
if
int
(
basic_type
.
Min
)
<=
len
(
primary
.
value
[
1
:
-
1
])
<=
int
(
basic_type
.
Max
):
try
:
if
int
(
basic_type
.
Min
)
<=
len
(
primary
.
value
[
1
:
-
1
])
<=
int
(
basic_type
.
Max
):
return
else
:
raise
TypeError
(
'Invalid string literal'
' - check that length is'
'within the bound limits {Min}..{Max}'
.
format
(
Min
=
str
(
basic_type
.
Min
),
Max
=
str
(
basic_type
.
Max
)))
except
ValueError
:
# No size constraint (or MIN/MAX)
LOG
.
debug
(
'String literal size constraint discarded'
)
return
else
:
raise
TypeError
(
'Invalid string literal - check that length is'
'within the bound limits {Min}..{Max}'
.
format
(
Min
=
str
(
basic_type
.
Min
),
Max
=
str
(
basic_type
.
Max
)))
else
:
raise
TypeError
(
'String literal not expected'
)
elif
(
isinstance
(
primary
,
ogAST
.
PrimMantissaBaseExp
)
and
...
...
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