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
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):
...
@@ -1953,7 +1953,8 @@ def _transition(tr, **kwargs):
code
.
append
(
'<<{label}>>'
.
format
(
code
.
append
(
'<<{label}>>'
.
format
(
label
=
tr
.
terminator
.
label
.
inputString
))
label
=
tr
.
terminator
.
label
.
inputString
))
if
tr
.
terminator
.
kind
==
'next_state'
:
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 {}'
code
.
append
(
u
'-- Entering state aggregation {}'
.
format
(
tr
.
terminator
.
inputString
))
.
format
(
tr
.
terminator
.
inputString
))
# Call the START function of the state aggregation
# Call the START function of the state aggregation
...
@@ -1962,7 +1963,7 @@ def _transition(tr, **kwargs):
...
@@ -1962,7 +1963,7 @@ def _transition(tr, **kwargs):
.
format
(
ctxt
=
LPREFIX
,
.
format
(
ctxt
=
LPREFIX
,
nextState
=
tr
.
terminator
.
inputString
))
nextState
=
tr
.
terminator
.
inputString
))
code
.
append
(
u
'trId := -1;'
)
code
.
append
(
u
'trId := -1;'
)
elif
tr
.
terminator
.
inputString
.
strip
()
!=
'-'
:
elif
not
history
:
#
tr.terminator.inputString.strip() != '-':
code
.
append
(
u
'trId := '
+
code
.
append
(
u
'trId := '
+
unicode
(
tr
.
terminator
.
next_id
)
+
u
';'
)
unicode
(
tr
.
terminator
.
next_id
)
+
u
';'
)
if
tr
.
terminator
.
next_id
==
-
1
:
if
tr
.
terminator
.
next_id
==
-
1
:
...
@@ -1985,16 +1986,14 @@ def _transition(tr, **kwargs):
...
@@ -1985,16 +1986,14 @@ def _transition(tr, **kwargs):
if
next_id
!=
-
1
):
if
next_id
!=
-
1
):
code
.
append
(
'case {}.state is'
.
format
(
LPREFIX
))
code
.
append
(
'case {}.state is'
.
format
(
LPREFIX
))
for
nid
,
sta
in
tr
.
terminator
.
candidate_id
.
viewitems
():
for
nid
,
sta
in
tr
.
terminator
.
candidate_id
.
viewitems
():
print
nid
.
encode
(
'utf-8'
),
sta
if
nid
!=
-
1
:
if
nid
!=
-
1
:
#if any(each for each in sta
if
tr
.
terminator
.
next_is_aggregation
:
# if each in parallel_states):
statement
=
u
'{};'
.
format
(
nid
)
# pass
else
:
#else:
statement
=
u
'tdId := {};'
.
format
(
nid
)
#for each in sta:
code
.
extend
([
u
'when {} =>'
code
.
extend
([
u
'when {} =>'
.
format
(
u
'|'
.
join
(
sta
)),
.
format
(
u
'|'
.
join
(
sta
)),
u
'trId := {};'
.
format
(
nid
)
])
statement
])
code
.
extend
([
'when others =>'
,
code
.
extend
([
'when others =>'
,
'trId := -1;'
,
'trId := -1;'
,
...
...
opengeode/Helper.py
View file @
c7e2d31d
...
@@ -140,16 +140,20 @@ def flatten(process, sep=u'_'):
...
@@ -140,16 +140,20 @@ def flatten(process, sep=u'_'):
term
.
next_id
=
u
'{term}{sep}{entry}_START'
.
format
(
term
.
next_id
=
u
'{term}{sep}{entry}_START'
.
format
(
term
=
term
.
inputString
,
entry
=
term
.
entrypoint
,
sep
=
sep
)
term
=
term
.
inputString
,
entry
=
term
.
entrypoint
,
sep
=
sep
)
elif
term
.
inputString
.
strip
()
==
'-'
:
elif
term
.
inputString
.
strip
()
==
'-'
:
term
.
candidate_id
=
defaultdict
(
list
)
#
term.candidate_id = defaultdict(list)
for
each
in
term
.
possible_states
:
for
each
in
term
.
possible_states
:
if
each
.
lower
()
in
(
st
.
statename
.
lower
()
term
.
candidate_id
[
-
1
].
append
(
each
)
for
st
in
context
.
composite_states
):
for
comp
in
context
.
composite_states
:
term
.
candidate_id
[
each
+
sep
+
u
'START'
]
=
\
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
()
[
st
for
st
in
process
.
mapping
.
viewkeys
()
if
st
.
startswith
(
each
)
if
st
.
startswith
(
each
)
and
not
st
.
endswith
(
u
'START'
)]
and
not
st
.
endswith
(
u
'START'
)]
else
:
continue
term
.
candidate_id
[
-
1
].
append
(
each
)
def
update_composite_state
(
state
,
process
):
def
update_composite_state
(
state
,
process
):
''' Rename inner states, recursively, and add inner transitions
''' Rename inner states, recursively, and add inner transitions
...
...
opengeode/ogAST.py
View file @
c7e2d31d
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
"""
"""
import
logging
import
logging
from
collections
import
defaultdict
LOG
=
logging
.
getLogger
(
__name__
)
LOG
=
logging
.
getLogger
(
__name__
)
...
@@ -468,6 +469,12 @@ class Terminator(object):
...
@@ -468,6 +469,12 @@ class Terminator(object):
# If this terminator is within a state aggregation, store the name
# If this terminator is within a state aggregation, store the name
# of the parallel substate (set by Helper.state_aggregations)
# of the parallel substate (set by Helper.state_aggregations)
self
.
substate
=
''
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
):
def
trace
(
self
):
''' Debug output for terminators '''
''' Debug output for terminators '''
...
...
Write
Preview
Markdown
is supported
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