summaryrefslogtreecommitdiff
path: root/prolog
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-09-27 16:14:00 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-09-27 16:14:00 +0200
commit28116fd8278bb3b8832f4f5b22c68bd7978c8efd (patch)
tree48c134e70d3e1d3502e1465c92ed80ba7a3315bb /prolog
parentb88aac8b26de977f17e27645fd3d0412a6420f53 (diff)
Incorporate some tweaks to the monkey methods
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):