From cd9b13712921be4c61968e7959cff2b287f6fc17 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 2 Feb 2014 14:24:58 +0100 Subject: [PATCH] allow elseif without matching if (grrrrr) --- components/compiler/controlparser.cpp | 6 +++++- components/compiler/scriptparser.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/compiler/controlparser.cpp b/components/compiler/controlparser.cpp index 5d74ee9d42..3be470c273 100644 --- a/components/compiler/controlparser.cpp +++ b/components/compiler/controlparser.cpp @@ -7,6 +7,7 @@ #include "scanner.hpp" #include "generator.hpp" +#include "errorhandler.hpp" namespace Compiler { @@ -186,8 +187,11 @@ namespace Compiler { if (mState==StartState) { - if (keyword==Scanner::K_if) + if (keyword==Scanner::K_if || keyword==Scanner::K_elseif) { + if (keyword==Scanner::K_elseif) + getErrorHandler().warning ("elseif without matching if", loc); + mExprParser.reset(); scanner.scan (mExprParser); diff --git a/components/compiler/scriptparser.cpp b/components/compiler/scriptparser.cpp index 5b3d244b0d..1b613595a6 100644 --- a/components/compiler/scriptparser.cpp +++ b/components/compiler/scriptparser.cpp @@ -32,7 +32,7 @@ namespace Compiler bool ScriptParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner) { - if (keyword==Scanner::K_while || keyword==Scanner::K_if) + if (keyword==Scanner::K_while || keyword==Scanner::K_if || keyword==Scanner::K_elseif) { mControlParser.reset(); if (mControlParser.parseKeyword (keyword, loc, scanner))