15bool Const(
const std::string& str, std::span<const char>& sp)
17 if ((
size_t)sp.size() >= str.size() && std::equal(str.begin(), str.end(), sp.begin())) {
18 sp = sp.subspan(str.size());
24bool Func(
const std::string& str, std::span<const char>& sp)
26 if ((
size_t)sp.size() >= str.size() + 2 && sp[str.size()] ==
'(' && sp[sp.size() - 1] ==
')' && std::equal(str.begin(), str.end(), sp.begin())) {
27 sp = sp.subspan(str.size() + 1, sp.size() - str.size() - 2);
33std::span<const char>
Expr(std::span<const char>& sp)
37 while (it != sp.end()) {
38 if (*it ==
'(' || *it ==
'{') {
40 }
else if (level && (*it ==
')' || *it ==
'}')) {
42 }
else if (level == 0 && (*it ==
')' || *it ==
'}' || *it ==
',')) {
47 std::span<const char>
ret = sp.first(it - sp.begin());
48 sp = sp.subspan(it - sp.begin());
std::span< const char > Expr(std::span< const char > &sp)
Extract the expression that sp begins with.
bool Const(const std::string &str, std::span< const char > &sp)
Parse a constant.
bool Func(const std::string &str, std::span< const char > &sp)
Parse a function call.