#pragma once
#include <whiteout/common_types.h>
#include <cstddef>
#include <string_view>
#include <vector>
namespace whiteout {
namespace mdx {
enum class MdlTokenType : u8 {
Number, Identifier, String, OpenBrace, CloseBrace, OpenBracket, CloseBracket, Comma, Colon, Semicolon, Dot, LessEqual, EndOfFile,
Error,
};
struct MdlToken {
MdlTokenType type;
std::string_view text; u32 line; u32 column; };
class MdlTokenizer {
public:
static std::vector<MdlToken> tokenize(std::string_view source);
private:
MdlTokenizer(std::string_view source);
void run();
void skipWhitespaceAndComments();
void readNumber();
void readIdentifier();
void readString();
std::string_view m_source;
const char* m_cursor;
const char* m_end;
const char* m_lineStart; u32 m_line;
std::vector<MdlToken> m_tokens;
};
} }