X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=rpl.py;h=b848afa756a6188a60d29a446bdd51d1e455b74a;hb=16e7952b7cc32ca21498fa3a12fb79f679ea8c21;hp=b51edefcce07b40e01a984f5e263dc944bc01342;hpb=0c6d29f73e35adbbaab1263de439f73efa98d99e;p=picoclvr.git diff --git a/rpl.py b/rpl.py index b51edef..b848afa 100755 --- a/rpl.py +++ b/rpl.py @@ -75,9 +75,9 @@ def generate( result_stack = rpl_exec(prog, stack) if len(result_stack) == 0: no_empty_stack = False - result = result + [""] + stack + [""] + result_stack + result = result + [""] + stack + [""] + result_stack - result = result + [""] + prog + result = result + [""] + prog result = result + [""] if no_empty_stack and ( @@ -103,11 +103,11 @@ def next_marker(seq, tokens, start=0): def decompose(seq): io = [] k = 0 - while seq[k] == "": - o = next_marker(seq, [""], start=k + 1) + while seq[k] == "": + o = next_marker(seq, [""], start=k + 1) if o is None: raise ValueError("Missing output markers (should be correct in the prompt)") - e = next_marker(seq, ["", ""], start=o) + e = next_marker(seq, ["", ""], start=o) if e is None: raise ValueError( "Missing input/output markers (should be correct in the prompt)" @@ -123,14 +123,14 @@ def decompose(seq): k = e - if seq[k] == "": + if seq[k] == "": e = next_marker(seq, [""], start=k) if e is None: prog = [] else: prog = seq[k + 1 : e] else: - raise ValueError("Missing (it should be in the prompt)") + raise ValueError("Missing (it should be in the prompt)") return prog, io