From 4838e37e26c3fb72ad509d7aef7f307cc7ae3ef2 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 4 Feb 2015 23:48:56 +0100 Subject: Small cleanups --- monkey/monkey.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'monkey/monkey.py') 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. -- cgit v1.2.1