2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit b2bc5810 authored by eckhart's avatar eckhart
Browse files

- ebnf.py: default reset method added to compiler sub

parent bfa26ef0
...@@ -90,8 +90,8 @@ class Compiler: ...@@ -90,8 +90,8 @@ class Compiler:
""" """
def __init__(self, grammar_name="", grammar_source=""): def __init__(self, grammar_name="", grammar_source=""):
self._reset()
self.set_grammar_name(grammar_name, grammar_source) self.set_grammar_name(grammar_name, grammar_source)
self._reset()
def _reset(self): def _reset(self):
self.tree = None # type: Optional[RootNode] self.tree = None # type: Optional[RootNode]
......
...@@ -481,7 +481,10 @@ class EBNFCompiler(Compiler): ...@@ -481,7 +481,10 @@ class EBNFCompiler(Compiler):
self.grammar_name + '", grammar_source=""):', self.grammar_name + '", grammar_source=""):',
' super(' + self.grammar_name + ' super(' + self.grammar_name +
'Compiler, self).__init__(grammar_name, grammar_source)', 'Compiler, self).__init__(grammar_name, grammar_source)',
r" assert re.match('\w+\Z', grammar_name)", ''] r" assert re.match('\w+\Z', grammar_name)", '',
' def _reset(self):',
' super()._reset()',
' # initialize your variables here, not in the constructor!']
for name in self.rules: for name in self.rules:
method_name = Compiler.method_name(name) method_name = Compiler.method_name(name)
if name == self.root_symbol: if name == self.root_symbol:
......
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