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

Parse simple stop conditions

parent f63eb47a
......@@ -2,7 +2,7 @@
 
# Resource object code
#
# Created: Fri Jan 23 17:47:05 2015
# Created: Mon Mar 9 21:42:24 2015
# by: The Resource Compiler for PySide (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!
......@@ -3908,6 +3908,19 @@ def label(root, parent, context=None):
return lab, errors, warnings
def stop_if(root, parent, context=None):
''' Parse a STOP IF expression - Return an expression
Can be used in simulators to cut off paths
** This is an extension of the SDL grammar **
'''
expr = root.getChild(0)
expr, errors, warnings = expression(expr, context)
expr.exprType = BOOLEAN
errors = [[e, [0, 0], []] for e in errors]
warnings = [[w, [0, 0], []] for w in warnings]
return expr, errors, warnings
def pr_file(root):
''' Complete PR model - can be made up from several files/strings '''
errors = []
......@@ -4065,7 +4078,7 @@ def parse_pr(files=None, string=None):
return og_ast, warnings, errors
def parseSingleElement(elem='', string=''):
def parseSingleElement(elem='', string='', context=None):
'''
Parse any symbol and return syntax error and AST entry
Used for on-the-fly checks when user edits text
......@@ -4075,7 +4088,7 @@ def parseSingleElement(elem='', string=''):
'terminator_statement', 'label', 'task', 'procedure_call', 'end',
'text_area', 'state', 'start', 'procedure', 'floating_label',
'connect_part', 'process_definition', 'proc_start', 'state_start',
'signalroute'))
'signalroute', 'stop_if'))
# Create a dummy context, needed to place context data
if elem == 'proc_start':
elem = 'start'
......@@ -4084,7 +4097,7 @@ def parseSingleElement(elem='', string=''):
elem = 'start'
context = ogAST.CompositeState()
else:
context = ogAST.Process()
context = context or ogAST.Process()
LOG.debug('Parsing string: ' + string + ' with elem ' + elem)
parser = parser_init(string=string)
parser_ptr = getattr(parser, elem)
......
This diff is collapsed.
This diff is collapsed.
......@@ -106,6 +106,7 @@ tokens {
STATELIST;
STIMULUS;
STOP;
STOPIF;
STRING;
STRUCT;
SYNONYM;
......@@ -1073,6 +1074,12 @@ use_asn1
-> ^(ASN1 STRING);
/* OpenGEODE specific: Boolean condition that can be used in simulators
*/
stop_if
: STOP IF expression
-> ^(STOPIF expression);
symbolname
: START
| INPUT
......
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