48 lines
783 B
C++
48 lines
783 B
C++
#ifndef TOKEN_HPP
|
|
#define TOKEN_HPP
|
|
|
|
#include <string>
|
|
|
|
#include "SourceLocation.hpp"
|
|
|
|
namespace Blang{
|
|
class Token{
|
|
public:
|
|
|
|
enum TokenKind{
|
|
Token_StringLiteral,
|
|
Token_NumberLiteral,
|
|
Token_Operator,
|
|
Token_Keyword,
|
|
Token_Identifier,
|
|
Token_EndOfStatement,
|
|
Token_Unknown,
|
|
Token_Whitespace,
|
|
Token_LeftDelimiter,
|
|
Token_RightDelimiter
|
|
};
|
|
|
|
Token(TokenKind kind, const std::string& txt);
|
|
|
|
void setText(std::string);
|
|
std::string text();
|
|
|
|
void setKind(TokenKind);
|
|
TokenKind kind();
|
|
|
|
const Token& operator=(Token const & second) const;
|
|
|
|
bool operator==(Token const & second) const;
|
|
|
|
private:
|
|
SourceLocation _loc;
|
|
|
|
std::string _text;
|
|
|
|
TokenKind _kind;
|
|
|
|
};
|
|
}
|
|
|
|
#endif
|