Skip to content

Commit

Permalink
Improve tree printing in processor
Browse files Browse the repository at this point in the history
Fix the ID of the default rule in tree_print and improve the error
message if it's not used properly.
  • Loading branch information
renatahodovan committed Jun 3, 2024
1 parent a9d891d commit 8a12639
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions grammarinator/tool/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ def imag_rules(self):

def print_tree(self, root=None):
if not root and not self.default_rule:
raise ValueError('Either `root` must be defined or `print` should be called after `default_rule` is set.')
(root or self.vertices[self.default_rule]).print_tree()
raise ValueError('Either `root` must be defined or `print_tree` should be called after `default_rule` is set.')
(root or self.vertices[(self.default_rule,)]).print_tree()

def add_node(self, node):
self.vertices[node.id] = node
Expand Down

0 comments on commit 8a12639

Please sign in to comment.