Commit 03248704 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Support "nextstate via entrypoint" followed by inputs

parent facba563
......@@ -180,10 +180,11 @@ def _state(ast, scene, states, terminators, parent=None):
# state in that case: it will be rendered together with all its (possible)
# INPUT children in the render_terminator function.
for term in terminators:
state_label = ast.via or ast.inputString
if(term.kind == 'next_state' and
term.pos_x == ast.pos_x and
term.pos_y == ast.pos_y and
term.inputString == ast.inputString):
term.inputString == state_label):
raise TypeError('This state is a terminator')
new_state = sdlSymbols.State(parent=None, ast=ast)
if new_state not in scene.items():
......@@ -345,7 +346,8 @@ def _terminator(ast, scene, parent, states):
symbol = sdlSymbols.State(parent=parent, ast=ast)
# If the terminator is also a new state, render the inputs below
for state_ast in states:
if (state_ast.inputString == ast.inputString and
state_label = state_ast.via or state_ast.inputString
if (state_label == ast.inputString and
state_ast.pos_x == ast.pos_x and
state_ast.pos_y == ast.pos_y):
symbol.nested_scene = state_ast.composite or \
......
......@@ -3733,6 +3733,7 @@ def state(root, parent, context):
asterisk_state = False
asterisk_input = None
st_x, st_y = 0, 0
via_stop = None
for child in root.getChildren():
if isinstance(child, antlr3.tree.CommonErrorNode):
# There was a parsing error
......@@ -3749,6 +3750,7 @@ def state(root, parent, context):
state_def.charPositionInLine = child.getCharPositionInLine()
for statename in child.getChildren():
state_def.statelist.append(statename.toString())
via_stop = child.getTokenStopIndex()
elif child.type == lexer.ASTERISK:
asterisk_state = True
state_def.inputString = get_input_string(child)
......@@ -3845,10 +3847,10 @@ def state(root, parent, context):
errors.extend(err)
elif child.type == lexer.VIA:
# case of a state to be merged with a NEXTSTATE having a via clause
# stopped HERE: have to extract the string "statename via blah"
# to make sure it matches the NEXTSTATE
print ("state via:", get_input_string(root))
state_def.via = child.getChild(0).text
# in the via field we keep "state via entrypoint"
start = via_stop
stop = child.getTokenStopIndex()
state_def.via = token_stream(root).toString(start, stop)
elif child.type == 0:
# Parser error, already caught
pass
......@@ -5320,7 +5322,7 @@ def parseSingleElement(elem='', string='', context=None):
# syntax_errors.append(w.strip())
# Get the root of the Antlr-AST to build our own AST entry
root = r.tree
print (isinstance(tree, antlr3.tree.CommonErrorNode))
#print (isinstance(tree, antlr3.tree.CommonErrorNode))
root.token_stream = parser.getTokenStream()
backend_ptr = eval(elem)
try:
......
# $ANTLR 3.5.2 sdl92.g 2020-01-16 12:43:34
# $ANTLR 3.5.2 sdl92.g 2020-01-17 13:43:15
import sys
from antlr3 import *
......
# $ANTLR 3.5.2 sdl92.g 2020-01-16 12:43:34
# $ANTLR 3.5.2 sdl92.g 2020-01-17 13:43:14
 
import sys
from antlr3 import *
Markdown is supported
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