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)
......
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2015-01-23 17:47:08
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2015-03-09 21:42:26
import sys
from antlr3 import *
......@@ -10,222 +10,223 @@ HIDDEN = BaseRecognizer.HIDDEN
# token types
NUMBER_OF_INSTANCES=60
COMMENT2=210
MANTISSA=167
COMMENT2=211
MANTISSA=168
ROUTE=79
MOD=159
MOD=160
GROUND=44
PARAM=65
NOT=161
NOT=162
SEQOF=82
TEXTAREA_CONTENT=103
TEXTAREA_CONTENT=104
EOF=-1
ACTION=4
IMPORT=171
CREATE=148
IMPORT=172
CREATE=149
FPAR=43
NEXTSTATE=59
RETURN=78
THIS=149
THIS=150
CHANNEL=13
VIAPATH=113
ENDCONNECTION=126
VIAPATH=114
ENDCONNECTION=127
EXPORT=32
EQ=142
EQ=143
INFORMAL_TEXT=49
GEODE=175
D=184
E=187
F=194
GE=147
G=195
A=181
IMPLIES=152
B=203
C=185
L=186
M=191
N=182
O=196
TERMINATOR=100
H=197
I=193
GEODE=176
D=185
E=188
F=195
GE=148
G=196
A=182
IMPLIES=153
B=204
C=186
L=187
M=192
N=183
O=197
STOPIF=92
TERMINATOR=101
H=198
I=194
ELSE=27
J=204
K=188
U=200
T=198
W=202
J=205
K=189
U=201
T=199
W=203
STOP=91
V=201
INT=124
Q=211
P=189
S=192
VALUE=109
R=190
Y=183
X=199
V=202
INT=125
Q=212
P=190
S=193
VALUE=110
R=191
Y=184
X=200
FI=35
Z=212
MINUS_INFINITY=166
WS=209
OUT=132
NONE=133
Z=213
MINUS_INFINITY=167
WS=210
OUT=133
NONE=134
INPUT_NONE=52
CONSTANT=22
GT=144
CALL=138
END=177
GT=145
CALL=139
END=178
FLOATING_LABEL=41
T__215=215
IFTHENELSE=47
T__216=216
T__213=213
T__214=214
T__219=219
T__217=217
T__218=218
INPUT=51
ENDSUBSTRUCTURE=131
ENDSUBSTRUCTURE=132
FLOAT=40
SUBSTRUCTURE=130
ASTERISK=129
SUBSTRUCTURE=131
ASTERISK=130
PAREN=68
T__220=220
INOUT=50
STR=206
STR=207
STIMULUS=90
SELECTOR=81
THEN=104
ENDDECISION=140
THEN=105
ENDDECISION=141
OPEN_RANGE=62
SIGNAL=85
ENDSYSTEM=114
PLUS=155
ENDSYSTEM=115
PLUS=156
CHOICE=14
TASK_BODY=99
TASK_BODY=100
PARAMS=67
CLOSED_RANGE=16
STATE=88
STATELIST=89
TO=106
ASSIG_OP=178
SIGNALROUTE=119
TO=107
ASSIG_OP=179
SIGNALROUTE=120
ENDSYNTYPE=30
SORT=87
SET=84
TEXT=101
SEMI=127
TEXTAREA=102
TEXT=102
SEMI=128
TEXTAREA=103
BLOCK=12
CIF=15
START=125
START=126
DECISION=25
DIV=158
DIV=159
PROCESS=73
STRING=92
STRING=93
INPUTLIST=53
EXTERNAL=34
LT=145
EXPONENT=169
TRANSITION=107
ENDBLOCK=118
LT=146
EXPONENT=170
TRANSITION=108
ENDBLOCK=119
RESET=77
ENDNEWTYPE=29
SIGNAL_LIST=86
ENDTEXT=31
CONNECTION=21
SYSTEM=97
SYSTEM=98
CONNECT=20
L_PAREN=135
L_PAREN=136
PROCEDURE_CALL=71
BASE=168
BASE=169
COMMENT=17
SYNONYM=94
ENDALTERNATIVE=139
SYNONYM=95
ENDALTERNATIVE=140
ARRAY=8
ACTIVE=170
ENDFOR=151
ACTIVE=171
ENDFOR=152
FIELD_NAME=37
OCTSTR=61
VIEW=172
VIEW=173
EMPTYSTR=28
ENDCHANNEL=115
NULL=164
ENDCHANNEL=116
NULL=165
ANSWER=7
CONDITIONAL=19
PRIMARY=69
TASK=98
REFERENCED=121
ALPHA=207
TASK=99
REFERENCED=122
ALPHA=208
SEQUENCE=83
VARIABLE=110
PRIORITY=134
SPECIFIC=174
OR=153
VARIABLE=111
PRIORITY=135
SPECIFIC=175
OR=154
COMPOSITE_STATE=18
FIELD=36
USE=108
FROM=116
ENDPROCEDURE=123
FALSE=163
USE=109
FROM=117
ENDPROCEDURE=124
FALSE=164
OUTPUT=63
SYNONYM_LIST=95
APPEND=157
L_BRACKET=179
SYNONYM_LIST=96
APPEND=158
L_BRACKET=180
DIGITS=26
HYPERLINK=45
NEWTYPE=58
Exponent=208
Exponent=209
FOR=42
ENDSTATE=128
ENDSTATE=129
PROCEDURE_NAME=72
CONSTANTS=23
AND=120
ID=150
AND=121
ID=151
FLOAT2=39
IF=46
IN=48
PROVIDED=74
COMMA=137
COMMA=138
ALL=5
ASNFILENAME=176
DOT=205
ASNFILENAME=177
DOT=206
EXPRESSION=33
WITH=117
WITH=118
BITSTR=11
XOR=154
DASH=156
ENDPROCESS=122
XOR=155
DASH=157
ENDPROCESS=123
DCL=24
VIA=112
VIA=113
RANGE=76
STRUCT=93
STRUCT=94
LITERAL=56
SAVE=80
FIELDS=38
REM=160
TRUE=162
REM=161
TRUE=163
JOIN=54
PROCEDURE=70
R_BRACKET=180
R_PAREN=136
R_BRACKET=181
R_PAREN=137
OUTPUT_BODY=64
NEQ=143
ANY=141
NEQ=144
ANY=142
QUESTION=75
LABEL=55
PLUS_INFINITY=165
PLUS_INFINITY=166
PARAMNAMES=66
ASN1=9
KEEP=173
KEEP=174
NEG=57
VARIABLES=111
VARIABLES=112
ASSIGN=10
ALTERNATIVE=6
SYNTYPE=96
TIMER=105
LE=146
SYNTYPE=97
TIMER=106
LE=147
class sdl92Lexer(Lexer):
......@@ -267,11 +268,11 @@ class sdl92Lexer(Lexer):
# $ANTLR start "T__213"
def mT__213(self, ):
# $ANTLR start "T__214"
def mT__214(self, ):
try:
_type = T__213
_type = T__214
_channel = DEFAULT_CHANNEL
# sdl92.g:7:8: ( ':' )
......@@ -288,15 +289,15 @@ class sdl92Lexer(Lexer):
pass
# $ANTLR end "T__213"
# $ANTLR end "T__214"
# $ANTLR start "T__214"
def mT__214(self, ):
# $ANTLR start "T__215"
def mT__215(self, ):
try:
_type = T__214
_type = T__215
_channel = DEFAULT_CHANNEL
# sdl92.g:8:8: ( '!' )
......@@ -313,15 +314,15 @@ class sdl92Lexer(Lexer):
pass
# $ANTLR end "T__214"
# $ANTLR end "T__215"
# $ANTLR start "T__215"
def mT__215(self, ):
# $ANTLR start "T__216"
def mT__216(self, ):
try:
_type = T__215
_type = T__216
_channel = DEFAULT_CHANNEL
# sdl92.g:9:8: ( '(.' )
......@@ -338,15 +339,15 @@ class sdl92Lexer(Lexer):
pass
# $ANTLR end "T__215"
# $ANTLR end "T__216"
# $ANTLR start "T__216"
def mT__216(self, ):
# $ANTLR start "T__217"
def mT__217(self, ):
try:
_type = T__216
_type = T__217
_channel = DEFAULT_CHANNEL
# sdl92.g:10:8: ( '.)' )
......@@ -363,15 +364,15 @@ class sdl92Lexer(Lexer):
pass
# $ANTLR end "T__216"
# $ANTLR end "T__217"
# $ANTLR start "T__217"
def mT__217(self, ):
# $ANTLR start "T__218"
def mT__218(self, ):
try:
_type = T__217
_type = T__218
_channel = DEFAULT_CHANNEL
# sdl92.g:11:8: ( 'ERROR' )
......@@ -388,15 +389,15 @@ class sdl92Lexer(Lexer):
pass
# $ANTLR end "T__217"
# $ANTLR end "T__218"
# $ANTLR start "T__218"
def mT__218(self, ):
# $ANTLR start "T__219"
def mT__219(self, ):
try:
_type = T__218
_type = T__219
_channel = DEFAULT_CHANNEL
# sdl92.g:12:8: ( '/* CIF' )
......@@ -413,15 +414,15 @@ class sdl92Lexer(Lexer):
pass
# $ANTLR end "T__218"
# $ANTLR end "T__219"
# $ANTLR start "T__219"
def mT__219(self, ):
# $ANTLR start "T__220"
def mT__220(self, ):
try:
_type = T__219
_type = T__220
_channel = DEFAULT_CHANNEL
# sdl92.g:13:8: ( '*/' )
......@@ -438,7 +439,7 @@ class sdl92Lexer(Lexer):
pass
# $ANTLR end "T__219"
# $ANTLR end "T__220"
......@@ -449,8 +450,8 @@ class sdl92Lexer(Lexer):
_type = ASSIG_OP
_channel = DEFAULT_CHANNEL
# sdl92.g:1152:17: ( ':=' )
# sdl92.g:1152:25: ':='
# sdl92.g:1159:17: ( ':=' )
# sdl92.g:1159:25: ':='
pass
self.match(":=")
......@@ -474,8 +475,8 @@ class sdl92Lexer(Lexer):
_type = L_BRACKET
_channel = DEFAULT_CHANNEL
# sdl92.g:1153:17: ( '{' )
# sdl92.g:1153:25: '{'
# sdl92.g:1160:17: ( '{' )
# sdl92.g:1160:25: '{'
pass
self.match(123)
......@@ -499,8 +500,8 @@ class sdl92Lexer(Lexer):
_type = R_BRACKET
_channel = DEFAULT_CHANNEL
# sdl92.g:1154:17: ( '}' )
# sdl92.g:1154:25: '}'
# sdl92.g:1161:17: ( '}' )
# sdl92.g:1161:25: '}'
pass
self.match(125)
......@@ -524,8 +525,8 @@ class sdl92Lexer(Lexer):
_type = L_PAREN
_channel = DEFAULT_CHANNEL
# sdl92.g:1155:17: ( '(' )
# sdl92.g:1155:25: '('
# sdl92.g:1162:17: ( '(' )
# sdl92.g:1162:25: '('
pass
self.match(40)
......@@ -549,8 +550,8 @@ class sdl92Lexer(Lexer):
_type = R_PAREN
_channel = DEFAULT_CHANNEL
# sdl92.g:1156:17: ( ')' )
# sdl92.g:1156:25: ')'
# sdl92.g:1163:17: ( ')' )
# sdl92.g:1163:25: ')'
pass
self.match(41)
......@@ -574,8 +575,8 @@ class sdl92Lexer(Lexer):
_type = COMMA
_channel = DEFAULT_CHANNEL
# sdl92.g:1157:17: ( ',' )
# sdl92.g:1157:25: ','
# sdl92.g:1164:17: ( ',' )
# sdl92.g:1164:25: ','
pass
self.match(44)
......@@ -599,8 +600,8 @@ class sdl92Lexer(Lexer):
_type = SEMI
_channel = DEFAULT_CHANNEL
# sdl92.g:1158:17: ( ';' )
# sdl92.g:1158:25: ';'
# sdl92.g:1165:17: ( ';' )
# sdl92.g:1165:25: ';'
pass
self.match(59)
......@@ -624,8 +625,8 @@ class sdl92Lexer(Lexer):
_type = DASH
_channel = DEFAULT_CHANNEL
# sdl92.g:1159:17: ( '-' )
# sdl92.g:1159:25: '-'
# sdl92.g:1166:17: ( '-' )
# sdl92.g:1166:25: '-'
pass
self.match(45)
......@@ -649,8 +650,8 @@ class sdl92Lexer(Lexer):
_type = ANY
_channel = DEFAULT_CHANNEL
# sdl92.g:1160:17: ( A N Y )
# sdl92.g:1160:25: A N Y
# sdl92.g:1167:17: ( A N Y )
# sdl92.g:1167:25: A N Y
pass