Add string literals
This commit is contained in:
@@ -5,71 +5,71 @@
|
||||
|
||||
namespace Interpret
|
||||
{
|
||||
struct TokenError : public std::exception
|
||||
struct InterpretationError : public std::exception
|
||||
{
|
||||
Token::Token errorToken;
|
||||
std::string errorMsg;
|
||||
TokenError(Token::Token const & token, std::string const & msg);
|
||||
InterpretationError(Token::Token const & token, std::string const & msg);
|
||||
};
|
||||
|
||||
struct ExpectedArgument : public TokenError
|
||||
struct ExpectedArgument : public InterpretationError
|
||||
{
|
||||
ExpectedArgument(Token::Token const & token);
|
||||
};
|
||||
|
||||
struct ExpectedLabel : public TokenError
|
||||
struct ExpectedLabel : public InterpretationError
|
||||
{
|
||||
ExpectedLabel(Token::Token const & token);
|
||||
};
|
||||
|
||||
struct ExpectedValue : public TokenError
|
||||
struct ExpectedValue : public InterpretationError
|
||||
{
|
||||
ExpectedValue(Token::Token const & token);
|
||||
};
|
||||
|
||||
struct ExpectedImmediate : public TokenError
|
||||
struct ExpectedImmediate : public InterpretationError
|
||||
{
|
||||
ExpectedImmediate(Token::Token const & token);
|
||||
};
|
||||
|
||||
struct ExpectedImmediateOrMemory : public TokenError
|
||||
struct ExpectedImmediateOrMemory : public InterpretationError
|
||||
{
|
||||
ExpectedImmediateOrMemory(Token::Token const & token);
|
||||
};
|
||||
|
||||
struct ExpectedRegister : public TokenError
|
||||
struct ExpectedRegister : public InterpretationError
|
||||
{
|
||||
ExpectedRegister(Token::Token const & token);
|
||||
};
|
||||
|
||||
struct ExpectedRegisterOrMemory : public TokenError
|
||||
struct ExpectedRegisterOrMemory : public InterpretationError
|
||||
{
|
||||
ExpectedRegisterOrMemory(Token::Token const & token);
|
||||
};
|
||||
|
||||
struct ExpectedOperand : public TokenError
|
||||
struct ExpectedOperand : public InterpretationError
|
||||
{
|
||||
ExpectedOperand(Token::Token const & token);
|
||||
};
|
||||
|
||||
struct TooManyArguments : public TokenError
|
||||
struct TooManyArguments : public InterpretationError
|
||||
{
|
||||
TooManyArguments(Token::Token const & token);
|
||||
};
|
||||
|
||||
struct TooFewArguments : public TokenError
|
||||
struct TooFewArguments : public InterpretationError
|
||||
{
|
||||
TooFewArguments(Token::Token const & token);
|
||||
};
|
||||
|
||||
struct MissingEndOfStatment : public TokenError
|
||||
struct MissingEndOfStatment : public InterpretationError
|
||||
{
|
||||
MissingEndOfStatment(Token::Token const & token);
|
||||
};
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
struct BadTokenForValue : public TokenError
|
||||
struct BadTokenForValue : public InterpretationError
|
||||
{
|
||||
BadTokenForValue(Token::Token const & token);
|
||||
};
|
||||
|
||||
18
include/token/errors.hpp
Normal file
18
include/token/errors.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include <stdexcept>
|
||||
#include <token/token.hpp>
|
||||
|
||||
namespace Token
|
||||
{
|
||||
struct TokenizationError : public std::exception
|
||||
{
|
||||
Token errorToken;
|
||||
std::string errorMsg;
|
||||
TokenizationError(Token const & token, std::string const & msg);
|
||||
};
|
||||
|
||||
struct MissingEndOfString : public TokenizationError
|
||||
{
|
||||
MissingEndOfString(Token const & token);
|
||||
};
|
||||
}
|
||||
@@ -42,6 +42,7 @@ namespace Token
|
||||
static Token CreateOperandToken(OperandType const operandType, int const lineNumber, int const lineColumn);
|
||||
static Token CreateMemoryToken(RegisterType const registerType, int const lineNumber, int const lineColumn);
|
||||
static Token CreateMemoryToken(int const value, bool isValid, int const lineNumber, int const lineColumn);
|
||||
static Token CreateStringLiteralToken(std::string const & value, int const lineNumber, int const lineColumn);
|
||||
|
||||
void DebugPrint() const;
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Token
|
||||
Register,
|
||||
StatementEnd,
|
||||
Label,
|
||||
String,
|
||||
Memory
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user