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

Parse "state" as a valid primary expression

In stop conditions, it is valid to write "stop if state=wait"; until now
"state" was a reserved keyword so the parser would not accept it in an
expression. Now it does.
parent ccfeb420
......@@ -2,7 +2,7 @@
 
# Resource object code
#
# Created: Mon Mar 9 21:42:24 2015
# Created: Mon Mar 16 20:49:26 2015
# by: The Resource Compiler for PySide (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!
......@@ -3909,16 +3909,20 @@ def label(root, parent, context=None):
def stop_if(root, parent, context=None):
''' Parse a STOP IF expression - Return an expression
''' Parse a set of stop conditions - Return an list of expressions
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
expressions, errors, warnings = [], [], []
for each in root.getChildren():
expr, err, warn = expression(each, context)
expr.exprType = BOOLEAN
expressions.append(expr)
errors.extend(err)
warnings.extend(warn)
errors = [[e, [0, 0], []] for e in errors]
warnings = [[w, [0, 0], []] for w in warnings]
return expr, errors, warnings
return expressions, errors, warnings
def pr_file(root):
......
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2015-03-09 21:42:26
# $ANTLR 3.1.3 Mar 17, 2009 19:23:44 sdl92.g 2015-03-16 20:49:29
import sys
from antlr3 import *
......@@ -450,8 +450,8 @@ class sdl92Lexer(Lexer):
_type = ASSIG_OP
_channel = DEFAULT_CHANNEL
# sdl92.g:1159:17: ( ':=' )
# sdl92.g:1159:25: ':='
# sdl92.g:1160:17: ( ':=' )
# sdl92.g:1160:25: ':='
pass
self.match(":=")
......@@ -475,8 +475,8 @@ class sdl92Lexer(Lexer):
_type = L_BRACKET
_channel = DEFAULT_CHANNEL
# sdl92.g:1160:17: ( '{' )
# sdl92.g:1160:25: '{'
# sdl92.g:1161:17: ( '{' )
# sdl92.g:1161:25: '{'
pass
self.match(123)
......@@ -500,8 +500,8 @@ class sdl92Lexer(Lexer):
_type = R_BRACKET
_channel = DEFAULT_CHANNEL
# sdl92.g:1161:17: ( '}' )
# sdl92.g:1161:25: '}'
# sdl92.g:1162:17: ( '}' )
# sdl92.g:1162:25: '}'
pass
self.match(125)
......@@ -525,8 +525,8 @@ class sdl92Lexer(Lexer):
_type = L_PAREN
_channel = DEFAULT_CHANNEL
# sdl92.g:1162:17: ( '(' )
# sdl92.g:1162:25: '('
# sdl92.g:1163:17: ( '(' )
# sdl92.g:1163:25: '('
pass
self.match(40)
......@@ -550,8 +550,8 @@ class sdl92Lexer(Lexer):
_type = R_PAREN
_channel = DEFAULT_CHANNEL
# sdl92.g:1163:17: ( ')' )
# sdl92.g:1163:25: ')'
# sdl92.g:1164:17: ( ')' )
# sdl92.g:1164:25: ')'
pass
self.match(41)
......@@ -575,8 +575,8 @@ class sdl92Lexer(Lexer):
_type = COMMA
_channel = DEFAULT_CHANNEL
# sdl92.g:1164:17: ( ',' )
# sdl92.g:1164:25: ','
# sdl92.g:1165:17: ( ',' )
# sdl92.g:1165:25: ','
pass
self.match(44)
......@@ -600,8 +600,8 @@ class sdl92Lexer(Lexer):
_type = SEMI
_channel = DEFAULT_CHANNEL
# sdl92.g:1165:17: ( ';' )
# sdl92.g:1165:25: ';'
# sdl92.g:1166:17: ( ';' )
# sdl92.g:1166:25: ';'
pass
self.match(59)
......@@ -625,8 +625,8 @@ class sdl92Lexer(Lexer):
_type = DASH
_channel = DEFAULT_CHANNEL
# sdl92.g:1166:17: ( '-' )
# sdl92.g:1166:25: '-'
# sdl92.g:1167:17: ( '-' )
# sdl92.g:1167:25: '-'
pass
self.match(45)
......@@ -650,8 +650,8 @@ class sdl92Lexer(Lexer):
_type = ANY
_channel = DEFAULT_CHANNEL
# sdl92.g:1167:17: ( A N Y )
# sdl92.g:1167:25: A N Y
# sdl92.g:1168:17: ( A N Y )
# sdl92.g:1168:25: A N Y
pass
self.mA()
self.mN()
......@@ -677,8 +677,8 @@ class sdl92Lexer(Lexer):
_type = ASTERISK
_channel = DEFAULT_CHANNEL
# sdl92.g:1168:17: ( '*' )
# sdl92.g:1168:25: '*'
# sdl92.g:1169:17: ( '*' )
# sdl92.g:1169:25: '*'
pass
self.match(42)
......@@ -702,8 +702,8 @@ class sdl92Lexer(Lexer):
_type = DCL
_channel = DEFAULT_CHANNEL
# sdl92.g:1169:17: ( D C L )
# sdl92.g:1169:25: D C L
# sdl92.g:1170:17: ( D C L )
# sdl92.g:1170:25: D C L
pass
self.mD()
self.mC()
......@@ -729,8 +729,8 @@ class sdl92Lexer(Lexer):
_type = END
_channel = DEFAULT_CHANNEL
# sdl92.g:1170:17: ( E N D )
# sdl92.g:1170:25: E N D
# sdl92.g:1171:17: ( E N D )
# sdl92.g:1171:25: E N D
pass
self.mE()
self.mN()
......@@ -756,8 +756,8 @@ class sdl92Lexer(Lexer):
_type = KEEP
_channel = DEFAULT_CHANNEL
# sdl92.g:1171:17: ( K E E P )
# sdl92.g:1171:25: K E E P
# sdl92.g:1172:17: ( K E E P )
# sdl92.g:1172:25: K E E P
pass
self.mK()
self.mE()
......@@ -784,8 +784,8 @@ class sdl92Lexer(Lexer):
_type = PARAMNAMES
_channel = DEFAULT_CHANNEL
# sdl92.g:1172:17: ( P A R A M N A M E S )
# sdl92.g:1172:25: P A R A M N A M E S
# sdl92.g:1173:17: ( P A R A M N A M E S )
# sdl92.g:1173:25: P A R A M N A M E S
pass
self.mP()
self.mA()
......@@ -818,8 +818,8 @@ class sdl92Lexer(Lexer):
_type = SPECIFIC
_channel = DEFAULT_CHANNEL
# sdl92.g:1173:17: ( S P E C I F I C )
# sdl92.g:1173:25: S P E C I F I C
# sdl92.g:1174:17: ( S P E C I F I C )
# sdl92.g:1174:25: S P E C I F I C
pass
self.mS()
self.mP()
......@@ -850,8 +850,8 @@ class sdl92Lexer(Lexer):
_type = GEODE
_channel = DEFAULT_CHANNEL
# sdl92.g:1174:17: ( G E O D E )
# sdl92.g:1174:25: G E O D E
# sdl92.g:1175:17: ( G E O D E )
# sdl92.g:1175:25: G E O D E
pass
self.mG()
self.mE()
......@@ -879,8 +879,8 @@ class sdl92Lexer(Lexer):
_type = HYPERLINK
_channel = DEFAULT_CHANNEL
# sdl92.g:1175:17: ( H Y P E R L I N K )
# sdl92.g:1175:25: H Y P E R L I N K
# sdl92.g:1176:17: ( H Y P E R L I N K )
# sdl92.g:1176:25: H Y P E R L I N K
pass
self.mH()
self.mY()
......@@ -912,8 +912,8 @@ class sdl92Lexer(Lexer):
_type = ENDTEXT
_channel = DEFAULT_CHANNEL
# sdl92.g:1176:17: ( E N D T E X T )
# sdl92.g:1176:25: E N D T E X T
# sdl92.g:1177:17: ( E N D T E X T )
# sdl92.g:1177:25: E N D T E X T
pass
self.mE()
self.mN()
......@@ -943,8 +943,8 @@ class sdl92Lexer(Lexer):
_type = RETURN
_channel = DEFAULT_CHANNEL
# sdl92.g:1177:17: ( R E T U R N )
# sdl92.g:1177:25: R E T U R N
# sdl92.g:1178:17: ( R E T U R N )
# sdl92.g:1178:25: R E T U R N
pass
self.mR()
self.mE()
......@@ -973,8 +973,8 @@ class sdl92Lexer(Lexer):
_type = TIMER
_channel = DEFAULT_CHANNEL
# sdl92.g:1178:17: ( T I M E R )
# sdl92.g:1178:25: T I M E R
# sdl92.g:1179:17: ( T I M E R )
# sdl92.g:1179:25: T I M E R
pass
self.mT()
self.mI()
......@@ -1002,8 +1002,8 @@ class sdl92Lexer(Lexer):
_type = PROCESS
_channel = DEFAULT_CHANNEL
# sdl92.g:1179:17: ( P R O C E S S )
# sdl92.g:1179:25: P R O C E S S
# sdl92.g:1180:17: ( P R O C E S S )
# sdl92.g:1180:25: P R O C E S S
pass
self.mP()
self.mR()
......@@ -1033,8 +1033,8 @@ class sdl92Lexer(Lexer):
_type = ENDPROCESS
_channel = DEFAULT_CHANNEL
# sdl92.g:1180:17: ( E N D P R O C E S S )
# sdl92.g:1180:25: E N D P R O C E S S
# sdl92.g:1181:17: ( E N D P R O C E S S )
# sdl92.g:1181:25: E N D P R O C E S S
pass
self.mE()
self.mN()
......@@ -1067,8 +1067,8 @@ class sdl92Lexer(Lexer):
_type = START
_channel = DEFAULT_CHANNEL
# sdl92.g:1181:17: ( S T A R T )
# sdl92.g:1181:25: S T A R T
# sdl92.g:1182:17: ( S T A R T )
# sdl92.g:1182:25: S T A R T
pass
self.mS()
self.mT()
......@@ -1096,8 +1096,8 @@ class sdl92Lexer(Lexer):
_type = STATE
_channel = DEFAULT_CHANNEL
# sdl92.g:1182:17: ( S T A T E )
# sdl92.g:1182:25: S T A T E
# sdl92.g:1183:17: ( S T A T E )
# sdl92.g:1183:25: S T A T E
pass
self.mS()
self.mT()
......@@ -1125,8 +1125,8 @@ class sdl92Lexer(Lexer):
_type = TEXT
_channel = DEFAULT_CHANNEL
# sdl92.g:1183:17: ( T E X T )
# sdl92.g:1183:25: T E X T
# sdl92.g:1184:17: ( T E X T )
# sdl92.g:1184:25: T E X T
pass
self.mT()
self.mE()
......@@ -1153,8 +1153,8 @@ class sdl92Lexer(Lexer):
_type = PROCEDURE
_channel = DEFAULT_CHANNEL
# sdl92.g:1184:17: ( P R O C E D U R E )
# sdl92.g:1184:25: P R O C E D U R E
# sdl92.g:1185:17: ( P R O C E D U R E )
# sdl92.g:1185:25: P R O C E D U R E
pass
self.mP()
self.mR()
......@@ -1186,8 +1186,8 @@ class sdl92Lexer(Lexer):
_type = ENDPROCEDURE
_channel = DEFAULT_CHANNEL
# sdl92.g:1185:17: ( E N D P R O C E D U R E )
# sdl92.g:1185:25: E N D P R O C E D U R E
# sdl92.g:1186:17: ( E N D P R O C E D U R E )
# sdl92.g:1186:25: E N D P R O C E D U R E
pass
self.mE()
self.mN()
......@@ -1222,8 +1222,8 @@ class sdl92Lexer(Lexer):
_type = PROCEDURE_CALL
_channel = DEFAULT_CHANNEL
# sdl92.g:1186:17: ( P R O C E D U R E C A L L )
# sdl92.g:1186:25: P R O C E D U R E C A L L
# sdl92.g:1187:17: ( P R O C E D U R E C A L L )
# sdl92.g:1187:25: P R O C E D U R E C A L L
pass
self.mP()
self.mR()
......@@ -1259,8 +1259,8 @@ class sdl92Lexer(Lexer):
_type = ENDSTATE
_channel = DEFAULT_CHANNEL
# sdl92.g:1187:17: ( E N D S T A T E )
# sdl92.g:1187:25: E N D S T A T E
# sdl92.g:1188:17: ( E N D S T A T E )
# sdl92.g:1188:25: E N D S T A T E
pass
self.mE()
self.mN()
......@@ -1291,8 +1291,8 @@ class sdl92Lexer(Lexer):
_type = INPUT
_channel = DEFAULT_CHANNEL
# sdl92.g:1188:17: ( I N P U T )
# sdl92.g:1188:25: I N P U T
# sdl92.g:1189:17: ( I N P U T )
# sdl92.g:1189:25: I N P U T
pass
self.mI()
self.mN()
......@@ -1320,8 +1320,8 @@ class sdl92Lexer(Lexer):
_type = PROVIDED
_channel = DEFAULT_CHANNEL
# sdl92.g:1189:17: ( P R O V I D E D )
# sdl92.g:1189:25: P R O V I D E D
# sdl92.g:1190:17: ( P R O V I D E D )
# sdl92.g:1190:25: P R O V I D E D
pass
self.mP()
self.mR()
......@@ -1352,8 +1352,8 @@ class sdl92Lexer(Lexer):
_type = PRIORITY
_channel = DEFAULT_CHANNEL
# sdl92.g:1190:17: ( P R I O R I T Y )
# sdl92.g:1190:25: P R I O R I T Y
# sdl92.g:1191:17: ( P R I O R I T Y )
# sdl92.g:1191:25: P R I O R I T Y
pass
self.mP()
self.mR()
......@@ -1384,8 +1384,8 @@ class sdl92Lexer(Lexer):
_type = SAVE
_channel = DEFAULT_CHANNEL
# sdl92.g:1191:17: ( S A V E )
# sdl92.g:1191:25: S A V E
# sdl92.g:1192:17: ( S A V E )
# sdl92.g:1192:25: S A V E
pass
self.mS()
self.mA()
......@@ -1412,8 +1412,8 @@ class sdl92Lexer(Lexer):
_type = NONE
_channel = DEFAULT_CHANNEL
# sdl92.g:1192:17: ( N O N E )
# sdl92.g:1192:25: N O N E
# sdl92.g:1193:17: ( N O N E )
# sdl92.g:1193:25: N O N E
pass
self.mN()
self.mO()
......@@ -1440,8 +1440,8 @@ class sdl92Lexer(Lexer):
_type = FOR
_channel = DEFAULT_CHANNEL
# sdl92.g:1199:17: ( F O R )
# sdl92.g:1199:25: F O R
# sdl92.g:1200:17: ( F O R )
# sdl92.g:1200:25: F O R
pass
self.mF()
self.mO()
......@@ -1467,8 +1467,8 @@ class sdl92Lexer(Lexer):
_type = ENDFOR
_channel = DEFAULT_CHANNEL
# sdl92.g:1200:17: ( E N D F O R )
# sdl92.g:1200:25: E N D F O R
# sdl92.g:1201:17: ( E N D F O R )
# sdl92.g:1201:25: E N D F O R
pass
self.mE()
self.mN()
......@@ -1497,8 +1497,8 @@ class sdl92Lexer(Lexer):
_type = RANGE
_channel = DEFAULT_CHANNEL
# sdl92.g:1201:17: ( R A N G E )
# sdl92.g:1201:25: R A N G E
# sdl92.g:1202:17: ( R A N G E )
# sdl92.g:1202:25: R A N G E
pass
self.mR()
self.mA()
......@@ -1526,8 +1526,8 @@ class sdl92Lexer(Lexer):
_type = NEXTSTATE
_channel = DEFAULT_CHANNEL
# sdl92.g:1202:17: ( N E X T S T A T E )
# sdl92.g:1202:25: N E X T S T A T E
# sdl92.g:1203:17: ( N E X T S T A T E )
# sdl92.g:1203:25: N E X T S T A T E
pass
self.mN()
self.mE()
......@@ -1559,8 +1559,8 @@ class sdl92Lexer(Lexer):
_type = ANSWER
_channel = DEFAULT_CHANNEL
# sdl92.g:1203:17: ( A N S W E R )
# sdl92.g:1203:25: A N S W E R
# sdl92.g:1204:17: ( A N S W E R )
# sdl92.g:1204:25: A N S W E R
pass
self.mA()
self.mN()
......@@ -1589,8 +1589,8 @@ class sdl92Lexer(Lexer):
_type = COMMENT
_channel = DEFAULT_CHANNEL
# sdl92.g:1204:17: ( C O M M E N T )
# sdl92.g:1204:25: C O M M E N T
# sdl92.g:1205:17: ( C O M M E N T )
# sdl92.g:1205:25: C O M M E N T
pass
self.mC()
self.mO()
......@@ -1620,8 +1620,8 @@ class sdl92Lexer(Lexer):
_type = LABEL
_channel = DEFAULT_CHANNEL
# sdl92.g:1205:17: ( L A B E L )
# sdl92.g:1205:25: L A B E L
# sdl92.g:1206:17: ( L A B E L )
# sdl92.g:1206:25: L A B E L
pass
self.mL()
self.mA()
......@@ -1649,8 +1649,8 @@ class sdl92Lexer(Lexer):
_type = STOP
_channel = DEFAULT_CHANNEL
# sdl92.g:1206:17: ( S T O P )
# sdl92.g:1206:25: S T O P
# sdl92.g:1207:17: ( S T O P )
# sdl92.g:1207:25: S T O P
pass
self.mS()
self.mT()
......@@ -1677,8 +1677,8 @@ class sdl92Lexer(Lexer):
_type = IF
_channel = DEFAULT_CHANNEL
# sdl92.g:1207:17: ( I F )
# sdl92.g:1207:25: I F
# sdl92.g:1208:17: ( I F )
# sdl92.g:1208:25: I F
pass
self.mI()
self.mF()
......@@ -1703,8 +1703,8 @@ class sdl92Lexer(Lexer):
_type = THEN
_channel = DEFAULT_CHANNEL
# sdl92.g:1208:17: ( T H E N )
# sdl92.g:1208:25: T H E N
# sdl92.g:1209:17: ( T H E N )
# sdl92.g:1209:25: T H E N
pass
self.mT()
self.mH()
......@@ -1731,8 +1731,8 @@ class sdl92Lexer(Lexer):
_type = ELSE
_channel = DEFAULT_CHANNEL
# sdl92.g:1209:17: ( E L S E )
# sdl92.g:1209:25: E L S E
# sdl92.g:1210:17: ( E L S E )
# sdl92.g:1210:25: E L S E
pass
self.mE()
self.mL()
......@@ -1759,8 +1759,8 @@ class sdl92Lexer(Lexer):
_type = FI
_channel = DEFAULT_CHANNEL
# sdl92.g:1210:17: ( F I )
# sdl92.g:1210:25: F I
# sdl92.g:1211:17: ( F I )
# sdl92.g:1211:25: F I
pass
self.mF()
self.mI()
......@@ -1785,8 +1785,8 @@ class sdl92Lexer(Lexer):
_type = CREATE
_channel = DEFAULT_CHANNEL
# sdl92.g:1211:17: ( C R E A T E )
# sdl92.g:1211:25: C R E A T E
# sdl92.g:1212:17: ( C R E A T E )
# sdl92.g:1212:25: C R E A T E
pass
self.mC()
self.mR()
......@@ -1815,8 +1815,8 @@ class sdl92Lexer(Lexer):
_type = OUTPUT
_channel = DEFAULT_CHANNEL
# sdl92.g:1212:17: ( O U T P U T )
# sdl92.g:1212:25: O U T P U T
# sdl92.g:1213:17: ( O U T P U T )
# sdl92.g:1213:25: O U T P U T
pass
self.mO()
self.mU()
......@@ -1845,8 +1845,8 @@ class sdl92Lexer(Lexer):
_type = CALL
_channel = DEFAULT_CHANNEL
# sdl92.g:1213:17: ( C A L L )
# sdl92.g:1213:25: C A L L
# sdl92.g:1214:17: ( C A L L )
# sdl92.g:1214:25: C A L L
pass
self.mC()
self.mA()
......@@ -1873,8 +1873,8 @@ class sdl92Lexer(Lexer):
_type = THIS
_channel = DEFAULT_CHANNEL
# sdl92.g:1214:17: ( T H I S )
# sdl92.g:1214:25: T H I S
# sdl92.g:1215:17: ( T H I S )
# sdl92.g:1215:25: T H I S
pass
self.mT()
self.mH()
......@@ -1901,8 +1901,8 @@ class sdl92Lexer(Lexer):
_type = SET
_channel = DEFAULT_CHANNEL
# sdl92.g:1215:17: ( S E T )
# sdl92.g:1215:25: S E T
# sdl92.g:1216:17: ( S E T )
# sdl92.g:1216:25: S E T
pass
self.mS()
self.mE()
......@@ -1928,8 +1928,8 @@ class sdl92Lexer(Lexer):
_type = RESET
_channel = DEFAULT_CHANNEL
# sdl92.g:1216:17: ( R E S E T )
# sdl92.g:1216:25: R E S E T
# sdl92.g:1217:17: ( R E S E T )
# sdl92.g:1217:25: R E S E T
pass
self.mR()
self.mE()
......@@ -1957,8 +1957,8 @@ class sdl92Lexer(Lexer):
_type = ENDALTERNATIVE
_channel = DEFAULT_CHANNEL
# sdl92.g:1217:17: ( E N D A L T E R N A T I V E )
# sdl92.g:1217:25: E N D A L T E R N A T I V E
# sdl92.g:1218:17: ( E N D A L T E R N A T I V E )
# sdl92.g:1218:25: E N D A L T E R N A T I V E
pass
self.mE()
self.mN()
......@@ -1995,8 +1995,8 @@ class sdl92Lexer(Lexer):
_type = ALTERNATIVE
_channel = DEFAULT_CHANNEL
# sdl92.g:1218:17: ( A L T E R N A T I V E )
# sdl92.g:1218:25: A L T E R N A T I V E
# sdl92.g:1219:17: ( A L T E R N A T I V E )
# sdl92.g:1219:25: A L T E R N A T I V E
pass
self.mA()
self.mL()
......@@ -2030,8 +2030,8 @@ class sdl92Lexer(Lexer):
_type = DECISION
_channel = DEFAULT_CHANNEL
# sdl92.g:1219:17: ( D E C I S I O N )
# sdl92.g:1219:25: D E C I S I O N
# sdl92.g:1220:17: ( D E C I S I O N )
# sdl92.g:1220:25: D E C I S I O N
pass
self.mD()
self.mE()
......@@ -2062,8 +2062,8 @@ class sdl92Lexer(Lexer):
_type = ENDDECISION
_channel = DEFAULT_CHANNEL
# sdl92.g:1220:17: ( E N D D E C I S I O N )
# sdl92.g:1220:25: E N D D E C I S I O N
# sdl92.g:1221:17: ( E N D D E C I S I O N )
# sdl92.g:1221:25: E N D D E C I S I O N
pass
self.mE()
self.mN()
......@@ -2097,8 +2097,8 @@ class sdl92Lexer(Lexer):
_type = EXPORT
_channel = DEFAULT_CHANNEL
# sdl92.g:1221:17: ( E X P O R T )
# sdl92.g:1221:25: E X P O R T
# sdl92.g:1222:17: ( E X P O R T )
# sdl92.g:1222:25: E X P O R T
pass
self.mE()
self.mX()
......@@ -2127,8 +2127,8 @@ class sdl92Lexer(Lexer):
_type = EXTERNAL
_channel = DEFAULT_CHANNEL
# sdl92.g:1222:17: ( E X T E R N A L )
# sdl92.g:1222:25: E X T E R N A L
# sdl92.g:1223:17: ( E X T E R N A L )
# sdl92.g:1223:25: E X T E R N A L
pass
self.mE()
self.mX()
......@@ -2159,8 +2159,8 @@ class sdl92Lexer(Lexer):