summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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