diff options
author | Timotej Lazar <timotej.lazar@araneo.org> | 2015-02-04 23:48:56 +0100 |
---|---|---|
committer | Aleš Smodiš <aless@guru.si> | 2015-08-11 14:26:01 +0200 |
commit | 4838e37e26c3fb72ad509d7aef7f307cc7ae3ef2 (patch) | |
tree | e09c3f476bf0d056cb7ddfcce8a68636327b74a6 /monkey/monkey.py | |
parent | 92066f4993343037c79c93ecbedd2fdb22011320 (diff) |
Small cleanups
Diffstat (limited to 'monkey/monkey.py')
-rwxr-xr-x | monkey/monkey.py | 10 |
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. |