From c28aebddb41f70c3b134a6025463e6eb116746db Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 1 Jul 2026 23:02:47 -0400 Subject: [PATCH] Fix user guide and generated parser comments for position row and col to be 1-based --- assets/parser.d.erb | 4 ++-- assets/parser.h.erb | 4 ++-- doc/user_guide.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/parser.d.erb b/assets/parser.d.erb index 42ccf65..298c4f1 100644 --- a/assets/parser.d.erb +++ b/assets/parser.d.erb @@ -59,10 +59,10 @@ public alias <%= @grammar.prefix %>code_point_t = uint; */ public struct <%= @grammar.prefix %>position_t { - /** Input text row (0-based). */ + /** Input text row (1-based). */ uint row; - /** Input text column (0-based). */ + /** Input text column (1-based). */ uint col; /** Invalid position value. */ diff --git a/assets/parser.h.erb b/assets/parser.h.erb index 7e3100b..b54ca81 100644 --- a/assets/parser.h.erb +++ b/assets/parser.h.erb @@ -45,10 +45,10 @@ typedef uint32_t <%= @grammar.prefix %>code_point_t; */ typedef struct { - /** Input text row (0-based). */ + /** Input text row (1-based). */ uint32_t row; - /** Input text column (0-based). */ + /** Input text column (1-based). */ uint32_t col; } <%= @grammar.prefix %>position_t; diff --git a/doc/user_guide.md b/doc/user_guide.md index 6498563..f2d8b61 100644 --- a/doc/user_guide.md +++ b/doc/user_guide.md @@ -1346,7 +1346,7 @@ if (p_parse(context) == P_UNEXPECTED_TOKEN) { p_position_t error_position = p_position(context); 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); fprintf(stderr, "Error: unexpected token `%s' at row %u column %u\n", p_token_names[context->token], - error_position.row + 1, error_position.col + 1); + error_position.row, error_position.col); } ```