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

Parse properly instance/via clauses

parent 18db5dda
......@@ -123,8 +123,8 @@ The background pattern was downloaded from www.subtlepatterns.com
Changelog
=========
**3.1.3 (07/2020)**
- Fix issue finding ASN.1 files when model loaded from another folder
**3.2.0 (07/2020)**
- Add basic support for state type/instance
**3.1.2 (07/2020)**
- Reinforce syntax error checking and reporting
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3857,6 +3857,7 @@ def state(root, parent, context):
state_def.charPositionInLine = child.getCharPositionInLine()
state_def.statelist = [state_def.inputString]
inst_stop = child.getTokenStopIndex()
via_stop = inst_stop # in case there is also a via clause
elif child.type == lexer.TYPE_INSTANCE:
# Extract the complete string "state: instance"
start = inst_stop
......@@ -3926,8 +3927,8 @@ def state(root, parent, context):
.format(each, statename.lower()))
# then update the mapping state-input
context.mapping[statename.lower()].append(inp)
except KeyError:
stwarn.append('State definition missing')
except KeyError as err:
stwarn.append(f'State definition missing - {str(err)}')
state_def.inputs.append(inp)
if inp.inputString.strip() == '*':
if asterisk_input:
......
......@@ -140,7 +140,7 @@ except ImportError:
__all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse']
__version__ = '3.1.3'
__version__ = '3.2.0'
if hasattr(sys, 'frozen'):
# Detect if we are running on Windows (py2exe-generated)
......
# $ANTLR 3.5.2 sdl92.g 2020-07-09 14:22:50
# $ANTLR 3.5.2 sdl92.g 2020-07-09 17:54:52
import sys
from antlr3 import *
......@@ -493,8 +493,8 @@ class sdl92Lexer(Lexer):
_type = ASSIG_OP
_channel = DEFAULT_CHANNEL
# sdl92.g:1463:17: ( ':=' )
# sdl92.g:1463:25: ':='
# sdl92.g:1465:17: ( ':=' )
# sdl92.g:1465:25: ':='
pass
self.match(":=")
......@@ -516,8 +516,8 @@ class sdl92Lexer(Lexer):
_type = L_BRACKET
_channel = DEFAULT_CHANNEL
# sdl92.g:1464:17: ( '{' )
# sdl92.g:1464:25: '{'
# sdl92.g:1466:17: ( '{' )
# sdl92.g:1466:25: '{'
pass
self.match(123)
......@@ -538,8 +538,8 @@ class sdl92Lexer(Lexer):
_type = R_BRACKET
_channel = DEFAULT_CHANNEL
# sdl92.g:1465:17: ( '}' )
# sdl92.g:1465:25: '}'
# sdl92.g:1467:17: ( '}' )
# sdl92.g:1467:25: '}'
pass
self.match(125)
......@@ -560,8 +560,8 @@ class sdl92Lexer(Lexer):
_type = L_PAREN
_channel = DEFAULT_CHANNEL
# sdl92.g:1466:17: ( '(' )
# sdl92.g:1466:25: '('
# sdl92.g:1468:17: ( '(' )
# sdl92.g:1468:25: '('
pass
self.match(40)
......@@ -582,8 +582,8 @@ class sdl92Lexer(Lexer):
_type = R_PAREN
_channel = DEFAULT_CHANNEL
# sdl92.g:1467:17: ( ')' )
# sdl92.g:1467:25: ')'
# sdl92.g:1469:17: ( ')' )
# sdl92.g:1469:25: ')'
pass
self.match(41)
......@@ -604,8 +604,8 @@ class sdl92Lexer(Lexer):
_type = COMMA
_channel = DEFAULT_CHANNEL
# sdl92.g:1468:17: ( ',' )
# sdl92.g:1468:25: ','
# sdl92.g:1470:17: ( ',' )
# sdl92.g:1470:25: ','
pass
self.match(44)
......@@ -626,8 +626,8 @@ class sdl92Lexer(Lexer):
_type = SEMI
_channel = DEFAULT_CHANNEL
# sdl92.g:1469:17: ( ';' )
# sdl92.g:1469:25: ';'
# sdl92.g:1471:17: ( ';' )
# sdl92.g:1471:25: ';'
pass
self.match(59)
......@@ -648,8 +648,8 @@ class sdl92Lexer(Lexer):
_type = DASH
_channel = DEFAULT_CHANNEL
# sdl92.g:1470:17: ( '-' )
# sdl92.g:1470:25: '-'
# sdl92.g:1472:17: ( '-' )
# sdl92.g:1472:25: '-'
pass
self.match(45)
......@@ -670,8 +670,8 @@ class sdl92Lexer(Lexer):
_type = ANY
_channel = DEFAULT_CHANNEL
# sdl92.g:1471:17: ( A N Y )
# sdl92.g:1471:25: A N Y
# sdl92.g:1473:17: ( A N Y )
# sdl92.g:1473:25: A N Y
pass
self.mA()
......@@ -699,8 +699,8 @@ class sdl92Lexer(Lexer):
_type = ASTERISK
_channel = DEFAULT_CHANNEL
# sdl92.g:1472:17: ( '*' )
# sdl92.g:1472:25: '*'
# sdl92.g:1474:17: ( '*' )
# sdl92.g:1474:25: '*'
pass
self.match(42)
......@@ -721,8 +721,8 @@ class sdl92Lexer(Lexer):
_type = DCL
_channel = DEFAULT_CHANNEL
# sdl92.g:1473:17: ( D C L )
# sdl92.g:1473:25: D C L
# sdl92.g:1475:17: ( D C L )
# sdl92.g:1475:25: D C L
pass
self.mD()
......@@ -750,8 +750,8 @@ class sdl92Lexer(Lexer):
_type = END
_channel = DEFAULT_CHANNEL
# sdl92.g:1474:17: ( E N D )
# sdl92.g:1474:25: E N D
# sdl92.g:1476:17: ( E N D )
# sdl92.g:1476:25: E N D
pass
self.mE()
......@@ -779,8 +779,8 @@ class sdl92Lexer(Lexer):
_type = KEEP
_channel = DEFAULT_CHANNEL
# sdl92.g:1475:17: ( K E E P )
# sdl92.g:1475:25: K E E P
# sdl92.g:1477:17: ( K E E P )
# sdl92.g:1477:25: K E E P
pass
self.mK()
......@@ -811,8 +811,8 @@ class sdl92Lexer(Lexer):
_type = PARAMNAMES
_channel = DEFAULT_CHANNEL
# sdl92.g:1476:17: ( P A R A M N A M E S )
# sdl92.g:1476:25: P A R A M N A M E S
# sdl92.g:1478:17: ( P A R A M N A M E S )
# sdl92.g:1478:25: P A R A M N A M E S
pass
self.mP()
......@@ -861,8 +861,8 @@ class sdl92Lexer(Lexer):
_type = SPECIFIC
_channel = DEFAULT_CHANNEL
# sdl92.g:1477:17: ( S P E C I F I C )
# sdl92.g:1477:25: S P E C I F I C
# sdl92.g:1479:17: ( S P E C I F I C )
# sdl92.g:1479:25: S P E C I F I C
pass
self.mS()
......@@ -905,8 +905,8 @@ class sdl92Lexer(Lexer):
_type = GEODE
_channel = DEFAULT_CHANNEL
# sdl92.g:1478:17: ( G E O D E )
# sdl92.g:1478:25: G E O D E
# sdl92.g:1480:17: ( G E O D E )
# sdl92.g:1480:25: G E O D E
pass
self.mG()
......@@ -940,8 +940,8 @@ class sdl92Lexer(Lexer):
_type = HYPERLINK
_channel = DEFAULT_CHANNEL
# sdl92.g:1479:17: ( H Y P E R L I N K )
# sdl92.g:1479:25: H Y P E R L I N K
# sdl92.g:1481:17: ( H Y P E R L I N K )
# sdl92.g:1481:25: H Y P E R L I N K
pass
self.mH()
......@@ -987,8 +987,8 @@ class sdl92Lexer(Lexer):
_type = MKSTRING
_channel = DEFAULT_CHANNEL
# sdl92.g:1480:17: ( M K S T R I N G )
# sdl92.g:1480:25: M K S T R I N G
# sdl92.g:1482:17: ( M K S T R I N G )
# sdl92.g:1482:25: M K S T R I N G
pass
self.mM()
......@@ -1031,8 +1031,8 @@ class sdl92Lexer(Lexer):
_type = ENDTEXT
_channel = DEFAULT_CHANNEL
# sdl92.g:1481:17: ( E N D T E X T )
# sdl92.g:1481:25: E N D T E X T
# sdl92.g:1483:17: ( E N D T E X T )
# sdl92.g:1483:25: E N D T E X T
pass
self.mE()
......@@ -1072,8 +1072,8 @@ class sdl92Lexer(Lexer):
_type = RETURN
_channel = DEFAULT_CHANNEL
# sdl92.g:1482:17: ( R E T U R N )
# sdl92.g:1482:25: R E T U R N
# sdl92.g:1484:17: ( R E T U R N )
# sdl92.g:1484:25: R E T U R N
pass
self.mR()
......@@ -1110,8 +1110,8 @@ class sdl92Lexer(Lexer):
_type = RETURNS
_channel = DEFAULT_CHANNEL
# sdl92.g:1483:17: ( R E T U R N S )
# sdl92.g:1483:25: R E T U R N S
# sdl92.g:1485:17: ( R E T U R N S )
# sdl92.g:1485:25: R E T U R N S
pass
self.mR()
......@@ -1151,8 +1151,8 @@ class sdl92Lexer(Lexer):
_type = TIMER
_channel = DEFAULT_CHANNEL
# sdl92.g:1484:17: ( T I M E R )
# sdl92.g:1484:25: T I M E R
# sdl92.g:1486:17: ( T I M E R )
# sdl92.g:1486:25: T I M E R
pass
self.mT()
......@@ -1186,8 +1186,8 @@ class sdl92Lexer(Lexer):
_type = PROCESS
_channel = DEFAULT_CHANNEL
# sdl92.g:1485:17: ( P R O C E S S )
# sdl92.g:1485:25: P R O C E S S
# sdl92.g:1487:17: ( P R O C E S S )
# sdl92.g:1487:25: P R O C E S S
pass
self.mP()
......@@ -1227,8 +1227,8 @@ class sdl92Lexer(Lexer):
_type = TYPE
_channel = DEFAULT_CHANNEL
# sdl92.g:1486:17: ( T Y P E )
# sdl92.g:1486:25: T Y P E
# sdl92.g:1488:17: ( T Y P E )
# sdl92.g:1488:25: T Y P E
pass
self.mT()
......@@ -1259,8 +1259,8 @@ class sdl92Lexer(Lexer):
_type = ENDPROCESS
_channel = DEFAULT_CHANNEL
# sdl92.g:1487:17: ( E N D P R O C E S S )
# sdl92.g:1487:25: E N D P R O C E S S
# sdl92.g:1489:17: ( E N D P R O C E S S )
# sdl92.g:1489:25: E N D P R O C E S S
pass
self.mE()
......@@ -1309,8 +1309,8 @@ class sdl92Lexer(Lexer):
_type = START
_channel = DEFAULT_CHANNEL
# sdl92.g:1488:17: ( S T A R T )
# sdl92.g:1488:25: S T A R T
# sdl92.g:1490:17: ( S T A R T )
# sdl92.g:1490:25: S T A R T
pass
self.mS()
......@@ -1344,8 +1344,8 @@ class sdl92Lexer(Lexer):
_type = STATE
_channel = DEFAULT_CHANNEL
# sdl92.g:1489:17: ( S T A T E )
# sdl92.g:1489:25: S T A T E
# sdl92.g:1491:17: ( S T A T E )
# sdl92.g:1491:25: S T A T E
pass
self.mS()
......@@ -1379,8 +1379,8 @@ class sdl92Lexer(Lexer):
_type = TEXT
_channel = DEFAULT_CHANNEL
# sdl92.g:1490:17: ( T E X T )
# sdl92.g:1490:25: T E X T
# sdl92.g:1492:17: ( T E X T )
# sdl92.g:1492:25: T E X T
pass
self.mT()
......@@ -1411,8 +1411,8 @@ class sdl92Lexer(Lexer):
_type = PROCEDURE
_channel = DEFAULT_CHANNEL
# sdl92.g:1491:17: ( P R O C E D U R E )
# sdl92.g:1491:25: P R O C E D U R E
# sdl92.g:1493:17: ( P R O C E D U R E )
# sdl92.g:1493:25: P R O C E D U R E
pass
self.mP()
......@@ -1458,8 +1458,8 @@ class sdl92Lexer(Lexer):
_type = ENDPROCEDURE
_channel = DEFAULT_CHANNEL
# sdl92.g:1492:17: ( E N D P R O C E D U R E )
# sdl92.g:1492:25: E N D P R O C E D U R E
# sdl92.g:1494:17: ( E N D P R O C E D U R E )
# sdl92.g:1494:25: E N D P R O C E D U R E
pass
self.mE()
......@@ -1514,8 +1514,8 @@ class sdl92Lexer(Lexer):
_type = PROCEDURE_CALL
_channel = DEFAULT_CHANNEL
# sdl92.g:1493:17: ( P R O C E D U R E C A L L )
# sdl92.g:1493:25: P R O C E D U R E C A L L
# sdl92.g:1495:17: ( P R O C E D U R E C A L L )
# sdl92.g:1495:25: P R O C E D U R E C A L L
pass
self.mP()
......@@ -1573,8 +1573,8 @@ class sdl92Lexer(Lexer):
_type = ENDSTATE
_channel = DEFAULT_CHANNEL
# sdl92.g:1494:17: ( E N D S T A T E )
# sdl92.g:1494:25: E N D S T A T E
# sdl92.g:1496:17: ( E N D S T A T E )
# sdl92.g:1496:25: E N D S T A T E
pass
self.mE()
......@@ -1617,8 +1617,8 @@ class sdl92Lexer(Lexer):
_type = INPUT
_channel = DEFAULT_CHANNEL
# sdl92.g:1495:17: ( I N P U T )
# sdl92.g:1495:25: I N P U T
# sdl92.g:1497:17: ( I N P U T )
# sdl92.g:1497:25: I N P U T
pass
self.mI()
......@@ -1652,8 +1652,8 @@ class sdl92Lexer(Lexer):
_type = PROVIDED
_channel = DEFAULT_CHANNEL
# sdl92.g:1496:17: ( P R O V I D E D )
# sdl92.g:1496:25: P R O V I D E D
# sdl92.g:1498:17: ( P R O V I D E D )
# sdl92.g:1498:25: P R O V I D E D
pass
self.mP()
......@@ -1696,8 +1696,8 @@ class sdl92Lexer(Lexer):
_type = PRIORITY
_channel = DEFAULT_CHANNEL
# sdl92.g:1497:17: ( P R I O R I T Y )
# sdl92.g:1497:25: P R I O R I T Y
# sdl92.g:1499:17: ( P R I O R I T Y )
# sdl92.g:1499:25: P R I O R I T Y
pass
self.mP()
......@@ -1740,8 +1740,8 @@ class sdl92Lexer(Lexer):
_type = SAVE
_channel = DEFAULT_CHANNEL
# sdl92.g:1498:17: ( S A V E )
# sdl92.g:1498:25: S A V E
# sdl92.g:1500:17: ( S A V E )
# sdl92.g:1500:25: S A V E
pass
self.mS()
......@@ -1772,8 +1772,8 @@ class sdl92Lexer(Lexer):
_type = NONE
_channel = DEFAULT_CHANNEL
# sdl92.g:1499:17: ( N O N E )
# sdl92.g:1499:25: N O N E
# sdl92.g:1501:17: ( N O N E )
# sdl92.g:1501:25: N O N E
pass
self.mN()
......@@ -1804,8 +1804,8 @@ class sdl92Lexer(Lexer):
_type = FOR
_channel = DEFAULT_CHANNEL
# sdl92.g:1506:17: ( F O R )
# sdl92.g:1506:25: F O R
# sdl92.g:1508:17: ( F O R )
# sdl92.g:1508:25: F O R
pass
self.mF()
......@@ -1833,8 +1833,8 @@ class sdl92Lexer(Lexer):
_type = ENDFOR
_channel = DEFAULT_CHANNEL
# sdl92.g:1507:17: ( E N D F O R )
# sdl92.g:1507:25: E N D F O R
# sdl92.g:1509:17: ( E N D F O R )
# sdl92.g:1509:25: E N D F O R
pass
self.mE()
......@@ -1871,8 +1871,8 @@ class sdl92Lexer(Lexer):
_type = RANGE
_channel = DEFAULT_CHANNEL
# sdl92.g:1508:17: ( R A N G E )
# sdl92.g:1508:25: R A N G E
# sdl92.g:1510:17: ( R A N G E )
# sdl92.g:1510:25: R A N G E
pass
self.mR()
......@@ -1906,8 +1906,8 @@ class sdl92Lexer(Lexer):
_type = NEXTSTATE
_channel = DEFAULT_CHANNEL
# sdl92.g:1509:17: ( N E X T S T A T E )
# sdl92.g:1509:25: N E X T S T A T E
# sdl92.g:1511:17: ( N E X T S T A T E )
# sdl92.g:1511:25: N E X T S T A T E
pass
self.mN()
......@@ -1953,8 +1953,8 @@ class sdl92Lexer(Lexer):
_type = ANSWER
_channel = DEFAULT_CHANNEL
# sdl92.g:1510:17: ( A N S W E R )
# sdl92.g:1510:25: A N S W E R
# sdl92.g:1512:17: ( A N S W E R )
# sdl92.g:1512:25: A N S W E R
pass
self.mA()
......@@ -1991,8 +1991,8 @@ class sdl92Lexer(Lexer):
_type = COMMENT
_channel = DEFAULT_CHANNEL
# sdl92.g:1511:17: ( C O M M E N T )
# sdl92.g:1511:25: C O M M E N T
# sdl92.g:1513:17: ( C O M M E N T )
# sdl92.g:1513:25: C O M M E N T
pass
self.mC()
......@@ -2032,8 +2032,8 @@ class sdl92Lexer(Lexer):
_type = LABEL
_channel = DEFAULT_CHANNEL
# sdl92.g:1512:17: ( L A B E L )
# sdl92.g:1512:25: L A B E L
# sdl92.g:1514:17: ( L A B E L )
# sdl92.g:1514:25: L A B E L
pass
self.mL()
......@@ -2067,8 +2067,8 @@ class sdl92Lexer(Lexer):
_type = STOP
_channel = DEFAULT_CHANNEL
# sdl92.g:1513:17: ( S T O P )
# sdl92.g:1513:25: S T O P
# sdl92.g:1515:17: ( S T O P )
# sdl92.g:1515:25: S T O P
pass
self.mS()
......@@ -2099,8 +2099,8 @@ class sdl92Lexer(Lexer):
_type = IF
_channel = DEFAULT_CHANNEL
# sdl92.g:1514:17: ( I F )
# sdl92.g:1514:25: I F
# sdl92.g:1516:17: ( I F )
# sdl92.g:1516:25: I F
pass
self.mI()
......@@ -2125,8 +2125,8 @@ class sdl92Lexer(Lexer):
_type = THEN
_channel = DEFAULT_CHANNEL
# sdl92.g:1515:17: ( T H E N )
# sdl92.g:1515:25: T H E N
# sdl92.g:1517:17: ( T H E N )
# sdl92.g:1517:25: T H E N
pass
self.mT()
......@@ -2157,8 +2157,8 @@ class sdl92Lexer(Lexer):
_type = ELSE
_channel = DEFAULT_CHANNEL
# sdl92.g:1516:17: ( E L S E )
# sdl92.g:1516:25: E L S E
# sdl92.g:1518:17: ( E L S E )
# sdl92.g:1518:25: E L S E
pass
self.mE()
......@@ -2189,8 +2189,8 @@ class sdl92Lexer(Lexer):
_type = FI
_channel = DEFAULT_CHANNEL
# sdl92.g:1517:17: ( F I )
# sdl92.g:1517:25: F I
# sdl92.g:1519:17: ( F I )
# sdl92.g:1519:25: F I
pass
self.mF()
......@@ -2215,8 +2215,8 @@ class sdl92Lexer(Lexer):
_type = CREATE
_channel = DEFAULT_CHANNEL
# sdl92.g:1518:17: ( C R E A T E )
# sdl92.g:1518:25: C R E A T E
# sdl92.g:1520:17: ( C R E A T E )
# sdl92.g:1520:25: C R E A T E
pass
self.mC()
......@@ -2253,8 +2253,8 @@ class sdl92Lexer(Lexer):
_type = OUTPUT
_channel = DEFAULT_CHANNEL
# sdl92.g:1519:17: ( O U T P U T )
# sdl92.g:1519:25: O U T P U T
# sdl92.g:1521:17: ( O U T P U T )
# sdl92.g:1521:25: O U T P U T
pass
self.mO()
......@@ -2291,8 +2291,8 @@ class sdl92Lexer(Lexer):
_type = CALL
_channel = DEFAULT_CHANNEL
# sdl92.g:1520:17: ( C A L L )
# sdl92.g:1520:25: C A L L
# sdl92.g:1522:17: ( C A L L )
# sdl92.g:1522:25: C A L L
pass
self.mC()
......@@ -2323,8 +2323,8 @@ class sdl92Lexer(Lexer):
_type = THIS
_channel = DEFAULT_CHANNEL
# sdl92.g:1521:17: ( T H I S )
# sdl92.g:1521:25: T H I S
# sdl92.g:1523:17: ( T H I S )
# sdl92.g:1523:25: T H I S
pass
self.mT()
......@@ -2355,8 +2355,8 @@ class sdl92Lexer(Lexer):
_type = SET
_channel = DEFAULT_CHANNEL
# sdl92.g:1522:17: ( S E T )
# sdl92.g:1522:25: S E T
# sdl92.g:1524:17: ( S E T )
# sdl92.g:1524:25: S E T
pass
self.mS()
......@@ -2384,8 +2384,8 @@ class sdl92Lexer(Lexer):
_type = RESET
_channel = DEFAULT_CHANNEL
# sdl92.g:1523:17: ( R E S E T )
# sdl92.g:1523:25: R E S E T
# sdl92.g:1525:17: ( R E S E T )
# sdl92.g:1525:25: R E S E T
pass
self.mR()
......@@ -2419,8 +2419,8 @@ class sdl92Lexer(Lexer):
_type = ENDALTERNATIVE
_channel = DEFAULT_CHANNEL
# sdl92.g:1524:17: ( E N D A L T E R N A T I V E )
# sdl92.g:1524:25: E N D A L T E R N A T I V E
# sdl92.g:1526:17: ( E N D A L T E R N A T I V E )
# sdl92.g:1526:25: E N D A L T E R N A T I V E
pass
self.mE()
......@@ -2481,8 +2481,8 @@ class sdl92Lexer(Lexer):
_type = ALTERNATIVE
_channel = DEFAULT_CHANNEL
# sdl92.g:1525:17: ( A L T E R N A T I V E )
# sdl92.g:1525:25: A L T E R N A T I V E
# sdl92.g:1527:17: ( A L T E R N A T I V E )
# sdl92.g:1527:25: A L T E R N A T I V E
pass
self.mA()
......@@ -2534,8 +2534,8 @@ class sdl92Lexer(Lexer):
_type = DEFAULT
_channel = DEFAULT_CHANNEL
# sdl92.g:1526:17: ( D E F A U L T )
# sdl92.g:1526:25: D E F A U L T
# sdl92.g:1528:17: ( D E F A U L T )
# sdl92.g:1528:25: D E F A U L T