summaryrefslogtreecommitdiff
path: root/parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'parser.py')
-rw-r--r--parser.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/parser.py b/parser.py
index 410ae3b..ee494cb 100644
--- a/parser.py
+++ b/parser.py
@@ -106,6 +106,11 @@ class Parser(object):
self.loader = loader
if self.loader is not None and getattr(self.loader, '_parser', None) is None:
self.loader._parser = self
+ self.reset_parser()
+
+ def reset_parser(self):
+ # type: () -> None
+ # Reset the state attributes (to clear self-references)
self.current_event = None
self.yaml_version = None
self.tag_handles = {} # type: Dict[Any, Any]
@@ -113,6 +118,9 @@ class Parser(object):
self.marks = [] # type: List[Any]
self.state = self.parse_stream_start # type: Any
+ def dispose(self):
+ self.reset_parser()
+
@property
def scanner(self):
# type: () -> Any
@@ -127,12 +135,6 @@ class Parser(object):
self.loader.resolver
return self.loader._resolver
- def dispose(self):
- # type: () -> None
- # Reset the state attributes (to clear self-references)
- self.states = []
- self.state = None
-
def check_event(self, *choices):
# type: (Any) -> bool
# Check the type of the next event.