summaryrefslogtreecommitdiff
path: root/prolog/util.py
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2014-05-06 18:38:06 +0200
committerAleš Smodiš <aless@guru.si>2015-08-11 14:26:00 +0200
commit185b174f7585f76fc33bc815b02e94e1907b702d (patch)
treea31386f2d9e32dee0e42c84413e6ad6cb57fc1f7 /prolog/util.py
parent170fb9c4cb46464360cafe2d4ced1267746b372a (diff)
Fix two bugs in prolog.util.decompose
Diffstat (limited to 'prolog/util.py')
-rw-r--r--prolog/util.py7
1 files changed, 4 insertions, 3 deletions
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