diff options
author | Timotej Lazar <timotej.lazar@araneo.org> | 2014-05-06 18:38:06 +0200 |
---|---|---|
committer | Aleš Smodiš <aless@guru.si> | 2015-08-11 14:26:00 +0200 |
commit | 185b174f7585f76fc33bc815b02e94e1907b702d (patch) | |
tree | a31386f2d9e32dee0e42c84413e6ad6cb57fc1f7 | |
parent | 170fb9c4cb46464360cafe2d4ced1267746b372a (diff) |
Fix two bugs in prolog.util.decompose
-rw-r--r-- | prolog/util.py | 7 |
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 |