From 185b174f7585f76fc33bc815b02e94e1907b702d Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 6 May 2014 18:38:06 +0200 Subject: Fix two bugs in prolog.util.decompose --- prolog/util.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'prolog') diff --git a/prolog/util.py b/prolog/util.py index eb026fe..6091b17 100644 --- a/prolog/util.py +++ b/prolog/util.py @@ -40,16 +40,17 @@ def decompose(code): rule_start = 0 for t in tokens: if t[0] == 'SEMI': - lines.append(line[:]) + if line != []: + lines.append(line[:]) + line = [] lines.append([t]) - line = [] continue if not parens: if t[0] in ('PERIOD', 'FROM', 'COMMA', 'EOF'): if line != []: lines.append(line[:]) line = [] - if t[0] in ('PERIOD', 'EOF'): + if t[0] in ('PERIOD', 'EOF') and rule_start < len(lines): rules.append((rule_start, len(lines))) rule_start = len(lines) continue -- cgit v1.2.1