forked from OctaForge/libcubescript
remove slice_until
parent
3744dec1f0
commit
d01349886a
|
@ -13,7 +13,7 @@ ostd::string_range cs_gen_state::get_str() {
|
||||||
ostd::string_range beg = source;
|
ostd::string_range beg = source;
|
||||||
source = util::parse_string(cs, source, nl);
|
source = util::parse_string(cs, source, nl);
|
||||||
current_line += nl - 1;
|
current_line += nl - 1;
|
||||||
ostd::string_range ret = slice_until(beg, source);
|
ostd::string_range ret = beg.slice(0, &source[0] - &beg[0]);
|
||||||
return ret.slice(1, ret.size() - 1);
|
return ret.slice(1, ret.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ ostd::string_range cs_gen_state::read_macro_name() {
|
||||||
for (; isalnum(c) || (c == '_'); c = current()) {
|
for (; isalnum(c) || (c == '_'); c = current()) {
|
||||||
next_char();
|
next_char();
|
||||||
}
|
}
|
||||||
return slice_until(op, source);
|
return op.slice(0, &source[0] - &op[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
char cs_gen_state::skip_until(ostd::string_range chars) {
|
char cs_gen_state::skip_until(ostd::string_range chars) {
|
||||||
|
@ -95,7 +95,7 @@ void cs_gen_state::skip_comments() {
|
||||||
ostd::string_range cs_gen_state::get_word() {
|
ostd::string_range cs_gen_state::get_word() {
|
||||||
auto beg = source;
|
auto beg = source;
|
||||||
source = util::parse_word(cs, source);
|
source = util::parse_word(cs, source);
|
||||||
return slice_until(beg, source);
|
return beg.slice(0, &source[0] - &beg[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int cs_ret_code(int type, int def = 0) {
|
static inline int cs_ret_code(int type, int def = 0) {
|
||||||
|
@ -497,9 +497,9 @@ static bool compileblockstr(cs_gen_state &gs, ostd::string_range str, bool macro
|
||||||
str.pop_front();
|
str.pop_front();
|
||||||
break;
|
break;
|
||||||
case '\"': {
|
case '\"': {
|
||||||
ostd::string_range start = str;
|
auto start = str;
|
||||||
str = util::parse_string(gs.cs, str);
|
str = util::parse_string(gs.cs, str);
|
||||||
ostd::string_range strr = slice_until(start, str);
|
auto strr = start.slice(0, &str[0] - &start[0]);
|
||||||
memcpy(&buf[len], strr.data(), strr.size());
|
memcpy(&buf[len], strr.data(), strr.size());
|
||||||
len += strr.size();
|
len += strr.size();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -229,7 +229,7 @@ end:
|
||||||
nlines = nl;
|
nlines = nl;
|
||||||
if (str.empty() || (*str != '\"')) {
|
if (str.empty() || (*str != '\"')) {
|
||||||
throw cs_error(
|
throw cs_error(
|
||||||
cs, "unfinished string '%s'", slice_until(orig, str)
|
cs, "unfinished string '%s'", orig.slice(0, &str[0] - &orig[0])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
str.pop_front();
|
str.pop_front();
|
||||||
|
@ -306,7 +306,7 @@ end:
|
||||||
case '"':
|
case '"':
|
||||||
p_quote = p_input;
|
p_quote = p_input;
|
||||||
p_input = parse_string(p_state, p_input);
|
p_input = parse_string(p_state, p_input);
|
||||||
p_quote = slice_until(p_quote, p_input);
|
p_quote = p_quote.slice(0, &p_input[0] - &p_quote[0]);
|
||||||
p_item = p_quote.slice(1, p_quote.size() - 1);
|
p_item = p_quote.slice(1, p_quote.size() - 1);
|
||||||
break;
|
break;
|
||||||
case '(':
|
case '(':
|
||||||
|
@ -351,9 +351,9 @@ end:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endblock:
|
endblock:
|
||||||
p_item = slice_until(p_item, p_input);
|
p_item = p_item.slice(0, &p_input[0] - &p_item[0]);
|
||||||
p_item.pop_back();
|
p_item.pop_back();
|
||||||
p_quote = slice_until(p_quote, p_input);
|
p_quote = p_quote.slice(0, &p_input[0] - &p_quote[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ')':
|
case ')':
|
||||||
|
@ -361,7 +361,7 @@ endblock:
|
||||||
return false;
|
return false;
|
||||||
default: {
|
default: {
|
||||||
ostd::string_range e = parse_word(p_state, p_input);
|
ostd::string_range e = parse_word(p_state, p_input);
|
||||||
p_quote = p_item = slice_until(p_input, e);
|
p_quote = p_item = p_input.slice(0, &e[0] - &p_input[0]);
|
||||||
p_input = e;
|
p_input = e;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,12 +38,6 @@ inline void cs_do_and_cleanup(F1 &&dof, F2 &&clf) {
|
||||||
dof();
|
dof();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ostd::string_range slice_until(
|
|
||||||
ostd::string_range s1, ostd::string_range s2
|
|
||||||
) {
|
|
||||||
return s1.slice(0, &s2[0] - &s1[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* namespace cscript */
|
} /* namespace cscript */
|
||||||
|
|
||||||
#endif /* LIBCUBESCRIPT_CS_UTIL_HH */
|
#endif /* LIBCUBESCRIPT_CS_UTIL_HH */
|
||||||
|
|
Loading…
Reference in New Issue