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

Better detect wrong choice assignments

mychoice!a!b := 5was not properly spotted as an error in
selector_expression. the right syntax is mychoice := a: { b 5 }  (ASN.1
Value notation)
parent 46e241ca
......@@ -142,6 +142,10 @@ The background pattern was downloaded from www.subtlepatterns.com
Changelog
=========
1.5.13 (10/2016)
- Better support of warnings
- Fixed detection of CHOICE assignment erros
1.5.12 (09/2016)
- Detect duplicate declaration of procedures
......
......@@ -1217,7 +1217,7 @@ def unary_expression(root, context):
return expr, errors, warnings
def expression(root, context):
def expression(root, context, pos='right'):
''' Expression analysis (e.g. 5+5*hello(world)!foo) '''
logic = (lexer.OR, lexer.AND, lexer.XOR, lexer.IMPLIES)
arithmetic = (lexer.PLUS, lexer.ASTERISK, lexer.DASH,
......@@ -1247,7 +1247,7 @@ def expression(root, context):
elif root.type == lexer.CALL:
return call_expression(root, context)
elif root.type == lexer.SELECTOR:
return selector_expression(root, context)
return selector_expression(root, context, pos)
else:
raise NotImplementedError(sdl92Parser.tokenNames[root.type] +
' - line ' + str(root.getLine()))
......@@ -1699,7 +1699,7 @@ def selector_expression(root, context, pos="right"):
node.tmpVar = tmp()
receiver, receiver_err, receiver_warn = \
expression(root.children[0], context)
expression(root.children[0], context, pos)
receiver_bty = find_basic_type(receiver.exprType)
errors.extend(receiver_err)
warnings.extend(receiver_warn)
......
......@@ -138,7 +138,7 @@ except ImportError:
__all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse']
__version__ = '1.5.12'
__version__ = '1.5.13'
if hasattr(sys, 'frozen'):
# Detect if we are running on Windows (py2exe-generated)
......
......@@ -11,7 +11,8 @@ NullType ::= NULL
ChoiceWithEmptySeq ::= CHOICE {
a NULL,
b EmptySeq,
c NullType
c NullType,
d SEQUENCE { a BOOLEAN }
}
c1 EmptySeq ::= {}
......
......@@ -38,7 +38,12 @@ dcl eso SeqOf := {};
/* CIF COMMENT (278, 376), (177, 40) */
COMMENT 'This is ok, there should
be no warning raised';
/* CIF NEXTSTATE (174, 428), (70, 35) */
/* CIF TASK (145, 433), (127, 35) */
TASK ch:= d: {a TRUE}
/* CIF COMMENT (292, 433), (170, 38) */
COMMENT 'No error, but
ch!d!a := TRUE would fail';
/* CIF NEXTSTATE (174, 483), (70, 35) */
NEXTSTATE wait;
/* CIF STATE (474, 233), (70, 35) */
STATE wait;
......
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