@herb-tools/node 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +0 -1
- package/dist/herb-node.esm.js +1 -1
- package/extension/error_helpers.cpp +1 -1
- package/extension/error_helpers.h +1 -1
- package/extension/extension_helpers.cpp +9 -27
- package/extension/extension_helpers.h +3 -3
- package/extension/libherb/analyze.c +43 -80
- package/extension/libherb/ast_node.c +10 -13
- package/extension/libherb/ast_node.h +3 -3
- package/extension/libherb/ast_nodes.c +32 -34
- package/extension/libherb/ast_nodes.h +33 -33
- package/extension/libherb/ast_pretty_print.c +1 -1
- package/extension/libherb/ast_pretty_print.h +1 -1
- package/extension/libherb/buffer.c +10 -1
- package/extension/libherb/errors.c +36 -36
- package/extension/libherb/errors.h +22 -22
- package/extension/libherb/include/ast_node.h +3 -3
- package/extension/libherb/include/ast_nodes.h +33 -33
- package/extension/libherb/include/ast_pretty_print.h +1 -1
- package/extension/libherb/include/errors.h +22 -22
- package/extension/libherb/include/lexer_peek_helpers.h +8 -6
- package/extension/libherb/include/lexer_struct.h +10 -9
- package/extension/libherb/include/location.h +10 -13
- package/extension/libherb/include/parser_helpers.h +1 -1
- package/extension/libherb/include/position.h +3 -14
- package/extension/libherb/include/pretty_print.h +1 -1
- package/extension/libherb/include/prism_helpers.h +1 -1
- package/extension/libherb/include/range.h +4 -13
- package/extension/libherb/include/token.h +0 -3
- package/extension/libherb/include/token_struct.h +2 -2
- package/extension/libherb/include/version.h +1 -1
- package/extension/libherb/lexer.c +3 -2
- package/extension/libherb/lexer_peek_helpers.c +10 -4
- package/extension/libherb/lexer_peek_helpers.h +8 -6
- package/extension/libherb/lexer_struct.h +10 -9
- package/extension/libherb/location.c +9 -37
- package/extension/libherb/location.h +10 -13
- package/extension/libherb/parser.c +98 -119
- package/extension/libherb/parser_helpers.c +15 -15
- package/extension/libherb/parser_helpers.h +1 -1
- package/extension/libherb/position.h +3 -14
- package/extension/libherb/pretty_print.c +7 -12
- package/extension/libherb/pretty_print.h +1 -1
- package/extension/libherb/prism_helpers.c +7 -7
- package/extension/libherb/prism_helpers.h +1 -1
- package/extension/libherb/range.c +2 -35
- package/extension/libherb/range.h +4 -13
- package/extension/libherb/token.c +25 -29
- package/extension/libherb/token.h +0 -3
- package/extension/libherb/token_struct.h +2 -2
- package/extension/libherb/version.h +1 -1
- package/extension/libherb/visitor.c +1 -1
- package/extension/nodes.cpp +1 -1
- package/extension/nodes.h +1 -1
- package/package.json +2 -2
- package/extension/libherb/position.c +0 -33
|
@@ -99,8 +99,8 @@ void parser_append_unexpected_error(parser_T* parser, const char* description, c
|
|
|
99
99
|
description,
|
|
100
100
|
expected,
|
|
101
101
|
token_type_to_string(token->type),
|
|
102
|
-
token->location
|
|
103
|
-
token->location
|
|
102
|
+
token->location.start,
|
|
103
|
+
token->location.end,
|
|
104
104
|
errors
|
|
105
105
|
);
|
|
106
106
|
|
|
@@ -111,8 +111,8 @@ void parser_append_unexpected_token_error(parser_T* parser, token_type_T expecte
|
|
|
111
111
|
append_unexpected_token_error(
|
|
112
112
|
expected_type,
|
|
113
113
|
parser->current_token,
|
|
114
|
-
parser->current_token->location
|
|
115
|
-
parser->current_token->location
|
|
114
|
+
parser->current_token->location.start,
|
|
115
|
+
parser->current_token->location.end,
|
|
116
116
|
errors
|
|
117
117
|
);
|
|
118
118
|
}
|
|
@@ -121,12 +121,12 @@ void parser_append_literal_node_from_buffer(
|
|
|
121
121
|
const parser_T* parser,
|
|
122
122
|
buffer_T* buffer,
|
|
123
123
|
array_T* children,
|
|
124
|
-
position_T
|
|
124
|
+
position_T start
|
|
125
125
|
) {
|
|
126
126
|
if (buffer_length(buffer) == 0) { return; }
|
|
127
127
|
|
|
128
128
|
AST_LITERAL_NODE_T* literal =
|
|
129
|
-
ast_literal_node_init(buffer_value(buffer), start, parser->current_token->location
|
|
129
|
+
ast_literal_node_init(buffer_value(buffer), start, parser->current_token->location.start, NULL);
|
|
130
130
|
|
|
131
131
|
if (children != NULL) { array_append(children, literal); }
|
|
132
132
|
buffer_clear(buffer);
|
|
@@ -149,7 +149,7 @@ token_T* parser_consume_expected(parser_T* parser, const token_type_T expected_t
|
|
|
149
149
|
if (token == NULL) {
|
|
150
150
|
token = parser_advance(parser);
|
|
151
151
|
|
|
152
|
-
append_unexpected_token_error(expected_type, token, token->location
|
|
152
|
+
append_unexpected_token_error(expected_type, token, token->location.start, token->location.end, array);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
return token;
|
|
@@ -162,8 +162,8 @@ AST_HTML_ELEMENT_NODE_T* parser_handle_missing_close_tag(
|
|
|
162
162
|
) {
|
|
163
163
|
append_missing_closing_tag_error(
|
|
164
164
|
open_tag->tag_name,
|
|
165
|
-
open_tag->tag_name->location
|
|
166
|
-
open_tag->tag_name->location
|
|
165
|
+
open_tag->tag_name->location.start,
|
|
166
|
+
open_tag->tag_name->location.end,
|
|
167
167
|
errors
|
|
168
168
|
);
|
|
169
169
|
|
|
@@ -174,8 +174,8 @@ AST_HTML_ELEMENT_NODE_T* parser_handle_missing_close_tag(
|
|
|
174
174
|
NULL,
|
|
175
175
|
false,
|
|
176
176
|
ELEMENT_SOURCE_HTML,
|
|
177
|
-
open_tag->base.location
|
|
178
|
-
open_tag->base.location
|
|
177
|
+
open_tag->base.location.start,
|
|
178
|
+
open_tag->base.location.end,
|
|
179
179
|
errors
|
|
180
180
|
);
|
|
181
181
|
}
|
|
@@ -192,15 +192,15 @@ void parser_handle_mismatched_tags(
|
|
|
192
192
|
append_tag_names_mismatch_error(
|
|
193
193
|
expected_tag,
|
|
194
194
|
actual_tag,
|
|
195
|
-
actual_tag->location
|
|
196
|
-
actual_tag->location
|
|
195
|
+
actual_tag->location.start,
|
|
196
|
+
actual_tag->location.end,
|
|
197
197
|
errors
|
|
198
198
|
);
|
|
199
199
|
} else {
|
|
200
200
|
append_missing_opening_tag_error(
|
|
201
201
|
close_tag->tag_name,
|
|
202
|
-
close_tag->tag_name->location
|
|
203
|
-
close_tag->tag_name->location
|
|
202
|
+
close_tag->tag_name->location.start,
|
|
203
|
+
close_tag->tag_name->location.end,
|
|
204
204
|
errors
|
|
205
205
|
);
|
|
206
206
|
}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
#ifndef HERB_POSITION_H
|
|
2
2
|
#define HERB_POSITION_H
|
|
3
3
|
|
|
4
|
-
#include <
|
|
4
|
+
#include <stdint.h>
|
|
5
5
|
|
|
6
6
|
typedef struct POSITION_STRUCT {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
uint32_t line;
|
|
8
|
+
uint32_t column;
|
|
9
9
|
} position_T;
|
|
10
10
|
|
|
11
|
-
position_T* position_init(size_t line, size_t column);
|
|
12
|
-
|
|
13
|
-
size_t position_line(const position_T* position);
|
|
14
|
-
size_t position_column(const position_T* position);
|
|
15
|
-
|
|
16
|
-
size_t position_sizeof(void);
|
|
17
|
-
|
|
18
|
-
position_T* position_copy(position_T* position);
|
|
19
|
-
|
|
20
|
-
void position_free(position_T* position);
|
|
21
|
-
|
|
22
11
|
#endif
|
|
@@ -158,16 +158,16 @@ void pretty_print_errors(
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
void pretty_print_location(location_T
|
|
161
|
+
void pretty_print_location(location_T location, buffer_T* buffer) {
|
|
162
162
|
buffer_append(buffer, "(location: (");
|
|
163
163
|
char location_string[128];
|
|
164
164
|
sprintf(
|
|
165
165
|
location_string,
|
|
166
|
-
"%
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
"%u,%u)-(%u,%u",
|
|
167
|
+
location.start.line,
|
|
168
|
+
location.start.column,
|
|
169
|
+
location.end.line,
|
|
170
|
+
location.end.column
|
|
171
171
|
);
|
|
172
172
|
buffer_append(buffer, location_string);
|
|
173
173
|
buffer_append(buffer, "))");
|
|
@@ -188,12 +188,7 @@ void pretty_print_position_property(
|
|
|
188
188
|
|
|
189
189
|
char position_string[128];
|
|
190
190
|
|
|
191
|
-
sprintf(
|
|
192
|
-
position_string,
|
|
193
|
-
"%zu:%zu",
|
|
194
|
-
(position->line) ? position->line : 0,
|
|
195
|
-
(position->column) ? position->column : 0
|
|
196
|
-
);
|
|
191
|
+
sprintf(position_string, "%u:%u", (position->line) ? position->line : 0, (position->column) ? position->column : 0);
|
|
197
192
|
|
|
198
193
|
buffer_append(buffer, position_string);
|
|
199
194
|
buffer_append(buffer, ")");
|
|
@@ -21,7 +21,7 @@ void pretty_print_position_property(
|
|
|
21
21
|
buffer_T* buffer
|
|
22
22
|
);
|
|
23
23
|
|
|
24
|
-
void pretty_print_location(location_T
|
|
24
|
+
void pretty_print_location(location_T location, buffer_T* buffer);
|
|
25
25
|
|
|
26
26
|
void pretty_print_property(
|
|
27
27
|
const char* name,
|
|
@@ -16,15 +16,15 @@ const char* pm_error_level_to_string(pm_error_level_t level) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
position_T
|
|
20
|
-
position_T
|
|
19
|
+
position_T position_from_source_with_offset(const char* source, size_t offset) {
|
|
20
|
+
position_T position = { .line = 1, .column = 0 };
|
|
21
21
|
|
|
22
22
|
for (size_t i = 0; i < offset; i++) {
|
|
23
23
|
if (is_newline(source[i])) {
|
|
24
|
-
position
|
|
25
|
-
position
|
|
24
|
+
position.line++;
|
|
25
|
+
position.column = 0;
|
|
26
26
|
} else {
|
|
27
|
-
position
|
|
27
|
+
position.column++;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -40,8 +40,8 @@ RUBY_PARSE_ERROR_T* ruby_parse_error_from_prism_error(
|
|
|
40
40
|
size_t start_offset = (size_t) (error->location.start - parser->start);
|
|
41
41
|
size_t end_offset = (size_t) (error->location.end - parser->start);
|
|
42
42
|
|
|
43
|
-
position_T
|
|
44
|
-
position_T
|
|
43
|
+
position_T start = position_from_source_with_offset(source, start_offset);
|
|
44
|
+
position_T end = position_from_source_with_offset(source, end_offset);
|
|
45
45
|
|
|
46
46
|
return ruby_parse_error_init(
|
|
47
47
|
error->message,
|
|
@@ -16,6 +16,6 @@ RUBY_PARSE_ERROR_T* ruby_parse_error_from_prism_error(
|
|
|
16
16
|
pm_parser_t* parser
|
|
17
17
|
);
|
|
18
18
|
|
|
19
|
-
position_T
|
|
19
|
+
position_T position_from_source_with_offset(const char* source, size_t offset);
|
|
20
20
|
|
|
21
21
|
#endif
|
|
@@ -1,38 +1,5 @@
|
|
|
1
1
|
#include "include/range.h"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
return
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
range_T* range_init(const size_t from, const size_t to) {
|
|
8
|
-
range_T* range = calloc(1, range_sizeof());
|
|
9
|
-
|
|
10
|
-
range->from = from;
|
|
11
|
-
range->to = to;
|
|
12
|
-
|
|
13
|
-
return range;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
size_t range_from(const range_T* range) {
|
|
17
|
-
return range->from;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
size_t range_to(const range_T* range) {
|
|
21
|
-
return range->to;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
size_t range_length(range_T* range) {
|
|
25
|
-
return range_to(range) - range_from(range);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
range_T* range_copy(range_T* range) {
|
|
29
|
-
if (!range) { return NULL; }
|
|
30
|
-
|
|
31
|
-
return range_init(range_from(range), range_to(range));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
void range_free(range_T* range) {
|
|
35
|
-
if (range == NULL) { return; }
|
|
36
|
-
|
|
37
|
-
free(range);
|
|
3
|
+
uint32_t range_length(range_T range) {
|
|
4
|
+
return range.to - range.from;
|
|
38
5
|
}
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
#ifndef HERB_RANGE_H
|
|
2
2
|
#define HERB_RANGE_H
|
|
3
3
|
|
|
4
|
+
#include <stdint.h>
|
|
4
5
|
#include <stdlib.h>
|
|
5
6
|
|
|
6
7
|
typedef struct RANGE_STRUCT {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
uint32_t from;
|
|
9
|
+
uint32_t to;
|
|
9
10
|
} range_T;
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
size_t range_from(const range_T* range);
|
|
14
|
-
size_t range_to(const range_T* range);
|
|
15
|
-
size_t range_length(range_T* range);
|
|
16
|
-
|
|
17
|
-
range_T* range_copy(range_T* range);
|
|
18
|
-
|
|
19
|
-
size_t range_sizeof(void);
|
|
20
|
-
|
|
21
|
-
void range_free(range_T* range);
|
|
12
|
+
uint32_t range_length(range_T range);
|
|
22
13
|
|
|
23
14
|
#endif
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#include "include/json.h"
|
|
3
3
|
#include "include/lexer.h"
|
|
4
4
|
#include "include/position.h"
|
|
5
|
+
#include "include/range.h"
|
|
5
6
|
#include "include/token_struct.h"
|
|
6
7
|
#include "include/util.h"
|
|
7
8
|
|
|
@@ -28,10 +29,15 @@ token_T* token_init(const char* value, const token_type_T type, lexer_T* lexer)
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
token->type = type;
|
|
31
|
-
token->range =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
token->range = (range_T) { .from = lexer->previous_position, .to = lexer->current_position };
|
|
33
|
+
|
|
34
|
+
location_from(
|
|
35
|
+
&token->location,
|
|
36
|
+
lexer->previous_line,
|
|
37
|
+
lexer->previous_column,
|
|
38
|
+
lexer->current_line,
|
|
39
|
+
lexer->current_column
|
|
40
|
+
);
|
|
35
41
|
|
|
36
42
|
lexer->previous_line = lexer->current_line;
|
|
37
43
|
lexer->previous_column = lexer->current_column;
|
|
@@ -84,7 +90,7 @@ const char* token_type_to_string(const token_type_T type) {
|
|
|
84
90
|
|
|
85
91
|
char* token_to_string(const token_T* token) {
|
|
86
92
|
const char* type_string = token_type_to_string(token->type);
|
|
87
|
-
const char* template = "#<Herb::Token type=\"%s\" value=\"%s\" range=[%
|
|
93
|
+
const char* template = "#<Herb::Token type=\"%s\" value=\"%s\" range=[%u, %u] start=(%u:%u) end=(%u:%u)>";
|
|
88
94
|
|
|
89
95
|
char* string = calloc(strlen(type_string) + strlen(template) + strlen(token->value) + 16, sizeof(char));
|
|
90
96
|
char* escaped;
|
|
@@ -100,12 +106,12 @@ char* token_to_string(const token_T* token) {
|
|
|
100
106
|
template,
|
|
101
107
|
type_string,
|
|
102
108
|
escaped,
|
|
103
|
-
token->range
|
|
104
|
-
token->range
|
|
105
|
-
token->location
|
|
106
|
-
token->location
|
|
107
|
-
token->location
|
|
108
|
-
token->location
|
|
109
|
+
token->range.from,
|
|
110
|
+
token->range.to,
|
|
111
|
+
token->location.start.line,
|
|
112
|
+
token->location.start.column,
|
|
113
|
+
token->location.end.line,
|
|
114
|
+
token->location.end.column
|
|
109
115
|
);
|
|
110
116
|
|
|
111
117
|
free(escaped);
|
|
@@ -122,24 +128,24 @@ char* token_to_json(const token_T* token) {
|
|
|
122
128
|
|
|
123
129
|
buffer_T range = buffer_new();
|
|
124
130
|
json_start_array(&json, "range");
|
|
125
|
-
json_add_size_t(&range, NULL, token->range
|
|
126
|
-
json_add_size_t(&range, NULL, token->range
|
|
131
|
+
json_add_size_t(&range, NULL, token->range.from);
|
|
132
|
+
json_add_size_t(&range, NULL, token->range.to);
|
|
127
133
|
buffer_concat(&json, &range);
|
|
128
134
|
buffer_free(&range);
|
|
129
135
|
json_end_array(&json);
|
|
130
136
|
|
|
131
137
|
buffer_T start = buffer_new();
|
|
132
138
|
json_start_object(&json, "start");
|
|
133
|
-
json_add_size_t(&start, "line", token->location
|
|
134
|
-
json_add_size_t(&start, "column", token->location
|
|
139
|
+
json_add_size_t(&start, "line", token->location.start.line);
|
|
140
|
+
json_add_size_t(&start, "column", token->location.start.column);
|
|
135
141
|
buffer_concat(&json, &start);
|
|
136
142
|
buffer_free(&start);
|
|
137
143
|
json_end_object(&json);
|
|
138
144
|
|
|
139
145
|
buffer_T end = buffer_new();
|
|
140
146
|
json_start_object(&json, "end");
|
|
141
|
-
json_add_size_t(&end, "line", token->location
|
|
142
|
-
json_add_size_t(&end, "column", token->location
|
|
147
|
+
json_add_size_t(&end, "line", token->location.end.line);
|
|
148
|
+
json_add_size_t(&end, "column", token->location.end.column);
|
|
143
149
|
buffer_concat(&json, &end);
|
|
144
150
|
buffer_free(&end);
|
|
145
151
|
json_end_object(&json);
|
|
@@ -157,14 +163,6 @@ int token_type(const token_T* token) {
|
|
|
157
163
|
return token->type;
|
|
158
164
|
}
|
|
159
165
|
|
|
160
|
-
position_T* token_start_position(token_T* token) {
|
|
161
|
-
return token->location->start;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
position_T* token_end_position(token_T* token) {
|
|
165
|
-
return token->location->end;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
166
|
token_T* token_copy(token_T* token) {
|
|
169
167
|
if (!token) { return NULL; }
|
|
170
168
|
|
|
@@ -184,8 +182,8 @@ token_T* token_copy(token_T* token) {
|
|
|
184
182
|
}
|
|
185
183
|
|
|
186
184
|
new_token->type = token->type;
|
|
187
|
-
new_token->range =
|
|
188
|
-
new_token->location =
|
|
185
|
+
new_token->range = token->range;
|
|
186
|
+
new_token->location = token->location;
|
|
189
187
|
|
|
190
188
|
return new_token;
|
|
191
189
|
}
|
|
@@ -194,8 +192,6 @@ void token_free(token_T* token) {
|
|
|
194
192
|
if (!token) { return; }
|
|
195
193
|
|
|
196
194
|
if (token->value != NULL) { free(token->value); }
|
|
197
|
-
if (token->range != NULL) { range_free(token->range); }
|
|
198
|
-
if (token->location != NULL) { location_free(token->location); }
|
|
199
195
|
|
|
200
196
|
free(token);
|
|
201
197
|
}
|
|
@@ -13,9 +13,6 @@ const char* token_type_to_string(token_type_T type);
|
|
|
13
13
|
char* token_value(const token_T* token);
|
|
14
14
|
int token_type(const token_T* token);
|
|
15
15
|
|
|
16
|
-
position_T* token_start_position(token_T* token);
|
|
17
|
-
position_T* token_end_position(token_T* token);
|
|
18
|
-
|
|
19
16
|
size_t token_sizeof(void);
|
|
20
17
|
|
|
21
18
|
token_T* token_copy(token_T* token);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.5/templates/src/visitor.c.erb
|
|
3
3
|
|
|
4
4
|
#include <stdio.h>
|
|
5
5
|
|
package/extension/nodes.cpp
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.5/templates/javascript/packages/node/extension/nodes.cpp.erb
|
|
3
3
|
|
|
4
4
|
#include <node_api.h>
|
|
5
5
|
#include "error_helpers.h"
|
package/extension/nodes.h
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
2
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.
|
|
2
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.7.5/templates/javascript/packages/node/extension/nodes.h.erb
|
|
3
3
|
|
|
4
4
|
#ifndef HERB_EXTENSION_NODES_H
|
|
5
5
|
#define HERB_EXTENSION_NODES_H
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herb-tools/node",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Native Node.js addon for HTML-aware ERB parsing using Herb.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"host": "https://github.com/marcoroth/herb/releases/download/"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@herb-tools/core": "0.7.
|
|
51
|
+
"@herb-tools/core": "0.7.5",
|
|
52
52
|
"@mapbox/node-pre-gyp": "^2.0.0",
|
|
53
53
|
"node-addon-api": "^5.1.0",
|
|
54
54
|
"node-pre-gyp-github": "^2.0.0"
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#include "include/position.h"
|
|
2
|
-
#include "include/memory.h"
|
|
3
|
-
|
|
4
|
-
size_t position_sizeof(void) {
|
|
5
|
-
return sizeof(position_T);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
position_T* position_init(const size_t line, const size_t column) {
|
|
9
|
-
position_T* position = safe_malloc(position_sizeof());
|
|
10
|
-
|
|
11
|
-
position->line = line;
|
|
12
|
-
position->column = column;
|
|
13
|
-
|
|
14
|
-
return position;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
size_t position_line(const position_T* position) {
|
|
18
|
-
return position->line;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
size_t position_column(const position_T* position) {
|
|
22
|
-
return position->column;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
position_T* position_copy(position_T* position) {
|
|
26
|
-
if (position == NULL) { return NULL; }
|
|
27
|
-
|
|
28
|
-
return position_init(position_line(position), position_column(position));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
void position_free(position_T* position) {
|
|
32
|
-
free(position);
|
|
33
|
-
}
|