Use 1-based row and column values for position values - close #30
This commit is contained in:
1 parent
98e10d3d14
commit
1d468b6d3c
14 files changed
+303
-299
No files matched your search
+4
-2
@@ -60,6 +60,8 @@ void <%= @grammar.prefix %>context_init(<%= @grammar.prefix %>context_t * contex
|
||||
/* Lexer initialization. */
|
||||
newcontext.input = input;
|
||||
newcontext.input_length = input_length;
|
||||
newcontext.text_position.row = 1u;
|
||||
newcontext.text_position.col = 1u;
|
||||
newcontext.mode = <%= @lexer.mode_id("default") %>;
|
||||
|
||||
/* Copy to the user's context structure. */
|
||||
@@ -365,7 +367,7 @@ static size_t find_longest_match(<%= @grammar.prefix %>context_t * context,
|
||||
if (code_point == '\n')
|
||||
{
|
||||
attempt_match.delta_position.row++;
|
||||
attempt_match.delta_position.col = 0u;
|
||||
attempt_match.delta_position.col = 1u;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -567,7 +569,7 @@ size_t <%= @grammar.prefix %>lex(<%= @grammar.prefix %>context_t * context, <%=
|
||||
*************************************************************************/
|
||||
|
||||
/** Invalid position value. */
|
||||
#define INVALID_POSITION (<%= @grammar.prefix %>position_t){0xFFFFFFFFu, 0xFFFFFFFFu}
|
||||
#define INVALID_POSITION (<%= @grammar.prefix %>position_t){0u, 0u}
|
||||
|
||||
/** Reduce ID type. */
|
||||
typedef <%= get_type_for(@parser.reduce_table.size) %> reduce_id_t;
|
||||
|
||||
+5
-3
@@ -65,12 +65,12 @@ public struct <%= @grammar.prefix %>position_t
|
||||
uint col;
|
||||
|
||||
/** Invalid position value. */
|
||||
enum INVALID = <%= @grammar.prefix %>position_t(0xFFFF_FFFF, 0xFFFF_FFFF);
|
||||
enum INVALID = <%= @grammar.prefix %>position_t(0u, 0u);
|
||||
|
||||
/** Return whether the position is valid. */
|
||||
public @property bool valid()
|
||||
{
|
||||
return row != 0xFFFF_FFFFu;
|
||||
return row != 0u;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,6 +235,8 @@ public void <%= @grammar.prefix %>context_init(<%= @grammar.prefix %>context_t *
|
||||
|
||||
/* Lexer initialization. */
|
||||
newcontext.input = input;
|
||||
newcontext.text_position.row = 1u;
|
||||
newcontext.text_position.col = 1u;
|
||||
newcontext.mode = <%= @lexer.mode_id("default") %>;
|
||||
|
||||
/* Copy to the user's context structure. */
|
||||
@@ -534,7 +536,7 @@ private size_t find_longest_match(<%= @grammar.prefix %>context_t * context,
|
||||
if (code_point == '\n')
|
||||
{
|
||||
attempt_match.delta_position.row++;
|
||||
attempt_match.delta_position.col = 0u;
|
||||
attempt_match.delta_position.col = 1u;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ typedef struct
|
||||
} <%= @grammar.prefix %>position_t;
|
||||
|
||||
/** Return whether the position is valid. */
|
||||
#define <%= @grammar.prefix %>position_valid(p) ((p).row != 0xFFFFFFFFu)
|
||||
#define <%= @grammar.prefix %>position_valid(p) ((p).row != 0u)
|
||||
|
||||
/** User header code blocks. */
|
||||
<%= @grammar.code_blocks.fetch("header", "") %>
|
||||
|
||||
Reference in new issue
Block a user