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
8e692deb
Commit
8e692deb
authored
Jun 20, 2014
by
Maxime Perrotin
Browse files
Added check that all numerical types have a range constraint ; fixed
test13 accordingly
parent
f5de6350
Changes
2
Hide whitespace changes
Inline
Side-by-side
ogParser.py
View file @
8e692deb
...
...
@@ -441,7 +441,7 @@ def check_range(typeref, type_to_check):
'outside expected range [{}..{}]'
.
format
(
type_to_check
.
Min
,
type_to_check
.
Max
,
typeref
.
Min
,
typeref
.
Max
))
except
AttributeError
:
except
(
AttributeError
,
ValueError
)
:
raise
TypeError
(
'Missing range'
)
...
...
@@ -1299,25 +1299,29 @@ def expression(root, context):
basic
=
find_basic_type
(
expr
.
left
.
exprType
)
left
=
find_basic_type
(
expr
.
left
.
exprType
)
right
=
find_basic_type
(
expr
.
right
.
exprType
)
if
isinstance
(
expr
,
ogAST
.
ExprPlus
):
attrs
=
{
'Min'
:
str
(
float
(
left
.
Min
)
+
float
(
right
.
Min
)),
'Max'
:
str
(
float
(
left
.
Max
)
+
float
(
right
.
Max
))}
expr
.
exprType
=
type
(
'Plus'
,
(
basic
,),
attrs
)
elif
isinstance
(
expr
,
ogAST
.
ExprMul
):
attrs
=
{
'Min'
:
str
(
float
(
left
.
Min
)
*
float
(
right
.
Min
)),
'Max'
:
str
(
float
(
left
.
Max
)
*
float
(
right
.
Max
))}
expr
.
exprType
=
type
(
'Mul'
,
(
basic
,),
attrs
)
elif
isinstance
(
expr
,
ogAST
.
ExprMinus
):
attrs
=
{
'Min'
:
str
(
float
(
left
.
Min
)
-
float
(
right
.
Min
)),
'Max'
:
str
(
float
(
left
.
Max
)
-
float
(
right
.
Max
))}
expr
.
exprType
=
type
(
'Minus'
,
(
basic
,),
attrs
)
elif
isinstance
(
expr
,
ogAST
.
ExprDiv
):
attrs
=
{
'Min'
:
str
(
float
(
left
.
Min
)
/
float
(
right
.
Min
)),
'Max'
:
str
(
float
(
left
.
Max
)
/
float
(
right
.
Max
))}
expr
.
exprType
=
type
(
'Div'
,
(
basic
,),
attrs
)
elif
isinstance
(
expr
,
(
ogAST
.
ExprMod
,
ogAST
.
ExprRem
)):
attrs
=
{
'Min'
:
right
.
Min
,
'Max'
:
right
.
Max
}
expr
.
exprType
=
type
(
'Mod'
,
(
basic
,),
attrs
)
try
:
if
isinstance
(
expr
,
ogAST
.
ExprPlus
):
attrs
=
{
'Min'
:
str
(
float
(
left
.
Min
)
+
float
(
right
.
Min
)),
'Max'
:
str
(
float
(
left
.
Max
)
+
float
(
right
.
Max
))}
expr
.
exprType
=
type
(
'Plus'
,
(
basic
,),
attrs
)
elif
isinstance
(
expr
,
ogAST
.
ExprMul
):
attrs
=
{
'Min'
:
str
(
float
(
left
.
Min
)
*
float
(
right
.
Min
)),
'Max'
:
str
(
float
(
left
.
Max
)
*
float
(
right
.
Max
))}
expr
.
exprType
=
type
(
'Mul'
,
(
basic
,),
attrs
)
elif
isinstance
(
expr
,
ogAST
.
ExprMinus
):
attrs
=
{
'Min'
:
str
(
float
(
left
.
Min
)
-
float
(
right
.
Min
)),
'Max'
:
str
(
float
(
left
.
Max
)
-
float
(
right
.
Max
))}
expr
.
exprType
=
type
(
'Minus'
,
(
basic
,),
attrs
)
elif
isinstance
(
expr
,
ogAST
.
ExprDiv
):
attrs
=
{
'Min'
:
str
(
float
(
left
.
Min
)
/
float
(
right
.
Min
)),
'Max'
:
str
(
float
(
left
.
Max
)
/
float
(
right
.
Max
))}
expr
.
exprType
=
type
(
'Div'
,
(
basic
,),
attrs
)
elif
isinstance
(
expr
,
(
ogAST
.
ExprMod
,
ogAST
.
ExprRem
)):
attrs
=
{
'Min'
:
right
.
Min
,
'Max'
:
right
.
Max
}
expr
.
exprType
=
type
(
'Mod'
,
(
basic
,),
attrs
)
except
ValueError
:
errors
.
append
(
'Check that all your numerical data types have '
'a range constraint'
)
elif
root
.
type
in
(
lexer
.
OR
,
lexer
.
AND
,
lexer
.
XOR
):
...
...
tests/regression/test13/dataview-uniq.asn
View file @
8e692deb
TASTE-Dataview DEFINITIONS ::=
BEGIN
Int ::= INTEGER
Int ::= INTEGER
(-1000..1000)
Bool ::= BOOLEAN
Float ::= REAL
Float ::= REAL
(-10000.0..10000.0)
END
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