diff --git a/components/compiler/discardparser.cpp b/components/compiler/discardparser.cpp index da114fb3d..0e7c4718c 100644 --- a/components/compiler/discardparser.cpp +++ b/components/compiler/discardparser.cpp @@ -14,6 +14,9 @@ namespace Compiler { if (mState==StartState || mState==CommaState || mState==MinusState) { + if (isEmpty()) + mTokenLoc = loc; + start(); return false; } @@ -25,6 +28,9 @@ namespace Compiler { if (mState==StartState || mState==CommaState || mState==MinusState) { + if (isEmpty()) + mTokenLoc = loc; + start(); return false; } @@ -37,6 +43,9 @@ namespace Compiler { if (mState==StartState || mState==CommaState) { + if (isEmpty()) + mTokenLoc = loc; + start(); return false; } @@ -48,12 +57,22 @@ namespace Compiler { if (code==Scanner::S_comma && mState==StartState) { + if (isEmpty()) + mTokenLoc = loc; + + start(); + mState = CommaState; return true; } if (code==Scanner::S_minus && (mState==StartState || mState==CommaState)) { + if (isEmpty()) + mTokenLoc = loc; + + start(); + mState = MinusState; return true; } @@ -64,6 +83,12 @@ namespace Compiler void DiscardParser::reset() { mState = StartState; + mTokenLoc = TokenLoc(); Parser::reset(); } + + const TokenLoc& DiscardParser::getTokenLoc() const + { + return mTokenLoc; + } } diff --git a/components/compiler/discardparser.hpp b/components/compiler/discardparser.hpp index bee8a87bb..2a7ed5544 100644 --- a/components/compiler/discardparser.hpp +++ b/components/compiler/discardparser.hpp @@ -2,6 +2,7 @@ #define COMPILER_DISCARDPARSER_H_INCLUDED #include "parser.hpp" +#include "tokenloc.hpp" namespace Compiler { @@ -14,6 +15,7 @@ namespace Compiler }; State mState; + TokenLoc mTokenLoc; public: @@ -38,8 +40,11 @@ namespace Compiler virtual void reset(); ///< Reset parser to clean state. + + /// Returns TokenLoc object for value. If no value has been parsed, the TokenLoc + /// object will be default initialised. + const TokenLoc& getTokenLoc() const; }; } #endif - diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 37c20527e..7c61ad0ee 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -832,7 +832,7 @@ namespace Compiler if (discardParser.isEmpty()) break; else - getErrorHandler().warning("Ignoring extra argument", mTokenLoc); + getErrorHandler().warning("Ignoring extra argument", discardParser.getTokenLoc()); } else if (*iter=='j') {