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
c7e2d31d
Commit
c7e2d31d
authored
Oct 21, 2015
by
Maxime Perrotin
Browse files
Implement History nextstate for aggregations
parent
1c30910c
Changes
3
Hide whitespace changes
Inline
Side-by-side
opengeode/AdaGenerator.py
View file @
c7e2d31d
...
...
@@ -1953,7 +1953,8 @@ def _transition(tr, **kwargs):
code
.
append
(
'<<{label}>>'
.
format
(
label
=
tr
.
terminator
.
label
.
inputString
))
if
tr
.
terminator
.
kind
==
'next_state'
:
if
tr
.
terminator
.
next_is_aggregation
:
# XXX add to C generator
history
=
tr
.
terminator
.
inputString
.
strip
()
==
'-'
if
tr
.
terminator
.
next_is_aggregation
and
not
history
:
# XXX add to C generator
code
.
append
(
u
'-- Entering state aggregation {}'
.
format
(
tr
.
terminator
.
inputString
))
# Call the START function of the state aggregation
...
...
@@ -1962,7 +1963,7 @@ def _transition(tr, **kwargs):
.
format
(
ctxt
=
LPREFIX
,
nextState
=
tr
.
terminator
.
inputString
))
code
.
append
(
u
'trId := -1;'
)
elif
tr
.
terminator
.
inputString
.
strip
()
!=
'-'
:
elif
not
history
:
#
tr.terminator.inputString.strip() != '-':
code
.
append
(
u
'trId := '
+
unicode
(
tr
.
terminator
.
next_id
)
+
u
';'
)
if
tr
.
terminator
.
next_id
==
-
1
:
...
...
@@ -1985,16 +1986,14 @@ def _transition(tr, **kwargs):
if
next_id
!=
-
1
):
code
.
append
(
'case {}.state is'
.
format
(
LPREFIX
))
for
nid
,
sta
in
tr
.
terminator
.
candidate_id
.
viewitems
():
print
nid
.
encode
(
'utf-8'
),
sta
if
nid
!=
-
1
:
#if any(each for each in sta
# if each in parallel_states):
# pass
#else:
#for each in sta:
if
tr
.
terminator
.
next_is_aggregation
:
statement
=
u
'{};'
.
format
(
nid
)
else
:
statement
=
u
'tdId := {};'
.
format
(
nid
)
code
.
extend
([
u
'when {} =>'
.
format
(
u
'|'
.
join
(
sta
)),
u
'trId := {};'
.
format
(
nid
)
])
statement
])
code
.
extend
([
'when others =>'
,
'trId := -1;'
,
...
...
opengeode/Helper.py
View file @
c7e2d31d
...
...
@@ -140,16 +140,20 @@ def flatten(process, sep=u'_'):
term
.
next_id
=
u
'{term}{sep}{entry}_START'
.
format
(
term
=
term
.
inputString
,
entry
=
term
.
entrypoint
,
sep
=
sep
)
elif
term
.
inputString
.
strip
()
==
'-'
:
term
.
candidate_id
=
defaultdict
(
list
)
#
term.candidate_id = defaultdict(list)
for
each
in
term
.
possible_states
:
if
each
.
lower
()
in
(
st
.
statename
.
lower
()
for
st
in
context
.
composite_states
):
term
.
candidate_id
[
each
+
sep
+
u
'START'
]
=
\
term
.
candidate_id
[
-
1
].
append
(
each
)
for
comp
in
context
.
composite_states
:
if
each
.
lower
()
==
comp
.
statename
.
lower
():
if
isinstance
(
comp
,
ogAST
.
StateAggregation
):
term
.
next_is_aggregation
=
True
term
.
candidate_id
[
each
+
sep
+
u
'START'
]
=
[
each
]
else
:
term
.
candidate_id
[
each
+
sep
+
u
'START'
]
=
\
[
st
for
st
in
process
.
mapping
.
viewkeys
()
if
st
.
startswith
(
each
)
and
not
st
.
endswith
(
u
'START'
)]
else
:
term
.
candidate_id
[
-
1
].
append
(
each
)
continue
def
update_composite_state
(
state
,
process
):
''' Rename inner states, recursively, and add inner transitions
...
...
opengeode/ogAST.py
View file @
c7e2d31d
...
...
@@ -35,6 +35,7 @@
"""
import
logging
from
collections
import
defaultdict
LOG
=
logging
.
getLogger
(
__name__
)
...
...
@@ -468,6 +469,12 @@ class Terminator(object):
# If this terminator is within a state aggregation, store the name
# of the parallel substate (set by Helper.state_aggregations)
self
.
substate
=
''
# candidate_id: {transition_id: [states]}
# field is set by Helper.py/flatten, in case of "nextstate -"
# there is a list of states that set transition_id to -1 : the standard
# states ; and there are the composite states, that set a different
# id corresponding to the start transition of the state.
self
.
candidate_id
=
defaultdict
(
list
)
def
trace
(
self
):
''' Debug output for terminators '''
...
...
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