improved handling of extra arguments in DiscardParser

drop
Marc Zinnschlag 8 years ago
parent f9607a47b3
commit 46e32de350

@ -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;
}
}

@ -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

@ -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')
{

Loading…
Cancel
Save