Skip to content

Commit

Permalink
Pydot now not necessary for earley debug, shows warning instead (Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
erezsh committed Sep 6, 2019
1 parent 54b18e5 commit deb325a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lark/parsers/earley.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
http://www.bramvandersanden.com/post/2014/06/shared-packed-parse-forest/
"""

import logging
from collections import deque

from ..visitors import Transformer_InPlace, v_args
Expand Down Expand Up @@ -299,8 +300,13 @@ def parse(self, stream, start):
solutions = [n.node for n in columns[-1] if n.is_complete and n.node is not None and n.s == start_symbol and n.start == 0]
if self.debug:
from .earley_forest import ForestToPyDotVisitor
debug_walker = ForestToPyDotVisitor()
debug_walker.visit(solutions[0], "sppf.png")
try:
debug_walker = ForestToPyDotVisitor()
except ImportError:
logging.warning("Cannot find dependency 'pydot', will not generate sppf debug image")
else:
debug_walker.visit(solutions[0], "sppf.png")


if not solutions:
expected_tokens = [t.expect for t in to_scan]
Expand Down

0 comments on commit deb325a

Please sign in to comment.