mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 21:11:50 +00:00
add Lua code tokenizer
This commit is contained in:
parent
3e6e897ce8
commit
28f49ac948
5 changed files with 256 additions and 0 deletions
35
src/coders/lua_parsing.hpp
Normal file
35
src/coders/lua_parsing.hpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace lua {
|
||||
struct Location {
|
||||
int pos;
|
||||
int lineStart;
|
||||
int line;
|
||||
};
|
||||
|
||||
enum class TokenTag {
|
||||
KEYWORD, NAME, INTEGER, NUMBER, OPEN_BRACKET, CLOSE_BRACKET, STRING,
|
||||
OPERATOR, COMMA, SEMICOLON, UNEXPECTED
|
||||
};
|
||||
|
||||
struct Token {
|
||||
TokenTag tag;
|
||||
std::string text;
|
||||
Location start;
|
||||
Location end;
|
||||
|
||||
Token(TokenTag tag, std::string text, Location start, Location end)
|
||||
: tag(tag),
|
||||
text(std::move(text)),
|
||||
start(std::move(start)),
|
||||
end(std::move(end)) {
|
||||
}
|
||||
};
|
||||
|
||||
bool is_lua_keyword(std::string_view view);
|
||||
|
||||
std::vector<Token> tokenize(std::string_view file, std::string_view source);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue