Correct the positioning of the error caret

When an error occurs midway through a token, like abc(def,
make the caret point at the location of the error (i.e. the paren)
instead of at the beginning of the token.
This commit is contained in:
ridiculousfish
2015-08-10 18:30:44 -07:00
parent 6157a9a858
commit e34a8da5d7
4 changed files with 96 additions and 22 deletions

View File

@@ -79,13 +79,16 @@ struct tok_t
/* If an error, this is the error code */
enum tokenizer_error error;
/* If an error, this is the offset of the error within the token. A value of 0 means it occurred at 'offset' */
size_t error_offset;
/* Offset of the token */
size_t offset;
/* Length of the token */
size_t length;
tok_t() : type(TOK_NONE), error(TOK_ERROR_NONE), offset(-1), length(-1) {}
tok_t() : type(TOK_NONE), error(TOK_ERROR_NONE), error_offset(-1), offset(-1), length(-1) {}
};
/**
@@ -119,13 +122,15 @@ class tokenizer_t
bool show_blank_lines;
/** Last error */
tokenizer_error error;
/** Last error offset, in "global" coordinates (relative to orig_buff) */
size_t global_error_offset;
/* Whether we are squashing errors */
bool squash_errors;
/* Whether to continue the previous line after the comment */
bool continue_line_after_comment;
void call_error(enum tokenizer_error error_type, const wchar_t *error_message);
void call_error(enum tokenizer_error error_type, const wchar_t *where, const wchar_t *error_message);
void read_string();
void read_comment();
void tok_next();