15bool Const(
const std::string& str, std::span<const char>&
sp,
bool skip)
17 if ((
size_t)
sp.size() >= str.size() && std::equal(str.begin(), str.end(),
sp.begin())) {
18 if (
skip)
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 Func(const std::string &str, std::span< const char > &sp)
Parse a function call.
bool Const(const std::string &str, std::span< const char > &sp, bool skip)
Parse a constant.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.