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 ...@@ -123,8 +123,8 @@ The background pattern was downloaded from www.subtlepatterns.com
Changelog Changelog
========= =========
**3.1.3 (07/2020)** **3.2.0 (07/2020)**
- Fix issue finding ASN.1 files when model loaded from another folder - Add basic support for state type/instance
**3.1.2 (07/2020)** **3.1.2 (07/2020)**
- Reinforce syntax error checking and reporting - Reinforce syntax error checking and reporting
......
This diff is collapsed.
...@@ -3857,6 +3857,7 @@ def state(root, parent, context): ...@@ -3857,6 +3857,7 @@ def state(root, parent, context):
state_def.charPositionInLine = child.getCharPositionInLine() state_def.charPositionInLine = child.getCharPositionInLine()
state_def.statelist = [state_def.inputString] state_def.statelist = [state_def.inputString]
inst_stop = child.getTokenStopIndex() inst_stop = child.getTokenStopIndex()
via_stop = inst_stop # in case there is also a via clause
elif child.type == lexer.TYPE_INSTANCE: elif child.type == lexer.TYPE_INSTANCE:
# Extract the complete string "state: instance" # Extract the complete string "state: instance"
start = inst_stop start = inst_stop
...@@ -3926,8 +3927,8 @@ def state(root, parent, context): ...@@ -3926,8 +3927,8 @@ def state(root, parent, context):
.format(each, statename.lower())) .format(each, statename.lower()))
# then update the mapping state-input # then update the mapping state-input
context.mapping[statename.lower()].append(inp) context.mapping[statename.lower()].append(inp)
except KeyError: except KeyError as err:
stwarn.append('State definition missing') stwarn.append(f'State definition missing - {str(err)}')
state_def.inputs.append(inp) state_def.inputs.append(inp)
if inp.inputString.strip() == '*': if inp.inputString.strip() == '*':
if asterisk_input: if asterisk_input:
......
...@@ -140,7 +140,7 @@ except ImportError: ...@@ -140,7 +140,7 @@ except ImportError:
__all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse'] __all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse']
__version__ = '3.1.3' __version__ = '3.2.0'
if hasattr(sys, 'frozen'): if hasattr(sys, 'frozen'):
# Detect if we are running on Windows (py2exe-generated) # Detect if we are running on Windows (py2exe-generated)
......
This diff is collapsed.
This diff is collapsed.
...@@ -478,28 +478,30 @@ floating_label ...@@ -478,28 +478,30 @@ floating_label
-> ^(FLOATING_LABEL cif? hyperlink? connector_name transition?) -> ^(FLOATING_LABEL cif? hyperlink? connector_name transition?)
; ;
// state is either a full state definition, or a declaration of an instance // state is either a full state definition, or a state instance
state state
: state_definition : state_definition
| state_instance | state_instance
; ;
// the "via" part is needed to allow the graphical merge with a nextstate
state_definition state_definition
: cif? : cif?
hyperlink? hyperlink?
STATE statelist (e=end | SEMI) // "via" part may be in NEXTSTATE STATE statelist via? (e=end | SEMI)
(state_part)* (state_part)*
ENDSTATE statename? f=end ENDSTATE statename? f=end
-> ^(STATE cif? hyperlink? $e? statelist state_part*) -> ^(STATE cif? hyperlink? $e? statelist via? state_part*)
; ;
state_instance state_instance
: cif? : cif?
hyperlink? hyperlink?
STATE statename ':' type_inst e=end STATE statename ':' type_inst via? (e=end | SEMI)
(state_part)*
ENDSTATE statename? f=end ENDSTATE statename? f=end
-> ^(STATE cif? hyperlink? $e? statename type_inst) -> ^(STATE cif? hyperlink? $e? statename via? type_inst state_part*)
; ;
......
Supports Markdown
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