Browse Source

Adjust PR - Change warning to debug

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.0
Erez Sh 4 years ago
parent
commit
16f2f73d15
2 changed files with 5 additions and 7 deletions
  1. +1
    -1
      lark/parsers/earley.py
  2. +4
    -6
      lark/parsers/earley_forest.py

+ 1
- 1
lark/parsers/earley.py View File

@@ -316,7 +316,7 @@ class Parser:

if self.tree_class is not None:
# Perform our SPPF -> AST conversion
transformer = ForestToParseTree(self.tree_class, self.callbacks, self.forest_sum_visitor and self.forest_sum_visitor(), self.resolve_ambiguity, self.debug)
transformer = ForestToParseTree(self.tree_class, self.callbacks, self.forest_sum_visitor and self.forest_sum_visitor(), self.resolve_ambiguity)
return transformer.transform(solutions[0])

# return the root of the SPPF


+ 4
- 6
lark/parsers/earley_forest.py View File

@@ -483,22 +483,20 @@ class ForestToParseTree(ForestTransformer):
tree.
"""

def __init__(self, tree_class=Tree, callbacks=dict(), prioritizer=ForestSumVisitor(), resolve_ambiguity=True, debug=False):
def __init__(self, tree_class=Tree, callbacks=dict(), prioritizer=ForestSumVisitor(), resolve_ambiguity=True):
super(ForestToParseTree, self).__init__()
self.tree_class = tree_class
self.callbacks = callbacks
self.prioritizer = prioritizer
self.resolve_ambiguity = resolve_ambiguity
self.debug = debug
self._on_cycle_retreat = False
self._cycle_node = None
self._successful_visits = set()

def on_cycle(self, node, path):
if self.debug:
logger.warning("Cycle encountered in the SPPF at node: %s. "
"As infinite ambiguities cannot be represented in a tree, "
"this family of derivations will be discarded.", node)
logger.debug("Cycle encountered in the SPPF at node: %s. "
"As infinite ambiguities cannot be represented in a tree, "
"this family of derivations will be discarded.", node)
self._cycle_node = node
self._on_cycle_retreat = True



Loading…
Cancel
Save