Browse Source

Merge pull request #243 from evandrocoan/pydot_tree_orientation

Allow to passing "rankdir" to lark/tree.py:pydot__tree_to_png
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.6.5
Erez Shinan 6 years ago
committed by GitHub
parent
commit
4a51ebc3d3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions
  1. +9
    -3
      lark/tree.py

+ 9
- 3
lark/tree.py View File

@@ -128,11 +128,17 @@ class SlottedTree(Tree):
__slots__ = 'data', 'children', 'rule', '_meta'


def pydot__tree_to_png(tree, filename):
"Creates a colorful image that represents the tree (data+children, without meta)"
def pydot__tree_to_png(tree, filename, rankdir="LR"):
"""Creates a colorful image that represents the tree (data+children, without meta)

Possible values for `rankdir` are "TB", "LR", "BT", "RL", corresponding to
directed graphs drawn from top to bottom, from left to right, from bottom to
top, and from right to left, respectively. See:
https://www.graphviz.org/doc/info/attrs.html#k:rankdir
"""

import pydot
graph = pydot.Dot(graph_type='digraph', rankdir="LR")
graph = pydot.Dot(graph_type='digraph', rankdir=rankdir)

i = [0]



Loading…
Cancel
Save