Blang/src/include/Token.hpp

48 lines
783 B
C++
Raw Normal View History

2016-04-22 21:46:31 +02:00
#ifndef TOKEN_HPP
#define TOKEN_HPP
#include <string>
#include "SourceLocation.hpp"
namespace Blang{
2016-08-11 15:11:45 +02:00
class Token{
public:
2016-04-22 21:46:31 +02:00
2016-08-11 15:11:45 +02:00
enum TokenKind{
Token_StringLiteral,
Token_NumberLiteral,
Token_Operator,
Token_Keyword,
Token_Identifier,
Token_EndOfStatement,
Token_Unknown,
Token_Whitespace,
Token_LeftDelimiter,
Token_RightDelimiter
};
2016-04-22 21:46:31 +02:00
2016-08-11 15:11:45 +02:00
Token(TokenKind kind, const std::string& txt);
2016-04-22 21:46:31 +02:00
2016-08-11 15:11:45 +02:00
void setText(std::string);
std::string text();
2016-04-22 21:46:31 +02:00
2016-08-11 15:11:45 +02:00
void setKind(TokenKind);
TokenKind kind();
2016-04-22 21:46:31 +02:00
2016-08-11 15:11:45 +02:00
const Token& operator=(Token const & second) const;
2016-04-22 21:46:31 +02:00
2016-08-11 15:11:45 +02:00
bool operator==(Token const & second) const;
2016-04-22 21:46:31 +02:00
2016-08-11 15:11:45 +02:00
private:
SourceLocation _loc;
2016-04-22 21:46:31 +02:00
2016-08-11 15:11:45 +02:00
std::string _text;
2016-04-22 21:46:31 +02:00
2016-08-11 15:11:45 +02:00
TokenKind _kind;
};
2016-04-22 21:46:31 +02:00
}
#endif