From 28116fd8278bb3b8832f4f5b22c68bd7978c8efd Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 27 Sep 2016 16:14:00 +0200 Subject: Incorporate some tweaks to the monkey methods --- prolog/util.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'prolog') diff --git a/prolog/util.py b/prolog/util.py index e1ce36b..402b920 100644 --- a/prolog/util.py +++ b/prolog/util.py @@ -144,6 +144,12 @@ def rename_vars_ast(root, fixed_names=None): # Yield "interesting" parts of a Prolog AST as lists of tokens. def interesting_ranges(ast, path=()): if ast.label() in {'clause', 'head', 'or', 'if', 'and'}: + if ast.label() == 'clause': + # Special case for clause with one goal. + if len(ast) == 4 and ast[2].label() == 'term': + terminals = ast[2].leaves() + yield terminals, path + (ast.label(), 'and') + if ast.label() == 'and': for i in range(0, len(ast), 2): for j in range(i, len(ast), 2): -- cgit v1.2.1