summaryrefslogtreecommitdiff
path: root/prolog
diff options
context:
space:
mode:
Diffstat (limited to 'prolog')
-rw-r--r--prolog/util.py6
1 files changed, 6 insertions, 0 deletions
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):