summaryrefslogtreecommitdiff
path: root/monkey/monkey.py
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-02-04 23:48:56 +0100
committerAleš Smodiš <aless@guru.si>2015-08-11 14:26:01 +0200
commit4838e37e26c3fb72ad509d7aef7f307cc7ae3ef2 (patch)
treee09c3f476bf0d056cb7ddfcce8a68636327b74a6 /monkey/monkey.py
parent92066f4993343037c79c93ecbedd2fdb22011320 (diff)
Small cleanups
Diffstat (limited to 'monkey/monkey.py')
-rwxr-xr-xmonkey/monkey.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/monkey/monkey.py b/monkey/monkey.py
index 07d6b0a..e185630 100755
--- a/monkey/monkey.py
+++ b/monkey/monkey.py
@@ -8,16 +8,20 @@ from prolog.engine import test
from prolog.util import Token, compose, decompose, map_vars, rename_vars, stringify
from .util import PQueue
-# Starting from [code], find a sequence of [edits] that transforms it into a
+# Starting from [code], find a sequence of edits that transforms it into a
# correct predicate for [name]. Append [aux_code] when testing (available facts
# and predicates).
# Return (solution, edits, time spent, #programs checked). If no solution is
# found within [timeout] seconds, solution='' and edits=[].
-def fix(name, code, edits, aux_code='', timeout=30, debug=False):
+def fix(name, code, edits, program_lines, aux_code='', timeout=30, debug=False):
+ # A dictionary of edits with costs for each edit type (insert, remove or
+ # change a line). Edits are tuples (before, after), where before and after
+ # are sequences of tokens. Variable names are normalized to A0, A1, A2,….
+ inserts, removes, changes = classify_edits(edits)
+
# Generate states that can be reached from the given program with one edit.
# Program code is given as a list of [lines], where each line is a list of
# tokens. Rule ranges are given in [rules] (see prolog.util.decompose).
- inserts, removes, changes = classify_edits(edits)
def step(lines, rules, prev=None):
# Apply edits in order from top to bottom; skip lines with index lower
# than last step.