From 8de37bfa4cd251544800bc30ccb1c8650884e329 Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 16 Apr 2015 19:41:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/annimon/everlastingsummer/Parser.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/com/annimon/everlastingsummer/Parser.java b/src/com/annimon/everlastingsummer/Parser.java index cdae92b..cfaf965 100644 --- a/src/com/annimon/everlastingsummer/Parser.java +++ b/src/com/annimon/everlastingsummer/Parser.java @@ -80,6 +80,7 @@ public final class Parser { terminal = statement(); } catch (RuntimeException re) { Logger.log("Parser.next()", re); + if (tokens.isEmpty()) return; } // антизацикливание counter++; @@ -447,25 +448,25 @@ public final class Parser { if (lookMatch(1, TokenType.EQ)) { if (match(TokenType.EQ)) { // == - match(TokenType.EQ); + consume(TokenType.EQ); expression = new BinaryExpression(Operator.EQUALS, expression, additive()); continue; } if (match(TokenType.GT)) { // >= - match(TokenType.EQ); + consume(TokenType.EQ); expression = new BinaryExpression(Operator.GTEQ, expression, additive()); continue; } if (match(TokenType.LT)) { // <= - match(TokenType.EQ); + consume(TokenType.EQ); expression = new BinaryExpression(Operator.LTEQ, expression, additive()); continue; } if (match(TokenType.EXCL)) { // != - match(TokenType.EQ); + consume(TokenType.EQ); expression = new BinaryExpression(Operator.NOTEQUALS, expression, additive()); continue; } @@ -552,9 +553,10 @@ public final class Parser { // Расчёт уровня меню. if (lookMatch(pos, TokenType.MENU) && lookMatch(pos + 1, TokenType.COLON)) { level++; - pos++; + pos += 2; } if (lookMatch(pos, TokenType.ENDMENU)) { + pos++; level--; // Завершаем работу по достижению ENDMENU первого уровня. if (level <= 0) break; @@ -570,9 +572,10 @@ public final class Parser { while (true) { if (lookMatch(pos, TokenType.IF)) level++; else if (lookMatch(pos, TokenType.ENDIF)) { + pos++; level--; if (level <= 0) break; - } + } else if (lookMatch(pos, TokenType.EOF)) break; pos++; } return pos;