diff --git a/include/cubescript/cubescript.hh b/include/cubescript/cubescript.hh index 7581921..082d20b 100644 --- a/include/cubescript/cubescript.hh +++ b/include/cubescript/cubescript.hh @@ -768,6 +768,7 @@ namespace util { void skip(); bool parse(); + ostd::Size parse(ostd::Size n); ostd::Size count(); CsString element() const; @@ -776,10 +777,6 @@ private: CsState &p_state; }; - OSTD_EXPORT ostd::Maybe list_index( - CsState &cs, ostd::ConstCharRange s, ostd::Size idx - ); - template inline ostd::Ptrdiff format_int(R &&writer, CsInt val) { return ostd::format(ostd::forward(writer), IntFormat, val); diff --git a/src/cs_util.cc b/src/cs_util.cc index 16d788c..2e977e9 100644 --- a/src/cs_util.cc +++ b/src/cs_util.cc @@ -372,6 +372,17 @@ endblock: return true; } + ostd::Size ListParser::parse(ostd::Size n) { + ostd::Size ret = 0; + for (ostd::Size i = 0; i < n; ++i) { + if (!parse()) { + return ret; + } + ++ret; + } + return ret; + } + ostd::Size ListParser::count() { ostd::Size ret = 0; while (parse()) { @@ -394,21 +405,6 @@ endblock: s.advance(item.size()); return s; } - - OSTD_EXPORT ostd::Maybe list_index( - CsState &cs, ostd::ConstCharRange s, ostd::Size idx - ) { - ListParser p(cs, s); - for (ostd::Size i = 0; i < idx; ++i) { - if (!p.parse()) { - return ostd::nothing; - } - } - if (!p.parse()) { - return ostd::nothing; - } - return ostd::move(p.element()); - } } /* namespace util */ } /* namespace cscript */