Clean up tokenizer implementation

Rather than storing a bunch of "next_foo" fields, simply populate the
tok_t directly.
This commit is contained in:
ridiculousfish
2018-02-23 14:30:15 -08:00
parent e9a4875a6b
commit 6673fe5457
7 changed files with 122 additions and 130 deletions

View File

@@ -379,7 +379,7 @@ void parse_util_token_extent(const wchar_t *buff, size_t cursor_pos, const wchar
// Calculate end of token.
if (token.type == TOK_STRING) {
tok_end += token.text.size();
tok_end += token.length;
}
// Cursor was before beginning of this token, means that the cursor is between two tokens,
@@ -393,14 +393,14 @@ void parse_util_token_extent(const wchar_t *buff, size_t cursor_pos, const wchar
// and break.
if (token.type == TOK_STRING && tok_end >= offset_within_cmdsubst) {
a = cmdsubst_begin + token.offset;
b = a + token.text.size();
b = a + token.length;
break;
}
// Remember previous string token.
if (token.type == TOK_STRING) {
pa = cmdsubst_begin + token.offset;
pb = pa + token.text.size();
pb = pa + token.length;
}
}
@@ -479,7 +479,8 @@ void parse_util_get_parameter_info(const wcstring &cmd, const size_t pos, wchar_
while (tok.next(&token)) {
if (token.offset > pos) break;
if (token.type == TOK_STRING) last_quote = get_quote(token.text, pos - token.offset);
if (token.type == TOK_STRING)
last_quote = get_quote(tok.text_of(token), pos - token.offset);
if (out_type != NULL) *out_type = token.type;