1#ifndef CODEX_LUA_PARSER_H
2#define CODEX_LUA_PARSER_H
11 constexpr std::string_view
name(std::string_view
s)
const;
16 std::array<item, MAX>
v;
18 constexpr state push(
node n, std::string_view name, std::string_view
s);
26 return this->
push(n_, this->
orig_s.substr(0, 0), s_);
30 node n_, std::string_view name, std::string_view s_)
34 const auto b = begin(this->
orig_s);
38 .str_b =
static_cast<std::size_t
>(std::distance(
b, begin(name))),
39 .str_e =
static_cast<std::size_t
>(std::distance(
b, end(name))),
56 throw "invalid identifier";
57 const auto name = std::string_view{begin(
s.s), i};
58 if(!
v.empty() &&
v != name)
59 throw "unexpected identifier";
60 return s.push(node::identifier, name, {i, end(
s.s)});
65 std::string_view name =
s.s;
67 name = {begin(name), begin(
s.s)};
68 return s.push(node::number, name,
s.s);
74 std::string_view name =
s.s;
76 name = {begin(name), begin(
s.s)};
78 return s.push(node::string, name,
s.s);
93 throw "invalid expression";
99 s =
s.
push(node::table_begin,
s.s);
106 }
while(
s.s[0] !=
'}');
109 s =
s.push(node::table_end,
s.s);
114 s =
s.
push(node::table_key,
s.s);
122 if(
const char c =
s.s[0];
c ==
'}')
129 s =
s.push(node::table_value,
s.s);
139template<fixed_
string s>
141 static constexpr auto input =
s;
144 std::array<state::item, MAX>
v;
149template<fixed_
string s>
156 throw "trailing content";
constexpr std::string_view consume_set(std::string_view s)
Definition lexer.hpp:47
constexpr bool set_contains(char c)
Definition lexer.hpp:36
constexpr std::string_view ignore_interm(std::string_view s)
Definition lexer.hpp:17
constexpr std::string_view consume(std::string_view s, std::string_view c)
Definition lexer.hpp:29
constexpr std::string_view consume_set_comp(std::string_view s)
Definition lexer.hpp:52
constexpr state parse_expression(state s)
Definition parser.hpp:81
constexpr state parse_string(state s)
Definition parser.hpp:71
constexpr state parse_table(state s)
Definition parser.hpp:98
constexpr state parse_table_item(state s)
Definition parser.hpp:113
constexpr state parse_ident(state s, std::string_view v="")
Definition parser.hpp:52
constexpr state parse_number(state s)
Definition parser.hpp:63
constexpr auto parse(void)
Definition parser.hpp:150
Definition parser.hpp:142
std::array< state::item, MAX > v
Definition parser.hpp:144
std::size_t n
Definition parser.hpp:143
Definition parser.hpp:140
struct parser::output output
bool ok
Definition parser.hpp:146
node n
Definition parser.hpp:9
constexpr std::string_view name(std::string_view s) const
Definition parser.hpp:21
std::size_t str_e
Definition parser.hpp:10
std::size_t level
Definition parser.hpp:10
std::size_t str_b
Definition parser.hpp:10
std::size_t n
Definition parser.hpp:14
constexpr state push(node n, std::string_view s)
Definition parser.hpp:25
bool ok
Definition parser.hpp:15
std::size_t level
Definition parser.hpp:14
std::array< item, MAX > v
Definition parser.hpp:16
std::string_view s
Definition parser.hpp:13
std::string_view orig_s
Definition parser.hpp:13
constexpr fixed_string s
Definition test.cpp:6