Commit 3745cd22 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Semantic check when entering a composite state

parent e3c5d1b0
......@@ -2814,7 +2814,8 @@ def decision(root, parent, context):
def nextstate(root, context):
''' Parse a NEXTSTATE [VIA State_Entry_Point] '''
''' Parse a NEXTSTATE [VIA State_Entry_Point] - detect various kinds of
errors when trying to enter a nested state '''
next_state_id, via, entrypoint = '', None, None
errors = []
for child in root.getChildren():
......@@ -2849,6 +2850,16 @@ def nextstate(root, context):
errors.append('"History" NEXTSTATE cannot have a "via" clause')
errors.append('NEXTSTATE undefined construct')
if not via:
# check that if the nextstate is nested, it has a START symbol
composite, = (comp for comp in context.composite_states
if comp.statename.lower() == next_state_id.lower())
if not composite.content.start:
errors.append('Composite state "{}" has no unnamed '
'START symbol'.format(composite.statename))
except ValueError:
return next_state_id, via, entrypoint, errors
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment