소스 검색

Fixed bug in statechart XML parser (sibling_dict for parallel state was being reused)

Joeri Exelmans 5 년 전
부모
커밋
39a7b52222
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      src/sccd/statechart/parser/xml.py

+ 4 - 2
src/sccd/statechart/parser/xml.py

@@ -144,10 +144,12 @@ def statechart_parser_rules(globals, path, load_external = True, parse_f = parse
           elif len(state.children) > 1:
             raise XmlError("More than 1 child state: must set 'initial' attribute.")
 
-      def state_child_rules(parent, sibling_dict: Dict[str, State]={}):
+      def state_child_rules(parent, sibling_dict: Dict[str, State]):
 
         def common(el, constructor):
           short_name = require_attribute(el, "id")
+          if short_name == "":
+            raise XmlError("attribute 'id' must be non-empty string")
           state = constructor(short_name, parent)
 
           already_there = sibling_dict.setdefault(short_name, state)
@@ -170,7 +172,7 @@ def statechart_parser_rules(globals, path, load_external = True, parse_f = parse
 
         def parse_parallel(el):
           state = common_nonpseudo(el, ParallelState)
-          return state_child_rules(parent=state)
+          return state_child_rules(parent=state, sibling_dict={})
 
         def parse_history(el):
           history_type = el.get("type", "shallow")