const struct lex_token *t0,
const struct lex_token *t1)
{
+ int first_column = lex_token_get_first_column (src, t0);
+ int last_line = lex_token_get_last_line_number (src, t1) - 1;
+ int last_column = lex_token_get_last_column (src, t1) - 1;
return (struct msg_location) {
.file_name = intern_new_if_nonnull (src->reader->file_name),
- .first_line = t0->first_line,
- .last_line = lex_token_get_last_line_number (src, t1),
- .first_column = lex_token_get_first_column (src, t0),
- .last_column = lex_token_get_last_column (src, t1),
+ .p[0] = { .line = t0->first_line, .column = first_column },
+ .p[1] = { .line = last_line, .column = last_column },
};
}
lex_get_location (const struct lexer *lexer, int n0, int n1)
{
struct msg_location *loc = lex_get_lines (lexer, n0, n1);
- loc->first_column = lex_get_first_column (lexer, n0);
- loc->last_column = lex_get_last_column (lexer, n1);
+ loc->p[0].column = lex_get_first_column (lexer, n0);
+ loc->p[1].column = lex_get_last_column (lexer, n1) - 1;
return loc;
}
lex_get_lines (const struct lexer *lexer, int n0, int n1)
{
struct msg_location *loc = xmalloc (sizeof *loc);
+ int first_line = lex_get_first_line_number (lexer, n0);
+ int last_line = lex_get_last_line_number (lexer, n1) - 1;
*loc = (struct msg_location) {
.file_name = intern_new_if_nonnull (lex_get_file_name (lexer)),
- .first_line = lex_get_first_line_number (lexer, n0),
- .last_line = lex_get_last_line_number (lexer, n1),
+ .p[0] = { .line = first_line },
+ .p[1] = { .line = last_line },
};
return loc;
}
+void
+lex_extend_location (const struct lexer *lexer, int n, struct msg_location *loc)
+{
+ struct msg_location *new = lex_get_location (lexer, n, n);
+ msg_location_merge (loc, new);
+ msg_location_destroy (new);
+}
+
const char *
lex_get_encoding (const struct lexer *lexer)
{