herb 0.7.4-aarch64-linux-gnu → 0.8.0-aarch64-linux-gnu
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.
- checksums.yaml +4 -4
- data/Makefile +8 -5
- data/config.yml +40 -20
- data/ext/herb/error_helpers.c +57 -3
- data/ext/herb/error_helpers.h +1 -1
- data/ext/herb/extconf.rb +1 -0
- data/ext/herb/extension.c +10 -24
- data/ext/herb/extension_helpers.c +12 -18
- data/ext/herb/extension_helpers.h +4 -4
- data/ext/herb/nodes.c +72 -37
- data/herb.gemspec +0 -2
- data/lib/herb/3.0/herb.so +0 -0
- data/lib/herb/3.1/herb.so +0 -0
- data/lib/herb/3.2/herb.so +0 -0
- data/lib/herb/3.3/herb.so +0 -0
- data/lib/herb/3.4/herb.so +0 -0
- data/lib/herb/ast/helpers.rb +11 -0
- data/lib/herb/ast/node.rb +15 -6
- data/lib/herb/ast/nodes.rb +609 -392
- data/lib/herb/cli.rb +31 -0
- data/lib/herb/colors.rb +82 -0
- data/lib/herb/engine/compiler.rb +140 -14
- data/lib/herb/engine/debug_visitor.rb +1 -5
- data/lib/herb/engine/parser_error_overlay.rb +1 -1
- data/lib/herb/engine.rb +18 -20
- data/lib/herb/errors.rb +166 -56
- data/lib/herb/location.rb +2 -2
- data/lib/herb/project.rb +86 -21
- data/lib/herb/token.rb +14 -2
- data/lib/herb/version.rb +1 -1
- data/lib/herb.rb +1 -0
- data/sig/herb/ast/helpers.rbs +3 -0
- data/sig/herb/ast/node.rbs +12 -5
- data/sig/herb/ast/nodes.rbs +124 -62
- data/sig/herb/colors.rbs +35 -0
- data/sig/herb/engine/compiler.rbs +23 -1
- data/sig/herb/errors.rbs +74 -20
- data/sig/herb/token.rbs +8 -0
- data/sig/herb_c_extension.rbs +1 -1
- data/sig/serialized_ast_errors.rbs +8 -0
- data/src/analyze.c +461 -249
- data/src/analyze_helpers.c +5 -0
- data/src/analyze_missing_end.c +147 -0
- data/src/analyze_transform.c +196 -0
- data/src/analyzed_ruby.c +23 -2
- data/src/ast_node.c +14 -17
- data/src/ast_nodes.c +179 -181
- data/src/ast_pretty_print.c +232 -232
- data/src/element_source.c +7 -6
- data/src/errors.c +272 -152
- data/src/extract.c +92 -34
- data/src/herb.c +37 -49
- data/src/html_util.c +34 -96
- data/src/include/analyze.h +10 -2
- data/src/include/analyze_helpers.h +3 -0
- data/src/include/analyzed_ruby.h +4 -2
- data/src/include/ast_node.h +4 -4
- data/src/include/ast_nodes.h +68 -67
- data/src/include/ast_pretty_print.h +2 -2
- data/src/include/element_source.h +3 -1
- data/src/include/errors.h +42 -26
- data/src/include/extract.h +4 -4
- data/src/include/herb.h +6 -7
- data/src/include/html_util.h +4 -5
- data/src/include/lexer.h +1 -3
- data/src/include/lexer_peek_helpers.h +21 -19
- data/src/include/lexer_struct.h +12 -10
- data/src/include/location.h +10 -13
- data/src/include/macros.h +4 -0
- data/src/include/parser.h +12 -6
- data/src/include/parser_helpers.h +26 -16
- data/src/include/position.h +3 -14
- data/src/include/pretty_print.h +38 -28
- data/src/include/prism_helpers.h +1 -1
- data/src/include/range.h +4 -13
- data/src/include/token.h +5 -11
- data/src/include/token_struct.h +2 -2
- data/src/include/utf8.h +3 -2
- data/src/include/util/hb_arena.h +31 -0
- data/src/include/util/hb_arena_debug.h +8 -0
- data/src/include/util/hb_array.h +33 -0
- data/src/include/util/hb_buffer.h +34 -0
- data/src/include/util/hb_string.h +29 -0
- data/src/include/util/hb_system.h +9 -0
- data/src/include/util.h +3 -14
- data/src/include/version.h +1 -1
- data/src/include/visitor.h +1 -1
- data/src/io.c +7 -4
- data/src/lexer.c +62 -88
- data/src/lexer_peek_helpers.c +42 -38
- data/src/location.c +9 -37
- data/src/main.c +19 -23
- data/src/parser.c +373 -313
- data/src/parser_helpers.c +60 -54
- data/src/parser_match_tags.c +316 -0
- data/src/pretty_print.c +88 -117
- data/src/prism_helpers.c +7 -7
- data/src/range.c +2 -35
- data/src/token.c +36 -87
- data/src/utf8.c +4 -4
- data/src/util/hb_arena.c +179 -0
- data/src/util/hb_arena_debug.c +237 -0
- data/src/{array.c → util/hb_array.c} +26 -27
- data/src/util/hb_buffer.c +203 -0
- data/src/util/hb_string.c +85 -0
- data/src/util/hb_system.c +30 -0
- data/src/util.c +29 -99
- data/src/visitor.c +54 -54
- data/templates/ext/herb/error_helpers.c.erb +3 -3
- data/templates/ext/herb/error_helpers.h.erb +1 -1
- data/templates/ext/herb/nodes.c.erb +11 -6
- data/templates/java/error_helpers.c.erb +75 -0
- data/templates/java/error_helpers.h.erb +20 -0
- data/templates/java/nodes.c.erb +97 -0
- data/templates/java/nodes.h.erb +23 -0
- data/templates/java/org/herb/ast/Errors.java.erb +121 -0
- data/templates/java/org/herb/ast/NodeVisitor.java.erb +14 -0
- data/templates/java/org/herb/ast/Nodes.java.erb +220 -0
- data/templates/java/org/herb/ast/Visitor.java.erb +56 -0
- data/templates/javascript/packages/core/src/visitor.ts.erb +29 -1
- data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +8 -8
- data/templates/javascript/packages/node/extension/error_helpers.h.erb +1 -1
- data/templates/javascript/packages/node/extension/nodes.cpp.erb +9 -9
- data/templates/javascript/packages/node/extension/nodes.h.erb +1 -1
- data/templates/lib/herb/ast/nodes.rb.erb +28 -16
- data/templates/lib/herb/errors.rb.erb +17 -12
- data/templates/rust/src/ast/nodes.rs.erb +220 -0
- data/templates/rust/src/errors.rs.erb +216 -0
- data/templates/rust/src/nodes.rs.erb +374 -0
- data/templates/src/analyze_missing_end.c.erb +36 -0
- data/templates/src/analyze_transform.c.erb +24 -0
- data/templates/src/ast_nodes.c.erb +14 -16
- data/templates/src/ast_pretty_print.c.erb +36 -36
- data/templates/src/errors.c.erb +36 -38
- data/templates/src/include/ast_nodes.h.erb +11 -10
- data/templates/src/include/ast_pretty_print.h.erb +2 -2
- data/templates/src/include/errors.h.erb +9 -9
- data/templates/src/parser_match_tags.c.erb +38 -0
- data/templates/src/visitor.c.erb +4 -4
- data/templates/template.rb +22 -3
- data/templates/wasm/error_helpers.cpp.erb +9 -9
- data/templates/wasm/error_helpers.h.erb +1 -1
- data/templates/wasm/nodes.cpp.erb +9 -9
- data/templates/wasm/nodes.h.erb +1 -1
- data/vendor/prism/Rakefile +4 -1
- data/vendor/prism/config.yml +2 -1
- data/vendor/prism/include/prism/ast.h +31 -1
- data/vendor/prism/include/prism/diagnostic.h +1 -0
- data/vendor/prism/include/prism/version.h +3 -3
- data/vendor/prism/src/diagnostic.c +3 -1
- data/vendor/prism/src/prism.c +130 -71
- data/vendor/prism/src/util/pm_string.c +6 -8
- data/vendor/prism/templates/include/prism/ast.h.erb +2 -0
- data/vendor/prism/templates/java/org/prism/Loader.java.erb +2 -2
- data/vendor/prism/templates/javascript/src/deserialize.js.erb +2 -2
- data/vendor/prism/templates/lib/prism/serialize.rb.erb +2 -2
- data/vendor/prism/templates/sig/prism.rbs.erb +4 -0
- data/vendor/prism/templates/src/diagnostic.c.erb +1 -0
- metadata +34 -21
- data/lib/herb/libherb/array.rb +0 -51
- data/lib/herb/libherb/ast_node.rb +0 -50
- data/lib/herb/libherb/buffer.rb +0 -56
- data/lib/herb/libherb/extract_result.rb +0 -20
- data/lib/herb/libherb/lex_result.rb +0 -32
- data/lib/herb/libherb/libherb.rb +0 -52
- data/lib/herb/libherb/parse_result.rb +0 -20
- data/lib/herb/libherb/token.rb +0 -46
- data/lib/herb/libherb.rb +0 -35
- data/src/buffer.c +0 -232
- data/src/include/array.h +0 -33
- data/src/include/buffer.h +0 -39
- data/src/include/json.h +0 -28
- data/src/include/memory.h +0 -12
- data/src/json.c +0 -205
- data/src/memory.c +0 -53
- data/src/position.c +0 -33
data/src/include/ast_nodes.h
CHANGED
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
#include <stdbool.h>
|
|
8
8
|
#include <prism.h>
|
|
9
9
|
|
|
10
|
-
#include "array.h"
|
|
11
|
-
#include "buffer.h"
|
|
12
|
-
#include "position.h"
|
|
13
|
-
#include "location.h"
|
|
14
|
-
#include "token_struct.h"
|
|
15
10
|
#include "analyzed_ruby.h"
|
|
16
11
|
#include "element_source.h"
|
|
12
|
+
#include "location.h"
|
|
13
|
+
#include "position.h"
|
|
14
|
+
#include "token_struct.h"
|
|
15
|
+
#include "util/hb_array.h"
|
|
16
|
+
#include "util/hb_buffer.h"
|
|
17
|
+
#include "util/hb_string.h"
|
|
17
18
|
|
|
18
19
|
typedef enum {
|
|
19
20
|
AST_DOCUMENT_NODE,
|
|
@@ -51,15 +52,15 @@ typedef enum {
|
|
|
51
52
|
|
|
52
53
|
typedef struct AST_NODE_STRUCT {
|
|
53
54
|
ast_node_type_T type;
|
|
54
|
-
location_T
|
|
55
|
+
location_T location;
|
|
55
56
|
// maybe a range too?
|
|
56
|
-
|
|
57
|
+
hb_array_T* errors;
|
|
57
58
|
} AST_NODE_T;
|
|
58
59
|
|
|
59
60
|
|
|
60
61
|
typedef struct AST_DOCUMENT_NODE_STRUCT {
|
|
61
62
|
AST_NODE_T base;
|
|
62
|
-
|
|
63
|
+
hb_array_T* children;
|
|
63
64
|
} AST_DOCUMENT_NODE_T;
|
|
64
65
|
|
|
65
66
|
typedef struct AST_LITERAL_NODE_STRUCT {
|
|
@@ -72,7 +73,7 @@ typedef struct AST_HTML_OPEN_TAG_NODE_STRUCT {
|
|
|
72
73
|
token_T* tag_opening;
|
|
73
74
|
token_T* tag_name;
|
|
74
75
|
token_T* tag_closing;
|
|
75
|
-
|
|
76
|
+
hb_array_T* children;
|
|
76
77
|
bool is_void;
|
|
77
78
|
} AST_HTML_OPEN_TAG_NODE_T;
|
|
78
79
|
|
|
@@ -80,7 +81,7 @@ typedef struct AST_HTML_CLOSE_TAG_NODE_STRUCT {
|
|
|
80
81
|
AST_NODE_T base;
|
|
81
82
|
token_T* tag_opening;
|
|
82
83
|
token_T* tag_name;
|
|
83
|
-
|
|
84
|
+
hb_array_T* children;
|
|
84
85
|
token_T* tag_closing;
|
|
85
86
|
} AST_HTML_CLOSE_TAG_NODE_T;
|
|
86
87
|
|
|
@@ -88,7 +89,7 @@ typedef struct AST_HTML_ELEMENT_NODE_STRUCT {
|
|
|
88
89
|
AST_NODE_T base;
|
|
89
90
|
struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag;
|
|
90
91
|
token_T* tag_name;
|
|
91
|
-
|
|
92
|
+
hb_array_T* body;
|
|
92
93
|
struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag;
|
|
93
94
|
bool is_void;
|
|
94
95
|
element_source_t source;
|
|
@@ -97,14 +98,14 @@ typedef struct AST_HTML_ELEMENT_NODE_STRUCT {
|
|
|
97
98
|
typedef struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT {
|
|
98
99
|
AST_NODE_T base;
|
|
99
100
|
token_T* open_quote;
|
|
100
|
-
|
|
101
|
+
hb_array_T* children;
|
|
101
102
|
token_T* close_quote;
|
|
102
103
|
bool quoted;
|
|
103
104
|
} AST_HTML_ATTRIBUTE_VALUE_NODE_T;
|
|
104
105
|
|
|
105
106
|
typedef struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT {
|
|
106
107
|
AST_NODE_T base;
|
|
107
|
-
|
|
108
|
+
hb_array_T* children;
|
|
108
109
|
} AST_HTML_ATTRIBUTE_NAME_NODE_T;
|
|
109
110
|
|
|
110
111
|
typedef struct AST_HTML_ATTRIBUTE_NODE_STRUCT {
|
|
@@ -122,28 +123,28 @@ typedef struct AST_HTML_TEXT_NODE_STRUCT {
|
|
|
122
123
|
typedef struct AST_HTML_COMMENT_NODE_STRUCT {
|
|
123
124
|
AST_NODE_T base;
|
|
124
125
|
token_T* comment_start;
|
|
125
|
-
|
|
126
|
+
hb_array_T* children;
|
|
126
127
|
token_T* comment_end;
|
|
127
128
|
} AST_HTML_COMMENT_NODE_T;
|
|
128
129
|
|
|
129
130
|
typedef struct AST_HTML_DOCTYPE_NODE_STRUCT {
|
|
130
131
|
AST_NODE_T base;
|
|
131
132
|
token_T* tag_opening;
|
|
132
|
-
|
|
133
|
+
hb_array_T* children;
|
|
133
134
|
token_T* tag_closing;
|
|
134
135
|
} AST_HTML_DOCTYPE_NODE_T;
|
|
135
136
|
|
|
136
137
|
typedef struct AST_XML_DECLARATION_NODE_STRUCT {
|
|
137
138
|
AST_NODE_T base;
|
|
138
139
|
token_T* tag_opening;
|
|
139
|
-
|
|
140
|
+
hb_array_T* children;
|
|
140
141
|
token_T* tag_closing;
|
|
141
142
|
} AST_XML_DECLARATION_NODE_T;
|
|
142
143
|
|
|
143
144
|
typedef struct AST_CDATA_NODE_STRUCT {
|
|
144
145
|
AST_NODE_T base;
|
|
145
146
|
token_T* tag_opening;
|
|
146
|
-
|
|
147
|
+
hb_array_T* children;
|
|
147
148
|
token_T* tag_closing;
|
|
148
149
|
} AST_CDATA_NODE_T;
|
|
149
150
|
|
|
@@ -174,7 +175,7 @@ typedef struct AST_ERB_ELSE_NODE_STRUCT {
|
|
|
174
175
|
token_T* tag_opening;
|
|
175
176
|
token_T* content;
|
|
176
177
|
token_T* tag_closing;
|
|
177
|
-
|
|
178
|
+
hb_array_T* statements;
|
|
178
179
|
} AST_ERB_ELSE_NODE_T;
|
|
179
180
|
|
|
180
181
|
typedef struct AST_ERB_IF_NODE_STRUCT {
|
|
@@ -182,7 +183,7 @@ typedef struct AST_ERB_IF_NODE_STRUCT {
|
|
|
182
183
|
token_T* tag_opening;
|
|
183
184
|
token_T* content;
|
|
184
185
|
token_T* tag_closing;
|
|
185
|
-
|
|
186
|
+
hb_array_T* statements;
|
|
186
187
|
struct AST_NODE_STRUCT* subsequent;
|
|
187
188
|
struct AST_ERB_END_NODE_STRUCT* end_node;
|
|
188
189
|
} AST_ERB_IF_NODE_T;
|
|
@@ -192,7 +193,7 @@ typedef struct AST_ERB_BLOCK_NODE_STRUCT {
|
|
|
192
193
|
token_T* tag_opening;
|
|
193
194
|
token_T* content;
|
|
194
195
|
token_T* tag_closing;
|
|
195
|
-
|
|
196
|
+
hb_array_T* body;
|
|
196
197
|
struct AST_ERB_END_NODE_STRUCT* end_node;
|
|
197
198
|
} AST_ERB_BLOCK_NODE_T;
|
|
198
199
|
|
|
@@ -201,7 +202,7 @@ typedef struct AST_ERB_WHEN_NODE_STRUCT {
|
|
|
201
202
|
token_T* tag_opening;
|
|
202
203
|
token_T* content;
|
|
203
204
|
token_T* tag_closing;
|
|
204
|
-
|
|
205
|
+
hb_array_T* statements;
|
|
205
206
|
} AST_ERB_WHEN_NODE_T;
|
|
206
207
|
|
|
207
208
|
typedef struct AST_ERB_CASE_NODE_STRUCT {
|
|
@@ -209,8 +210,8 @@ typedef struct AST_ERB_CASE_NODE_STRUCT {
|
|
|
209
210
|
token_T* tag_opening;
|
|
210
211
|
token_T* content;
|
|
211
212
|
token_T* tag_closing;
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
hb_array_T* children;
|
|
214
|
+
hb_array_T* conditions;
|
|
214
215
|
struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
|
|
215
216
|
struct AST_ERB_END_NODE_STRUCT* end_node;
|
|
216
217
|
} AST_ERB_CASE_NODE_T;
|
|
@@ -220,8 +221,8 @@ typedef struct AST_ERB_CASE_MATCH_NODE_STRUCT {
|
|
|
220
221
|
token_T* tag_opening;
|
|
221
222
|
token_T* content;
|
|
222
223
|
token_T* tag_closing;
|
|
223
|
-
|
|
224
|
-
|
|
224
|
+
hb_array_T* children;
|
|
225
|
+
hb_array_T* conditions;
|
|
225
226
|
struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
|
|
226
227
|
struct AST_ERB_END_NODE_STRUCT* end_node;
|
|
227
228
|
} AST_ERB_CASE_MATCH_NODE_T;
|
|
@@ -231,7 +232,7 @@ typedef struct AST_ERB_WHILE_NODE_STRUCT {
|
|
|
231
232
|
token_T* tag_opening;
|
|
232
233
|
token_T* content;
|
|
233
234
|
token_T* tag_closing;
|
|
234
|
-
|
|
235
|
+
hb_array_T* statements;
|
|
235
236
|
struct AST_ERB_END_NODE_STRUCT* end_node;
|
|
236
237
|
} AST_ERB_WHILE_NODE_T;
|
|
237
238
|
|
|
@@ -240,7 +241,7 @@ typedef struct AST_ERB_UNTIL_NODE_STRUCT {
|
|
|
240
241
|
token_T* tag_opening;
|
|
241
242
|
token_T* content;
|
|
242
243
|
token_T* tag_closing;
|
|
243
|
-
|
|
244
|
+
hb_array_T* statements;
|
|
244
245
|
struct AST_ERB_END_NODE_STRUCT* end_node;
|
|
245
246
|
} AST_ERB_UNTIL_NODE_T;
|
|
246
247
|
|
|
@@ -249,7 +250,7 @@ typedef struct AST_ERB_FOR_NODE_STRUCT {
|
|
|
249
250
|
token_T* tag_opening;
|
|
250
251
|
token_T* content;
|
|
251
252
|
token_T* tag_closing;
|
|
252
|
-
|
|
253
|
+
hb_array_T* statements;
|
|
253
254
|
struct AST_ERB_END_NODE_STRUCT* end_node;
|
|
254
255
|
} AST_ERB_FOR_NODE_T;
|
|
255
256
|
|
|
@@ -258,7 +259,7 @@ typedef struct AST_ERB_RESCUE_NODE_STRUCT {
|
|
|
258
259
|
token_T* tag_opening;
|
|
259
260
|
token_T* content;
|
|
260
261
|
token_T* tag_closing;
|
|
261
|
-
|
|
262
|
+
hb_array_T* statements;
|
|
262
263
|
struct AST_ERB_RESCUE_NODE_STRUCT* subsequent;
|
|
263
264
|
} AST_ERB_RESCUE_NODE_T;
|
|
264
265
|
|
|
@@ -267,7 +268,7 @@ typedef struct AST_ERB_ENSURE_NODE_STRUCT {
|
|
|
267
268
|
token_T* tag_opening;
|
|
268
269
|
token_T* content;
|
|
269
270
|
token_T* tag_closing;
|
|
270
|
-
|
|
271
|
+
hb_array_T* statements;
|
|
271
272
|
} AST_ERB_ENSURE_NODE_T;
|
|
272
273
|
|
|
273
274
|
typedef struct AST_ERB_BEGIN_NODE_STRUCT {
|
|
@@ -275,7 +276,7 @@ typedef struct AST_ERB_BEGIN_NODE_STRUCT {
|
|
|
275
276
|
token_T* tag_opening;
|
|
276
277
|
token_T* content;
|
|
277
278
|
token_T* tag_closing;
|
|
278
|
-
|
|
279
|
+
hb_array_T* statements;
|
|
279
280
|
struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause;
|
|
280
281
|
struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
|
|
281
282
|
struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause;
|
|
@@ -287,7 +288,7 @@ typedef struct AST_ERB_UNLESS_NODE_STRUCT {
|
|
|
287
288
|
token_T* tag_opening;
|
|
288
289
|
token_T* content;
|
|
289
290
|
token_T* tag_closing;
|
|
290
|
-
|
|
291
|
+
hb_array_T* statements;
|
|
291
292
|
struct AST_ERB_ELSE_NODE_STRUCT* else_clause;
|
|
292
293
|
struct AST_ERB_END_NODE_STRUCT* end_node;
|
|
293
294
|
} AST_ERB_UNLESS_NODE_T;
|
|
@@ -304,42 +305,42 @@ typedef struct AST_ERB_IN_NODE_STRUCT {
|
|
|
304
305
|
token_T* tag_opening;
|
|
305
306
|
token_T* content;
|
|
306
307
|
token_T* tag_closing;
|
|
307
|
-
|
|
308
|
+
hb_array_T* statements;
|
|
308
309
|
} AST_ERB_IN_NODE_T;
|
|
309
310
|
|
|
310
|
-
AST_DOCUMENT_NODE_T* ast_document_node_init(
|
|
311
|
-
AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T
|
|
312
|
-
AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing,
|
|
313
|
-
AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name,
|
|
314
|
-
AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name,
|
|
315
|
-
AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote,
|
|
316
|
-
AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(
|
|
317
|
-
AST_HTML_ATTRIBUTE_NODE_T* ast_html_attribute_node_init(struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT* name, token_T* equals, struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT* value, position_T
|
|
318
|
-
AST_HTML_TEXT_NODE_T* ast_html_text_node_init(const char* content, position_T
|
|
319
|
-
AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start,
|
|
320
|
-
AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening,
|
|
321
|
-
AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening,
|
|
322
|
-
AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening,
|
|
323
|
-
AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T
|
|
324
|
-
AST_ERB_CONTENT_NODE_T* ast_erb_content_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, bool parsed, bool valid, position_T
|
|
325
|
-
AST_ERB_END_NODE_T* ast_erb_end_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T
|
|
326
|
-
AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
327
|
-
AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
328
|
-
AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
329
|
-
AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
330
|
-
AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
331
|
-
AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
332
|
-
AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
333
|
-
AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
334
|
-
AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
335
|
-
AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
336
|
-
AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
337
|
-
AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
338
|
-
AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
339
|
-
AST_ERB_YIELD_NODE_T* ast_erb_yield_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T
|
|
340
|
-
AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing,
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
311
|
+
AST_DOCUMENT_NODE_T* ast_document_node_init(hb_array_T* children, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
312
|
+
AST_LITERAL_NODE_T* ast_literal_node_init(const char* content, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
313
|
+
AST_HTML_OPEN_TAG_NODE_T* ast_html_open_tag_node_init(token_T* tag_opening, token_T* tag_name, token_T* tag_closing, hb_array_T* children, bool is_void, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
314
|
+
AST_HTML_CLOSE_TAG_NODE_T* ast_html_close_tag_node_init(token_T* tag_opening, token_T* tag_name, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
315
|
+
AST_HTML_ELEMENT_NODE_T* ast_html_element_node_init(struct AST_HTML_OPEN_TAG_NODE_STRUCT* open_tag, token_T* tag_name, hb_array_T* body, struct AST_HTML_CLOSE_TAG_NODE_STRUCT* close_tag, bool is_void, element_source_t source, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
316
|
+
AST_HTML_ATTRIBUTE_VALUE_NODE_T* ast_html_attribute_value_node_init(token_T* open_quote, hb_array_T* children, token_T* close_quote, bool quoted, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
317
|
+
AST_HTML_ATTRIBUTE_NAME_NODE_T* ast_html_attribute_name_node_init(hb_array_T* children, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
318
|
+
AST_HTML_ATTRIBUTE_NODE_T* ast_html_attribute_node_init(struct AST_HTML_ATTRIBUTE_NAME_NODE_STRUCT* name, token_T* equals, struct AST_HTML_ATTRIBUTE_VALUE_NODE_STRUCT* value, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
319
|
+
AST_HTML_TEXT_NODE_T* ast_html_text_node_init(const char* content, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
320
|
+
AST_HTML_COMMENT_NODE_T* ast_html_comment_node_init(token_T* comment_start, hb_array_T* children, token_T* comment_end, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
321
|
+
AST_HTML_DOCTYPE_NODE_T* ast_html_doctype_node_init(token_T* tag_opening, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
322
|
+
AST_XML_DECLARATION_NODE_T* ast_xml_declaration_node_init(token_T* tag_opening, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
323
|
+
AST_CDATA_NODE_T* ast_cdata_node_init(token_T* tag_opening, hb_array_T* children, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
324
|
+
AST_WHITESPACE_NODE_T* ast_whitespace_node_init(token_T* value, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
325
|
+
AST_ERB_CONTENT_NODE_T* ast_erb_content_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, bool parsed, bool valid, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
326
|
+
AST_ERB_END_NODE_T* ast_erb_end_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
327
|
+
AST_ERB_ELSE_NODE_T* ast_erb_else_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
328
|
+
AST_ERB_IF_NODE_T* ast_erb_if_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_NODE_STRUCT* subsequent, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
329
|
+
AST_ERB_BLOCK_NODE_T* ast_erb_block_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* body, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
330
|
+
AST_ERB_WHEN_NODE_T* ast_erb_when_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
331
|
+
AST_ERB_CASE_NODE_T* ast_erb_case_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* children, hb_array_T* conditions, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
332
|
+
AST_ERB_CASE_MATCH_NODE_T* ast_erb_case_match_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* children, hb_array_T* conditions, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
333
|
+
AST_ERB_WHILE_NODE_T* ast_erb_while_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
334
|
+
AST_ERB_UNTIL_NODE_T* ast_erb_until_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
335
|
+
AST_ERB_FOR_NODE_T* ast_erb_for_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
336
|
+
AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* subsequent, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
337
|
+
AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
338
|
+
AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
339
|
+
AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
340
|
+
AST_ERB_YIELD_NODE_T* ast_erb_yield_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
341
|
+
AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors);
|
|
342
|
+
|
|
343
|
+
hb_string_T ast_node_type_to_string(AST_NODE_T* node);
|
|
344
|
+
hb_string_T ast_node_human_type(AST_NODE_T* node);
|
|
344
345
|
|
|
345
346
|
#endif
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
#define HERB_AST_PRETTY_PRINT_H
|
|
6
6
|
|
|
7
7
|
#include "ast_nodes.h"
|
|
8
|
-
#include "
|
|
8
|
+
#include "util/hb_buffer.h"
|
|
9
9
|
|
|
10
10
|
void ast_pretty_print_node(
|
|
11
11
|
AST_NODE_T* node,
|
|
12
12
|
size_t indent,
|
|
13
13
|
size_t relative_indent,
|
|
14
|
-
|
|
14
|
+
hb_buffer_T* buffer
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
#endif
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#ifndef HERB_ELEMENT_SOURCE_H
|
|
2
2
|
#define HERB_ELEMENT_SOURCE_H
|
|
3
3
|
|
|
4
|
+
#include "util/hb_string.h"
|
|
5
|
+
|
|
4
6
|
typedef enum {
|
|
5
7
|
ELEMENT_SOURCE_HTML,
|
|
6
8
|
ELEMENT_SOURCE_ACTIONVIEW,
|
|
@@ -8,6 +10,6 @@ typedef enum {
|
|
|
8
10
|
ELEMENT_SOURCE_SLIM
|
|
9
11
|
} element_source_t;
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
hb_string_T element_source_to_string(element_source_t source);
|
|
12
14
|
|
|
13
15
|
#endif
|
data/src/include/errors.h
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
#ifndef HERB_ERRORS_H
|
|
5
5
|
#define HERB_ERRORS_H
|
|
6
6
|
|
|
7
|
-
#include "array.h"
|
|
8
|
-
#include "buffer.h"
|
|
9
7
|
#include "errors.h"
|
|
10
8
|
#include "location.h"
|
|
11
9
|
#include "position.h"
|
|
12
10
|
#include "token.h"
|
|
11
|
+
#include "util/hb_array.h"
|
|
12
|
+
#include "util/hb_buffer.h"
|
|
13
13
|
|
|
14
14
|
typedef enum {
|
|
15
15
|
UNEXPECTED_ERROR,
|
|
@@ -21,11 +21,13 @@ typedef enum {
|
|
|
21
21
|
VOID_ELEMENT_CLOSING_TAG_ERROR,
|
|
22
22
|
UNCLOSED_ELEMENT_ERROR,
|
|
23
23
|
RUBY_PARSE_ERROR,
|
|
24
|
+
ERB_CONTROL_FLOW_SCOPE_ERROR,
|
|
25
|
+
MISSINGERB_END_TAG_ERROR,
|
|
24
26
|
} error_type_T;
|
|
25
27
|
|
|
26
28
|
typedef struct ERROR_STRUCT {
|
|
27
29
|
error_type_T type;
|
|
28
|
-
location_T
|
|
30
|
+
location_T location;
|
|
29
31
|
char* message;
|
|
30
32
|
} ERROR_T;
|
|
31
33
|
|
|
@@ -84,26 +86,40 @@ typedef struct {
|
|
|
84
86
|
const char* level;
|
|
85
87
|
} RUBY_PARSE_ERROR_T;
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
void
|
|
99
|
-
|
|
100
|
-
void
|
|
101
|
-
|
|
102
|
-
void
|
|
103
|
-
|
|
104
|
-
void
|
|
105
|
-
|
|
106
|
-
void
|
|
89
|
+
typedef struct {
|
|
90
|
+
ERROR_T base;
|
|
91
|
+
const char* keyword;
|
|
92
|
+
} ERB_CONTROL_FLOW_SCOPE_ERROR_T;
|
|
93
|
+
|
|
94
|
+
typedef struct {
|
|
95
|
+
ERROR_T base;
|
|
96
|
+
const char* keyword;
|
|
97
|
+
} MISSINGERB_END_TAG_ERROR_T;
|
|
98
|
+
|
|
99
|
+
UNEXPECTED_ERROR_T* unexpected_error_init(const char* description, const char* expected, const char* found, position_T start, position_T end);
|
|
100
|
+
void append_unexpected_error(const char* description, const char* expected, const char* found, position_T start, position_T end, hb_array_T* errors);
|
|
101
|
+
UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T start, position_T end);
|
|
102
|
+
void append_unexpected_token_error(token_type_T expected_type, token_T* found, position_T start, position_T end, hb_array_T* errors);
|
|
103
|
+
MISSING_OPENING_TAG_ERROR_T* missing_opening_tag_error_init(token_T* closing_tag, position_T start, position_T end);
|
|
104
|
+
void append_missing_opening_tag_error(token_T* closing_tag, position_T start, position_T end, hb_array_T* errors);
|
|
105
|
+
MISSING_CLOSING_TAG_ERROR_T* missing_closing_tag_error_init(token_T* opening_tag, position_T start, position_T end);
|
|
106
|
+
void append_missing_closing_tag_error(token_T* opening_tag, position_T start, position_T end, hb_array_T* errors);
|
|
107
|
+
TAG_NAMES_MISMATCH_ERROR_T* tag_names_mismatch_error_init(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end);
|
|
108
|
+
void append_tag_names_mismatch_error(token_T* opening_tag, token_T* closing_tag, position_T start, position_T end, hb_array_T* errors);
|
|
109
|
+
QUOTES_MISMATCH_ERROR_T* quotes_mismatch_error_init(token_T* opening_quote, token_T* closing_quote, position_T start, position_T end);
|
|
110
|
+
void append_quotes_mismatch_error(token_T* opening_quote, token_T* closing_quote, position_T start, position_T end, hb_array_T* errors);
|
|
111
|
+
VOID_ELEMENT_CLOSING_TAG_ERROR_T* void_element_closing_tag_error_init(token_T* tag_name, const char* expected, const char* found, position_T start, position_T end);
|
|
112
|
+
void append_void_element_closing_tag_error(token_T* tag_name, const char* expected, const char* found, position_T start, position_T end, hb_array_T* errors);
|
|
113
|
+
UNCLOSED_ELEMENT_ERROR_T* unclosed_element_error_init(token_T* opening_tag, position_T start, position_T end);
|
|
114
|
+
void append_unclosed_element_error(token_T* opening_tag, position_T start, position_T end, hb_array_T* errors);
|
|
115
|
+
RUBY_PARSE_ERROR_T* ruby_parse_error_init(const char* error_message, const char* diagnostic_id, const char* level, position_T start, position_T end);
|
|
116
|
+
void append_ruby_parse_error(const char* error_message, const char* diagnostic_id, const char* level, position_T start, position_T end, hb_array_T* errors);
|
|
117
|
+
ERB_CONTROL_FLOW_SCOPE_ERROR_T* erb_control_flow_scope_error_init(const char* keyword, position_T start, position_T end);
|
|
118
|
+
void append_erb_control_flow_scope_error(const char* keyword, position_T start, position_T end, hb_array_T* errors);
|
|
119
|
+
MISSINGERB_END_TAG_ERROR_T* missingerb_end_tag_error_init(const char* keyword, position_T start, position_T end);
|
|
120
|
+
void append_missingerb_end_tag_error(const char* keyword, position_T start, position_T end, hb_array_T* errors);
|
|
121
|
+
|
|
122
|
+
void error_init(ERROR_T* error, error_type_T type, position_T start, position_T end);
|
|
107
123
|
|
|
108
124
|
size_t error_sizeof(void);
|
|
109
125
|
error_type_T error_type(ERROR_T* error);
|
|
@@ -115,11 +131,11 @@ const char* error_human_type(ERROR_T* error);
|
|
|
115
131
|
|
|
116
132
|
void error_free(ERROR_T* error);
|
|
117
133
|
|
|
118
|
-
void error_pretty_print(ERROR_T* error, size_t indent, size_t relative_indent,
|
|
134
|
+
void error_pretty_print(ERROR_T* error, size_t indent, size_t relative_indent, hb_buffer_T* buffer);
|
|
119
135
|
|
|
120
136
|
void error_pretty_print_array(
|
|
121
|
-
const char* name,
|
|
122
|
-
|
|
137
|
+
const char* name, hb_array_T* array, size_t indent, size_t relative_indent, bool last_property,
|
|
138
|
+
hb_buffer_T* buffer
|
|
123
139
|
);
|
|
124
140
|
|
|
125
141
|
#endif
|
data/src/include/extract.h
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#ifndef HERB_EXTRACT_H
|
|
2
2
|
#define HERB_EXTRACT_H
|
|
3
3
|
|
|
4
|
-
#include "
|
|
4
|
+
#include "util/hb_buffer.h"
|
|
5
5
|
|
|
6
6
|
typedef enum {
|
|
7
7
|
HERB_EXTRACT_LANGUAGE_RUBY,
|
|
8
8
|
HERB_EXTRACT_LANGUAGE_HTML,
|
|
9
9
|
} herb_extract_language_T;
|
|
10
10
|
|
|
11
|
-
void herb_extract_ruby_to_buffer(const char* source,
|
|
12
|
-
void herb_extract_html_to_buffer(const char* source,
|
|
11
|
+
void herb_extract_ruby_to_buffer(const char* source, hb_buffer_T* output);
|
|
12
|
+
void herb_extract_html_to_buffer(const char* source, hb_buffer_T* output);
|
|
13
13
|
|
|
14
14
|
char* herb_extract_ruby_with_semicolons(const char* source);
|
|
15
|
-
void herb_extract_ruby_to_buffer_with_semicolons(const char* source,
|
|
15
|
+
void herb_extract_ruby_to_buffer_with_semicolons(const char* source, hb_buffer_T* output);
|
|
16
16
|
|
|
17
17
|
char* herb_extract(const char* source, herb_extract_language_T language);
|
|
18
18
|
char* herb_extract_from_file(const char* path, herb_extract_language_T language);
|
data/src/include/herb.h
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#ifndef HERB_H
|
|
2
2
|
#define HERB_H
|
|
3
3
|
|
|
4
|
-
#include "array.h"
|
|
5
4
|
#include "ast_node.h"
|
|
6
|
-
#include "buffer.h"
|
|
7
5
|
#include "extract.h"
|
|
8
6
|
#include "parser.h"
|
|
7
|
+
#include "util/hb_array.h"
|
|
8
|
+
#include "util/hb_buffer.h"
|
|
9
9
|
|
|
10
10
|
#include <stdint.h>
|
|
11
11
|
|
|
@@ -13,18 +13,17 @@
|
|
|
13
13
|
extern "C" {
|
|
14
14
|
#endif
|
|
15
15
|
|
|
16
|
-
void herb_lex_to_buffer(const char* source,
|
|
17
|
-
void herb_lex_json_to_buffer(const char* source, buffer_T* output);
|
|
16
|
+
void herb_lex_to_buffer(const char* source, hb_buffer_T* output);
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
hb_array_T* herb_lex(const char* source);
|
|
19
|
+
hb_array_T* herb_lex_file(const char* path);
|
|
21
20
|
|
|
22
21
|
AST_DOCUMENT_NODE_T* herb_parse(const char* source, parser_options_T* options);
|
|
23
22
|
|
|
24
23
|
const char* herb_version(void);
|
|
25
24
|
const char* herb_prism_version(void);
|
|
26
25
|
|
|
27
|
-
void herb_free_tokens(
|
|
26
|
+
void herb_free_tokens(hb_array_T** tokens);
|
|
28
27
|
|
|
29
28
|
#ifdef __cplusplus
|
|
30
29
|
}
|
data/src/include/html_util.h
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
#ifndef HERB_HTML_UTIL_H
|
|
2
2
|
#define HERB_HTML_UTIL_H
|
|
3
3
|
|
|
4
|
+
#include "util/hb_string.h"
|
|
4
5
|
#include <stdbool.h>
|
|
5
6
|
|
|
6
|
-
bool is_void_element(
|
|
7
|
-
bool is_html4_void_element(const char* tag_name);
|
|
7
|
+
bool is_void_element(hb_string_T tag_name);
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
char* html_self_closing_tag_string(const char* tag_name);
|
|
9
|
+
hb_string_T html_closing_tag_string(hb_string_T tag_name);
|
|
10
|
+
hb_string_T html_self_closing_tag_string(hb_string_T tag_name);
|
|
12
11
|
|
|
13
12
|
#endif
|
data/src/include/lexer.h
CHANGED
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
#include "lexer_struct.h"
|
|
5
5
|
#include "token_struct.h"
|
|
6
6
|
|
|
7
|
-
lexer_T*
|
|
7
|
+
void lexer_init(lexer_T* lexer, const char* source);
|
|
8
8
|
token_T* lexer_next_token(lexer_T* lexer);
|
|
9
9
|
token_T* lexer_error(lexer_T* lexer, const char* message);
|
|
10
10
|
|
|
11
|
-
void lexer_free(lexer_T* lexer);
|
|
12
|
-
|
|
13
11
|
#endif
|
|
@@ -5,38 +5,40 @@
|
|
|
5
5
|
#include "token_struct.h"
|
|
6
6
|
|
|
7
7
|
#include <stdbool.h>
|
|
8
|
+
#include <stdint.h>
|
|
8
9
|
#include <stdio.h>
|
|
9
10
|
#include <stdlib.h>
|
|
10
11
|
|
|
11
12
|
typedef struct {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
uint32_t position;
|
|
14
|
+
uint32_t line;
|
|
15
|
+
uint32_t column;
|
|
16
|
+
uint32_t previous_position;
|
|
17
|
+
uint32_t previous_line;
|
|
18
|
+
uint32_t previous_column;
|
|
18
19
|
char current_character;
|
|
19
20
|
lexer_state_T state;
|
|
20
21
|
} lexer_state_snapshot_T;
|
|
21
22
|
|
|
22
|
-
char lexer_peek(const lexer_T* lexer,
|
|
23
|
-
bool lexer_peek_for_doctype(const lexer_T* lexer,
|
|
24
|
-
bool lexer_peek_for_xml_declaration(const lexer_T* lexer,
|
|
25
|
-
bool lexer_peek_for_cdata_start(const lexer_T* lexer,
|
|
26
|
-
bool lexer_peek_for_cdata_end(const lexer_T* lexer,
|
|
23
|
+
char lexer_peek(const lexer_T* lexer, uint32_t offset);
|
|
24
|
+
bool lexer_peek_for_doctype(const lexer_T* lexer, uint32_t offset);
|
|
25
|
+
bool lexer_peek_for_xml_declaration(const lexer_T* lexer, uint32_t offset);
|
|
26
|
+
bool lexer_peek_for_cdata_start(const lexer_T* lexer, uint32_t offset);
|
|
27
|
+
bool lexer_peek_for_cdata_end(const lexer_T* lexer, uint32_t offset);
|
|
27
28
|
|
|
28
|
-
bool lexer_peek_for_html_comment_start(const lexer_T* lexer,
|
|
29
|
-
bool lexer_peek_for_html_comment_end(const lexer_T* lexer,
|
|
29
|
+
bool lexer_peek_for_html_comment_start(const lexer_T* lexer, uint32_t offset);
|
|
30
|
+
bool lexer_peek_for_html_comment_end(const lexer_T* lexer, uint32_t offset);
|
|
30
31
|
|
|
31
|
-
bool lexer_peek_erb_close_tag(const lexer_T* lexer,
|
|
32
|
-
bool lexer_peek_erb_dash_close_tag(const lexer_T* lexer,
|
|
33
|
-
bool lexer_peek_erb_percent_close_tag(const lexer_T* lexer,
|
|
34
|
-
bool
|
|
32
|
+
bool lexer_peek_erb_close_tag(const lexer_T* lexer, uint32_t offset);
|
|
33
|
+
bool lexer_peek_erb_dash_close_tag(const lexer_T* lexer, uint32_t offset);
|
|
34
|
+
bool lexer_peek_erb_percent_close_tag(const lexer_T* lexer, uint32_t offset);
|
|
35
|
+
bool lexer_peek_erb_equals_close_tag(const lexer_T* lexer, uint32_t offset);
|
|
36
|
+
bool lexer_peek_erb_end(const lexer_T* lexer, uint32_t offset);
|
|
35
37
|
|
|
36
|
-
char lexer_backtrack(const lexer_T* lexer,
|
|
38
|
+
char lexer_backtrack(const lexer_T* lexer, uint32_t offset);
|
|
37
39
|
|
|
38
40
|
bool lexer_peek_for_token_type_after_whitespace(lexer_T* lexer, token_type_T token_type);
|
|
39
|
-
bool lexer_peek_for_close_tag_start(const lexer_T* lexer,
|
|
41
|
+
bool lexer_peek_for_close_tag_start(const lexer_T* lexer, uint32_t offset);
|
|
40
42
|
|
|
41
43
|
lexer_state_snapshot_T lexer_save_state(lexer_T* lexer);
|
|
42
44
|
void lexer_restore_state(lexer_T* lexer, lexer_state_snapshot_T snapshot);
|