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
af323a3a
Commit
af323a3a
authored
Jul 21, 2020
by
Maxime Perrotin
Browse files
Fix issue with the "present" operator
parent
c407f7fb
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
af323a3a
...
@@ -175,6 +175,9 @@ The background pattern was downloaded from www.subtlepatterns.com
...
@@ -175,6 +175,9 @@ The background pattern was downloaded from www.subtlepatterns.com
Changelog
Changelog
=========
=========
**3.2.1 (07/2020)**
-
Fix issue with the "present" operator
**3.2.0 (07/2020)**
**3.2.0 (07/2020)**
-
Add basic support for state type/instance
-
Add basic support for state type/instance
...
...
opengeode/ogParser.py
View file @
af323a3a
...
@@ -703,6 +703,9 @@ def check_call(name, params, context):
...
@@ -703,6 +703,9 @@ def check_call(name, params, context):
# check that the list of enumerants are identical. unfortunately we
# check that the list of enumerants are identical. unfortunately we
# cannot check the ordering, as it is an unordered dict
# cannot check the ordering, as it is an unordered dict
if
name
==
'to_selector'
:
if
name
==
'to_selector'
:
# if the sort is a subtype, it may not have a -selection suffix
# and an exception may be raised. FIXME : check "present" operator
# as the issue is already fixed there
return_type
=
types
()[
sort
+
'-selection'
].
type
return_type
=
types
()[
sort
+
'-selection'
].
type
else
:
else
:
return_type
=
types
()[
sort
].
type
return_type
=
types
()[
sort
].
type
...
@@ -828,8 +831,21 @@ def check_call(name, params, context):
...
@@ -828,8 +831,21 @@ def check_call(name, params, context):
elif
name
==
'present'
:
elif
name
==
'present'
:
p
,
=
params
p
,
=
params
sort
=
type_name
(
p
.
exprType
)
+
"-selection"
# When we get there, the parameter has been checked already and we
return
types
()[
sort
].
type
# know it is a CHOICE type.
# However it may be a subtype, and in the AST the choices are defined
# in the supertype, so we must find it and and the -selection suffix
# This suffix is added by the Asn1scc module.
sort
=
p
.
exprType
sort_name
=
type_name
(
sort
)
try
:
while
sort
.
kind
==
"ReferenceType"
:
sort_name
=
sort
.
ReferencedTypeName
sort
=
types
()[
sort
.
ReferencedTypeName
].
type
except
AttributeError
:
# Native choice types don't have the kind field here
pass
return
types
()[
sort_name
+
"-selection"
].
type
# choice_to_int: returns an integer corresponding to either the currently
# choice_to_int: returns an integer corresponding to either the currently
# selected choice value (e.g. foo in CHOICE { foo INTEGER (..), ... } when
# selected choice value (e.g. foo in CHOICE { foo INTEGER (..), ... } when
...
@@ -3862,9 +3878,8 @@ def state(root, parent, context):
...
@@ -3862,9 +3878,8 @@ def state(root, parent, context):
# Extract the complete string "state: instance"
# Extract the complete string "state: instance"
start
=
inst_stop
start
=
inst_stop
stop
=
child
.
getTokenStopIndex
()
stop
=
child
.
getTokenStopIndex
()
full_string
=
token_stream
(
root
).
toString
(
start
,
stop
)
state_def
.
inputString
=
token_stream
(
root
).
toString
(
start
,
stop
)
state_def
.
inputString
,
state_def
.
instance_of
=
\
state_def
.
instance_of
=
child
.
getChild
(
0
).
toString
()
full_string
,
state_def
.
instance_of
elif
child
.
type
==
lexer
.
STATELIST
:
elif
child
.
type
==
lexer
.
STATELIST
:
# State name(state_def)
# State name(state_def)
state_def
.
inputString
=
get_input_string
(
child
)
state_def
.
inputString
=
get_input_string
(
child
)
...
@@ -3912,7 +3927,12 @@ def state(root, parent, context):
...
@@ -3912,7 +3927,12 @@ def state(root, parent, context):
'in substate "{}"'
'in substate "{}"'
.
format
(
each
,
comp
.
statename
.
lower
()))
.
format
(
each
,
comp
.
statename
.
lower
()))
try
:
try
:
for
statename
in
state_def
.
statelist
:
# Use the statelist unless the state is an instance
if
not
state_def
.
instance_of
:
statelist
=
state_def
.
statelist
else
:
statelist
=
[
state_def
.
instance_of
]
for
statename
in
statelist
:
# check that input is not already defined
# check that input is not already defined
existing
=
context
.
mapping
.
get
(
statename
.
lower
(),
[])
existing
=
context
.
mapping
.
get
(
statename
.
lower
(),
[])
dupl
=
set
()
dupl
=
set
()
...
@@ -3928,7 +3948,10 @@ def state(root, parent, context):
...
@@ -3928,7 +3948,10 @@ def state(root, parent, context):
# then update the mapping state-input
# then update the mapping state-input
context
.
mapping
[
statename
.
lower
()].
append
(
inp
)
context
.
mapping
[
statename
.
lower
()].
append
(
inp
)
except
KeyError
as
err
:
except
KeyError
as
err
:
stwarn
.
append
(
f
'State definition missing -
{
str
(
err
)
}
'
)
# missing state definition is caught at other places, no
# need to report here
pass
#stwarn.append(f'State definition missing - {str(err)}')
state_def
.
inputs
.
append
(
inp
)
state_def
.
inputs
.
append
(
inp
)
if
inp
.
inputString
.
strip
()
==
'*'
:
if
inp
.
inputString
.
strip
()
==
'*'
:
if
asterisk_input
:
if
asterisk_input
:
...
@@ -5453,6 +5476,18 @@ def parse_pr(files=None, string=None):
...
@@ -5453,6 +5476,18 @@ def parse_pr(files=None, string=None):
[
t_x
,
t_y
],
[
t_x
,
t_y
],
[
'PROCESS {}'
.
format
(
process
.
processName
)]])
[
'PROCESS {}'
.
format
(
process
.
processName
)]])
# TODO: do the same with JOIN/LABEL
# TODO: do the same with JOIN/LABEL
# Check that all floating state instances (foo:bar) have a correspoding
# nested state defined.
state_types
=
set
(
st
.
instance_of
.
lower
()
for
st
in
process
.
content
.
states
if
st
.
instance_of
)
comp_states
=
set
(
comp
.
statename
.
lower
()
for
comp
in
process
.
composite_states
)
for
missing
in
state_types
-
comp_states
:
errors
.
append
([
f
'Nested state definition missing :
{
missing
}
'
,
[
0
,
0
],
[
'PROCESS {}'
.
format
(
process
.
processName
)]])
return
og_ast
,
warnings
,
errors
return
og_ast
,
warnings
,
errors
...
...
opengeode/opengeode.py
View file @
af323a3a
...
@@ -140,7 +140,7 @@ except ImportError:
...
@@ -140,7 +140,7 @@ except ImportError:
__all__
=
[
'opengeode'
,
'SDL_Scene'
,
'SDL_View'
,
'parse'
]
__all__
=
[
'opengeode'
,
'SDL_Scene'
,
'SDL_View'
,
'parse'
]
__version__
=
'3.2.
0
'
__version__
=
'3.2.
1
'
if
hasattr
(
sys
,
'frozen'
):
if
hasattr
(
sys
,
'frozen'
):
# Detect if we are running on Windows (py2exe-generated)
# Detect if we are running on Windows (py2exe-generated)
...
@@ -2323,14 +2323,21 @@ clean:
...
@@ -2323,14 +2323,21 @@ clean:
pr_raw
=
Pr
.
parse_scene
(
scene
,
full_model
=
True
pr_raw
=
Pr
.
parse_scene
(
scene
,
full_model
=
True
if
not
self
.
readonly_pr
else
False
)
if
not
self
.
readonly_pr
else
False
)
pr_data
=
str
(
'
\n
'
.
join
(
pr_raw
))
pr_data
=
str
(
'
\n
'
.
join
(
pr_raw
))
if
pr_data
:
try
:
ast
,
warnings
,
errors
=
ogParser
.
parse_pr
(
files
=
self
.
readonly_pr
,
if
pr_data
:
string
=
pr_data
)
ast
,
warnings
,
errors
=
ogParser
.
parse_pr
(
scene
.
semantic_errors
=
True
if
errors
else
False
files
=
self
.
readonly_pr
,
log_errors
(
self
.
messages_window
,
errors
,
warnings
,
string
=
pr_data
)
clearfirst
=
False
)
scene
.
semantic_errors
=
True
if
errors
else
False
self
.
update_asn1_dock
.
emit
(
ast
)
log_errors
(
self
.
messages_window
,
errors
,
warnings
,
return
"Done"
clearfirst
=
False
)
self
.
update_asn1_dock
.
emit
(
ast
)
return
"Done"
except
Exception
as
err
:
self
.
messages_window
.
addItem
(
"Opengeode bug, PLEASE REPORT: "
+
str
(
err
))
LOG
.
debug
(
str
(
traceback
.
format_exc
()))
return
"Syntax Errors"
def
show_item
(
self
,
item
):
def
show_item
(
self
,
item
):
'''
'''
...
...
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