Fix user guide and generated parser comments for position row and col to be 1-based

This commit is contained in:
Josh Holtrop 2026-07-01 23:02:47 -04:00
parent cb914e8bb0
commit c28aebddb4
3 changed files with 6 additions and 6 deletions

View File

@ -59,10 +59,10 @@ public alias <%= @grammar.prefix %>code_point_t = uint;
*/ */
public struct <%= @grammar.prefix %>position_t public struct <%= @grammar.prefix %>position_t
{ {
/** Input text row (0-based). */ /** Input text row (1-based). */
uint row; uint row;
/** Input text column (0-based). */ /** Input text column (1-based). */
uint col; uint col;
/** Invalid position value. */ /** Invalid position value. */

View File

@ -45,10 +45,10 @@ typedef uint32_t <%= @grammar.prefix %>code_point_t;
*/ */
typedef struct typedef struct
{ {
/** Input text row (0-based). */ /** Input text row (1-based). */
uint32_t row; uint32_t row;
/** Input text column (0-based). */ /** Input text column (1-based). */
uint32_t col; uint32_t col;
} <%= @grammar.prefix %>position_t; } <%= @grammar.prefix %>position_t;

View File

@ -1346,7 +1346,7 @@ if (p_parse(context) == P_UNEXPECTED_TOKEN)
{ {
p_position_t error_position = p_position(context); p_position_t error_position = p_position(context);
fprintf(stderr, "Error: unexpected token at row %u column %u\n", fprintf(stderr, "Error: unexpected token at row %u column %u\n",
error_position.row + 1, error_position.col + 1); error_position.row, error_position.col);
} }
``` ```
@ -1474,7 +1474,7 @@ if (p_parse(context) == P_UNEXPECTED_TOKEN)
p_position_t error_position = p_position(context); p_position_t error_position = p_position(context);
fprintf(stderr, "Error: unexpected token `%s' at row %u column %u\n", fprintf(stderr, "Error: unexpected token `%s' at row %u column %u\n",
p_token_names[context->token], p_token_names[context->token],
error_position.row + 1, error_position.col + 1); error_position.row, error_position.col);
} }
``` ```