improved handling of extra arguments in DiscardParser

drop
Marc Zinnschlag 9 years ago
parent f9607a47b3
commit 46e32de350

@ -14,6 +14,9 @@ namespace Compiler
{ {
if (mState==StartState || mState==CommaState || mState==MinusState) if (mState==StartState || mState==CommaState || mState==MinusState)
{ {
if (isEmpty())
mTokenLoc = loc;
start(); start();
return false; return false;
} }
@ -25,6 +28,9 @@ namespace Compiler
{ {
if (mState==StartState || mState==CommaState || mState==MinusState) if (mState==StartState || mState==CommaState || mState==MinusState)
{ {
if (isEmpty())
mTokenLoc = loc;
start(); start();
return false; return false;
} }
@ -37,6 +43,9 @@ namespace Compiler
{ {
if (mState==StartState || mState==CommaState) if (mState==StartState || mState==CommaState)
{ {
if (isEmpty())
mTokenLoc = loc;
start(); start();
return false; return false;
} }
@ -48,12 +57,22 @@ namespace Compiler
{ {
if (code==Scanner::S_comma && mState==StartState) if (code==Scanner::S_comma && mState==StartState)
{ {
if (isEmpty())
mTokenLoc = loc;
start();
mState = CommaState; mState = CommaState;
return true; return true;
} }
if (code==Scanner::S_minus && (mState==StartState || mState==CommaState)) if (code==Scanner::S_minus && (mState==StartState || mState==CommaState))
{ {
if (isEmpty())
mTokenLoc = loc;
start();
mState = MinusState; mState = MinusState;
return true; return true;
} }
@ -64,6 +83,12 @@ namespace Compiler
void DiscardParser::reset() void DiscardParser::reset()
{ {
mState = StartState; mState = StartState;
mTokenLoc = TokenLoc();
Parser::reset(); Parser::reset();
} }
const TokenLoc& DiscardParser::getTokenLoc() const
{
return mTokenLoc;
}
} }

@ -2,6 +2,7 @@
#define COMPILER_DISCARDPARSER_H_INCLUDED #define COMPILER_DISCARDPARSER_H_INCLUDED
#include "parser.hpp" #include "parser.hpp"
#include "tokenloc.hpp"
namespace Compiler namespace Compiler
{ {
@ -14,6 +15,7 @@ namespace Compiler
}; };
State mState; State mState;
TokenLoc mTokenLoc;
public: public:
@ -38,8 +40,11 @@ namespace Compiler
virtual void reset(); virtual void reset();
///< Reset parser to clean state. ///< 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 #endif

@ -832,7 +832,7 @@ namespace Compiler
if (discardParser.isEmpty()) if (discardParser.isEmpty())
break; break;
else else
getErrorHandler().warning("Ignoring extra argument", mTokenLoc); getErrorHandler().warning("Ignoring extra argument", discardParser.getTokenLoc());
} }
else if (*iter=='j') else if (*iter=='j')
{ {

Loading…
Cancel
Save