summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
Diffstat (limited to 'monkey')
-rwxr-xr-xmonkey/monkey.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/monkey/monkey.py b/monkey/monkey.py
index 8f57235..fd11868 100755
--- a/monkey/monkey.py
+++ b/monkey/monkey.py
@@ -260,29 +260,28 @@ def fix(name, code, edits, aux_code='', timeout=30, debug=False):
return '', [], total_time, n_tested
-# Return a list of pairs (range, message) describing edits in [path].
+# Return tuples (type, start, end, message) describing edits in [path].
def fix_hints(code, path):
program = list(annotate(code))
- messages = []
for step_type, idx, a, b in path:
if step_type == 'add_rule':
- type = 'insert'
+ fix_type = 'insert'
msg = 'Add another rule.'
start = program[idx].pos-1
end = start+2
elif step_type == 'add_part':
- type = 'insert'
+ fix_type = 'insert'
msg = 'Add another goal to this rule.'
start = program[idx].pos-1
end = start+2
elif step_type == 'remove_rule':
- type = 'remove'
+ fix_type = 'remove'
msg = 'Remove this rule.'
start = program[idx].pos
end = program[idx + len(a) - 1].pos
elif step_type == 'remove_part':
- type = 'remove'
+ fix_type = 'remove'
msg = 'Remove this goal.'
start = program[idx].pos
end = idx + len(a) - 1
@@ -290,7 +289,7 @@ def fix_hints(code, path):
end -= 1
end = program[end].pos + len(program[end].val)
elif step_type == 'change_part':
- type = 'change'
+ fix_type = 'change'
msg = 'Check this part.'
first = 0
while idx+first < len(program)-1 and first < len(a) and first < len(b) and a[first] == b[first]:
@@ -300,8 +299,6 @@ def fix_hints(code, path):
last -= 1
start = program[idx+first].pos
end = program[idx+last].pos + len(program[idx+last].val)
- messages.append(({'type': type, 'start': start, 'end': end}, msg))
program[idx:idx+len(a)] = [t.clone(pos=program[idx].pos) for t in b]
-
- return messages
+ yield fix_type, start, end, msg