herb 0.1.0-x86_64-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 +7 -0
- data/License.txt +21 -0
- data/Makefile +121 -0
- data/README.md +166 -0
- data/Rakefile +184 -0
- data/exe/herb +5 -0
- data/ext/herb/error_helpers.c +302 -0
- data/ext/herb/error_helpers.h +15 -0
- data/ext/herb/extconf.rb +75 -0
- data/ext/herb/extension.c +110 -0
- data/ext/herb/extension.h +6 -0
- data/ext/herb/extension_helpers.c +117 -0
- data/ext/herb/extension_helpers.h +24 -0
- data/ext/herb/nodes.c +936 -0
- data/ext/herb/nodes.h +12 -0
- data/herb.gemspec +49 -0
- 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/node.rb +61 -0
- data/lib/herb/ast/nodes.rb +1542 -0
- data/lib/herb/ast.rb +6 -0
- data/lib/herb/cli.rb +164 -0
- data/lib/herb/errors.rb +352 -0
- data/lib/herb/lex_result.rb +20 -0
- data/lib/herb/libherb/array.rb +48 -0
- data/lib/herb/libherb/ast_node.rb +47 -0
- data/lib/herb/libherb/buffer.rb +53 -0
- data/lib/herb/libherb/extract_result.rb +17 -0
- data/lib/herb/libherb/lex_result.rb +29 -0
- data/lib/herb/libherb/libherb.rb +49 -0
- data/lib/herb/libherb/parse_result.rb +17 -0
- data/lib/herb/libherb/token.rb +43 -0
- data/lib/herb/libherb.rb +32 -0
- data/lib/herb/location.rb +42 -0
- data/lib/herb/parse_result.rb +26 -0
- data/lib/herb/position.rb +36 -0
- data/lib/herb/project.rb +361 -0
- data/lib/herb/range.rb +40 -0
- data/lib/herb/result.rb +21 -0
- data/lib/herb/token.rb +43 -0
- data/lib/herb/token_list.rb +11 -0
- data/lib/herb/version.rb +5 -0
- data/lib/herb.rb +32 -0
- data/src/analyze.c +989 -0
- data/src/analyze_helpers.c +241 -0
- data/src/analyzed_ruby.c +35 -0
- data/src/array.c +137 -0
- data/src/ast_node.c +81 -0
- data/src/ast_nodes.c +866 -0
- data/src/ast_pretty_print.c +588 -0
- data/src/buffer.c +199 -0
- data/src/errors.c +740 -0
- data/src/extract.c +110 -0
- data/src/herb.c +103 -0
- data/src/html_util.c +143 -0
- data/src/include/analyze.h +36 -0
- data/src/include/analyze_helpers.h +43 -0
- data/src/include/analyzed_ruby.h +33 -0
- data/src/include/array.h +33 -0
- data/src/include/ast_node.h +35 -0
- data/src/include/ast_nodes.h +303 -0
- data/src/include/ast_pretty_print.h +17 -0
- data/src/include/buffer.h +36 -0
- data/src/include/errors.h +125 -0
- data/src/include/extract.h +20 -0
- data/src/include/herb.h +32 -0
- data/src/include/html_util.h +13 -0
- data/src/include/io.h +9 -0
- data/src/include/json.h +28 -0
- data/src/include/lexer.h +13 -0
- data/src/include/lexer_peek_helpers.h +23 -0
- data/src/include/lexer_struct.h +32 -0
- data/src/include/location.h +25 -0
- data/src/include/macros.h +10 -0
- data/src/include/memory.h +12 -0
- data/src/include/parser.h +22 -0
- data/src/include/parser_helpers.h +33 -0
- data/src/include/position.h +22 -0
- data/src/include/pretty_print.h +53 -0
- data/src/include/prism_helpers.h +18 -0
- data/src/include/range.h +23 -0
- data/src/include/ruby_parser.h +6 -0
- data/src/include/token.h +25 -0
- data/src/include/token_matchers.h +21 -0
- data/src/include/token_struct.h +51 -0
- data/src/include/util.h +25 -0
- data/src/include/version.h +6 -0
- data/src/include/visitor.h +11 -0
- data/src/io.c +30 -0
- data/src/json.c +205 -0
- data/src/lexer.c +284 -0
- data/src/lexer_peek_helpers.c +59 -0
- data/src/location.c +41 -0
- data/src/main.c +162 -0
- data/src/memory.c +53 -0
- data/src/parser.c +704 -0
- data/src/parser_helpers.c +161 -0
- data/src/position.c +33 -0
- data/src/pretty_print.c +242 -0
- data/src/prism_helpers.c +50 -0
- data/src/range.c +38 -0
- data/src/ruby_parser.c +47 -0
- data/src/token.c +194 -0
- data/src/token_matchers.c +32 -0
- data/src/util.c +128 -0
- data/src/visitor.c +321 -0
- metadata +159 -0
data/ext/herb/nodes.c
ADDED
@@ -0,0 +1,936 @@
|
|
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/templates/ext/herb/nodes.c.erb
|
3
|
+
|
4
|
+
#include <ruby.h>
|
5
|
+
|
6
|
+
#include "error_helpers.h"
|
7
|
+
#include "extension_helpers.h"
|
8
|
+
#include "extension.h"
|
9
|
+
#include "nodes.h"
|
10
|
+
|
11
|
+
#include "../../src/include/herb.h"
|
12
|
+
#include "../../src/include/token.h"
|
13
|
+
|
14
|
+
VALUE rb_node_from_c_struct(AST_NODE_T* node);
|
15
|
+
static VALUE rb_nodes_array_from_c_array(array_T* array);
|
16
|
+
|
17
|
+
static VALUE rb_document_node_from_c_struct(AST_DOCUMENT_NODE_T* document_node) {
|
18
|
+
if (document_node == NULL) { return Qnil; }
|
19
|
+
|
20
|
+
AST_NODE_T* node = &document_node->base;
|
21
|
+
|
22
|
+
VALUE Herb = rb_define_module("Herb");
|
23
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
24
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
25
|
+
VALUE DocumentNode = rb_define_class_under(AST, "DocumentNode", Node);
|
26
|
+
|
27
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
28
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
29
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
30
|
+
|
31
|
+
VALUE document_node_children = rb_nodes_array_from_c_array(document_node->children);
|
32
|
+
|
33
|
+
VALUE args[4] = {
|
34
|
+
type,
|
35
|
+
location,
|
36
|
+
errors,
|
37
|
+
document_node_children
|
38
|
+
};
|
39
|
+
|
40
|
+
return rb_class_new_instance(4, args, DocumentNode);
|
41
|
+
};
|
42
|
+
|
43
|
+
static VALUE rb_literal_node_from_c_struct(AST_LITERAL_NODE_T* literal_node) {
|
44
|
+
if (literal_node == NULL) { return Qnil; }
|
45
|
+
|
46
|
+
AST_NODE_T* node = &literal_node->base;
|
47
|
+
|
48
|
+
VALUE Herb = rb_define_module("Herb");
|
49
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
50
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
51
|
+
VALUE LiteralNode = rb_define_class_under(AST, "LiteralNode", Node);
|
52
|
+
|
53
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
54
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
55
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
56
|
+
|
57
|
+
VALUE literal_node_content = rb_str_new_cstr(literal_node->content);
|
58
|
+
|
59
|
+
VALUE args[4] = {
|
60
|
+
type,
|
61
|
+
location,
|
62
|
+
errors,
|
63
|
+
literal_node_content
|
64
|
+
};
|
65
|
+
|
66
|
+
return rb_class_new_instance(4, args, LiteralNode);
|
67
|
+
};
|
68
|
+
|
69
|
+
static VALUE rb_html_open_tag_node_from_c_struct(AST_HTML_OPEN_TAG_NODE_T* html_open_tag_node) {
|
70
|
+
if (html_open_tag_node == NULL) { return Qnil; }
|
71
|
+
|
72
|
+
AST_NODE_T* node = &html_open_tag_node->base;
|
73
|
+
|
74
|
+
VALUE Herb = rb_define_module("Herb");
|
75
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
76
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
77
|
+
VALUE HTMLOpenTagNode = rb_define_class_under(AST, "HTMLOpenTagNode", Node);
|
78
|
+
|
79
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
80
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
81
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
82
|
+
|
83
|
+
VALUE html_open_tag_node_tag_opening = rb_token_from_c_struct(html_open_tag_node->tag_opening);
|
84
|
+
VALUE html_open_tag_node_tag_name = rb_token_from_c_struct(html_open_tag_node->tag_name);
|
85
|
+
VALUE html_open_tag_node_tag_closing = rb_token_from_c_struct(html_open_tag_node->tag_closing);
|
86
|
+
VALUE html_open_tag_node_children = rb_nodes_array_from_c_array(html_open_tag_node->children);
|
87
|
+
VALUE html_open_tag_node_is_void = (html_open_tag_node->is_void) ? Qtrue : Qfalse;
|
88
|
+
|
89
|
+
VALUE args[8] = {
|
90
|
+
type,
|
91
|
+
location,
|
92
|
+
errors,
|
93
|
+
html_open_tag_node_tag_opening,
|
94
|
+
html_open_tag_node_tag_name,
|
95
|
+
html_open_tag_node_tag_closing,
|
96
|
+
html_open_tag_node_children,
|
97
|
+
html_open_tag_node_is_void
|
98
|
+
};
|
99
|
+
|
100
|
+
return rb_class_new_instance(8, args, HTMLOpenTagNode);
|
101
|
+
};
|
102
|
+
|
103
|
+
static VALUE rb_html_close_tag_node_from_c_struct(AST_HTML_CLOSE_TAG_NODE_T* html_close_tag_node) {
|
104
|
+
if (html_close_tag_node == NULL) { return Qnil; }
|
105
|
+
|
106
|
+
AST_NODE_T* node = &html_close_tag_node->base;
|
107
|
+
|
108
|
+
VALUE Herb = rb_define_module("Herb");
|
109
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
110
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
111
|
+
VALUE HTMLCloseTagNode = rb_define_class_under(AST, "HTMLCloseTagNode", Node);
|
112
|
+
|
113
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
114
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
115
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
116
|
+
|
117
|
+
VALUE html_close_tag_node_tag_opening = rb_token_from_c_struct(html_close_tag_node->tag_opening);
|
118
|
+
VALUE html_close_tag_node_tag_name = rb_token_from_c_struct(html_close_tag_node->tag_name);
|
119
|
+
VALUE html_close_tag_node_tag_closing = rb_token_from_c_struct(html_close_tag_node->tag_closing);
|
120
|
+
|
121
|
+
VALUE args[6] = {
|
122
|
+
type,
|
123
|
+
location,
|
124
|
+
errors,
|
125
|
+
html_close_tag_node_tag_opening,
|
126
|
+
html_close_tag_node_tag_name,
|
127
|
+
html_close_tag_node_tag_closing
|
128
|
+
};
|
129
|
+
|
130
|
+
return rb_class_new_instance(6, args, HTMLCloseTagNode);
|
131
|
+
};
|
132
|
+
|
133
|
+
static VALUE rb_html_self_close_tag_node_from_c_struct(AST_HTML_SELF_CLOSE_TAG_NODE_T* html_self_close_tag_node) {
|
134
|
+
if (html_self_close_tag_node == NULL) { return Qnil; }
|
135
|
+
|
136
|
+
AST_NODE_T* node = &html_self_close_tag_node->base;
|
137
|
+
|
138
|
+
VALUE Herb = rb_define_module("Herb");
|
139
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
140
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
141
|
+
VALUE HTMLSelfCloseTagNode = rb_define_class_under(AST, "HTMLSelfCloseTagNode", Node);
|
142
|
+
|
143
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
144
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
145
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
146
|
+
|
147
|
+
VALUE html_self_close_tag_node_tag_opening = rb_token_from_c_struct(html_self_close_tag_node->tag_opening);
|
148
|
+
VALUE html_self_close_tag_node_tag_name = rb_token_from_c_struct(html_self_close_tag_node->tag_name);
|
149
|
+
VALUE html_self_close_tag_node_attributes = rb_nodes_array_from_c_array(html_self_close_tag_node->attributes);
|
150
|
+
VALUE html_self_close_tag_node_tag_closing = rb_token_from_c_struct(html_self_close_tag_node->tag_closing);
|
151
|
+
VALUE html_self_close_tag_node_is_void = (html_self_close_tag_node->is_void) ? Qtrue : Qfalse;
|
152
|
+
|
153
|
+
VALUE args[8] = {
|
154
|
+
type,
|
155
|
+
location,
|
156
|
+
errors,
|
157
|
+
html_self_close_tag_node_tag_opening,
|
158
|
+
html_self_close_tag_node_tag_name,
|
159
|
+
html_self_close_tag_node_attributes,
|
160
|
+
html_self_close_tag_node_tag_closing,
|
161
|
+
html_self_close_tag_node_is_void
|
162
|
+
};
|
163
|
+
|
164
|
+
return rb_class_new_instance(8, args, HTMLSelfCloseTagNode);
|
165
|
+
};
|
166
|
+
|
167
|
+
static VALUE rb_html_element_node_from_c_struct(AST_HTML_ELEMENT_NODE_T* html_element_node) {
|
168
|
+
if (html_element_node == NULL) { return Qnil; }
|
169
|
+
|
170
|
+
AST_NODE_T* node = &html_element_node->base;
|
171
|
+
|
172
|
+
VALUE Herb = rb_define_module("Herb");
|
173
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
174
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
175
|
+
VALUE HTMLElementNode = rb_define_class_under(AST, "HTMLElementNode", Node);
|
176
|
+
|
177
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
178
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
179
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
180
|
+
|
181
|
+
VALUE html_element_node_open_tag = rb_node_from_c_struct((AST_NODE_T*) html_element_node->open_tag);
|
182
|
+
VALUE html_element_node_tag_name = rb_token_from_c_struct(html_element_node->tag_name);
|
183
|
+
VALUE html_element_node_body = rb_nodes_array_from_c_array(html_element_node->body);
|
184
|
+
VALUE html_element_node_close_tag = rb_node_from_c_struct((AST_NODE_T*) html_element_node->close_tag);
|
185
|
+
VALUE html_element_node_is_void = (html_element_node->is_void) ? Qtrue : Qfalse;
|
186
|
+
|
187
|
+
VALUE args[8] = {
|
188
|
+
type,
|
189
|
+
location,
|
190
|
+
errors,
|
191
|
+
html_element_node_open_tag,
|
192
|
+
html_element_node_tag_name,
|
193
|
+
html_element_node_body,
|
194
|
+
html_element_node_close_tag,
|
195
|
+
html_element_node_is_void
|
196
|
+
};
|
197
|
+
|
198
|
+
return rb_class_new_instance(8, args, HTMLElementNode);
|
199
|
+
};
|
200
|
+
|
201
|
+
static VALUE rb_html_attribute_value_node_from_c_struct(AST_HTML_ATTRIBUTE_VALUE_NODE_T* html_attribute_value_node) {
|
202
|
+
if (html_attribute_value_node == NULL) { return Qnil; }
|
203
|
+
|
204
|
+
AST_NODE_T* node = &html_attribute_value_node->base;
|
205
|
+
|
206
|
+
VALUE Herb = rb_define_module("Herb");
|
207
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
208
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
209
|
+
VALUE HTMLAttributeValueNode = rb_define_class_under(AST, "HTMLAttributeValueNode", Node);
|
210
|
+
|
211
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
212
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
213
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
214
|
+
|
215
|
+
VALUE html_attribute_value_node_open_quote = rb_token_from_c_struct(html_attribute_value_node->open_quote);
|
216
|
+
VALUE html_attribute_value_node_children = rb_nodes_array_from_c_array(html_attribute_value_node->children);
|
217
|
+
VALUE html_attribute_value_node_close_quote = rb_token_from_c_struct(html_attribute_value_node->close_quote);
|
218
|
+
VALUE html_attribute_value_node_quoted = (html_attribute_value_node->quoted) ? Qtrue : Qfalse;
|
219
|
+
|
220
|
+
VALUE args[7] = {
|
221
|
+
type,
|
222
|
+
location,
|
223
|
+
errors,
|
224
|
+
html_attribute_value_node_open_quote,
|
225
|
+
html_attribute_value_node_children,
|
226
|
+
html_attribute_value_node_close_quote,
|
227
|
+
html_attribute_value_node_quoted
|
228
|
+
};
|
229
|
+
|
230
|
+
return rb_class_new_instance(7, args, HTMLAttributeValueNode);
|
231
|
+
};
|
232
|
+
|
233
|
+
static VALUE rb_html_attribute_name_node_from_c_struct(AST_HTML_ATTRIBUTE_NAME_NODE_T* html_attribute_name_node) {
|
234
|
+
if (html_attribute_name_node == NULL) { return Qnil; }
|
235
|
+
|
236
|
+
AST_NODE_T* node = &html_attribute_name_node->base;
|
237
|
+
|
238
|
+
VALUE Herb = rb_define_module("Herb");
|
239
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
240
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
241
|
+
VALUE HTMLAttributeNameNode = rb_define_class_under(AST, "HTMLAttributeNameNode", Node);
|
242
|
+
|
243
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
244
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
245
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
246
|
+
|
247
|
+
VALUE html_attribute_name_node_name = rb_token_from_c_struct(html_attribute_name_node->name);
|
248
|
+
|
249
|
+
VALUE args[4] = {
|
250
|
+
type,
|
251
|
+
location,
|
252
|
+
errors,
|
253
|
+
html_attribute_name_node_name
|
254
|
+
};
|
255
|
+
|
256
|
+
return rb_class_new_instance(4, args, HTMLAttributeNameNode);
|
257
|
+
};
|
258
|
+
|
259
|
+
static VALUE rb_html_attribute_node_from_c_struct(AST_HTML_ATTRIBUTE_NODE_T* html_attribute_node) {
|
260
|
+
if (html_attribute_node == NULL) { return Qnil; }
|
261
|
+
|
262
|
+
AST_NODE_T* node = &html_attribute_node->base;
|
263
|
+
|
264
|
+
VALUE Herb = rb_define_module("Herb");
|
265
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
266
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
267
|
+
VALUE HTMLAttributeNode = rb_define_class_under(AST, "HTMLAttributeNode", Node);
|
268
|
+
|
269
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
270
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
271
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
272
|
+
|
273
|
+
VALUE html_attribute_node_name = rb_node_from_c_struct((AST_NODE_T*) html_attribute_node->name);
|
274
|
+
VALUE html_attribute_node_equals = rb_token_from_c_struct(html_attribute_node->equals);
|
275
|
+
VALUE html_attribute_node_value = rb_node_from_c_struct((AST_NODE_T*) html_attribute_node->value);
|
276
|
+
|
277
|
+
VALUE args[6] = {
|
278
|
+
type,
|
279
|
+
location,
|
280
|
+
errors,
|
281
|
+
html_attribute_node_name,
|
282
|
+
html_attribute_node_equals,
|
283
|
+
html_attribute_node_value
|
284
|
+
};
|
285
|
+
|
286
|
+
return rb_class_new_instance(6, args, HTMLAttributeNode);
|
287
|
+
};
|
288
|
+
|
289
|
+
static VALUE rb_html_text_node_from_c_struct(AST_HTML_TEXT_NODE_T* html_text_node) {
|
290
|
+
if (html_text_node == NULL) { return Qnil; }
|
291
|
+
|
292
|
+
AST_NODE_T* node = &html_text_node->base;
|
293
|
+
|
294
|
+
VALUE Herb = rb_define_module("Herb");
|
295
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
296
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
297
|
+
VALUE HTMLTextNode = rb_define_class_under(AST, "HTMLTextNode", Node);
|
298
|
+
|
299
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
300
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
301
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
302
|
+
|
303
|
+
VALUE html_text_node_content = rb_str_new_cstr(html_text_node->content);
|
304
|
+
|
305
|
+
VALUE args[4] = {
|
306
|
+
type,
|
307
|
+
location,
|
308
|
+
errors,
|
309
|
+
html_text_node_content
|
310
|
+
};
|
311
|
+
|
312
|
+
return rb_class_new_instance(4, args, HTMLTextNode);
|
313
|
+
};
|
314
|
+
|
315
|
+
static VALUE rb_html_comment_node_from_c_struct(AST_HTML_COMMENT_NODE_T* html_comment_node) {
|
316
|
+
if (html_comment_node == NULL) { return Qnil; }
|
317
|
+
|
318
|
+
AST_NODE_T* node = &html_comment_node->base;
|
319
|
+
|
320
|
+
VALUE Herb = rb_define_module("Herb");
|
321
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
322
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
323
|
+
VALUE HTMLCommentNode = rb_define_class_under(AST, "HTMLCommentNode", Node);
|
324
|
+
|
325
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
326
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
327
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
328
|
+
|
329
|
+
VALUE html_comment_node_comment_start = rb_token_from_c_struct(html_comment_node->comment_start);
|
330
|
+
VALUE html_comment_node_children = rb_nodes_array_from_c_array(html_comment_node->children);
|
331
|
+
VALUE html_comment_node_comment_end = rb_token_from_c_struct(html_comment_node->comment_end);
|
332
|
+
|
333
|
+
VALUE args[6] = {
|
334
|
+
type,
|
335
|
+
location,
|
336
|
+
errors,
|
337
|
+
html_comment_node_comment_start,
|
338
|
+
html_comment_node_children,
|
339
|
+
html_comment_node_comment_end
|
340
|
+
};
|
341
|
+
|
342
|
+
return rb_class_new_instance(6, args, HTMLCommentNode);
|
343
|
+
};
|
344
|
+
|
345
|
+
static VALUE rb_html_doctype_node_from_c_struct(AST_HTML_DOCTYPE_NODE_T* html_doctype_node) {
|
346
|
+
if (html_doctype_node == NULL) { return Qnil; }
|
347
|
+
|
348
|
+
AST_NODE_T* node = &html_doctype_node->base;
|
349
|
+
|
350
|
+
VALUE Herb = rb_define_module("Herb");
|
351
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
352
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
353
|
+
VALUE HTMLDoctypeNode = rb_define_class_under(AST, "HTMLDoctypeNode", Node);
|
354
|
+
|
355
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
356
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
357
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
358
|
+
|
359
|
+
VALUE html_doctype_node_tag_opening = rb_token_from_c_struct(html_doctype_node->tag_opening);
|
360
|
+
VALUE html_doctype_node_children = rb_nodes_array_from_c_array(html_doctype_node->children);
|
361
|
+
VALUE html_doctype_node_tag_closing = rb_token_from_c_struct(html_doctype_node->tag_closing);
|
362
|
+
|
363
|
+
VALUE args[6] = {
|
364
|
+
type,
|
365
|
+
location,
|
366
|
+
errors,
|
367
|
+
html_doctype_node_tag_opening,
|
368
|
+
html_doctype_node_children,
|
369
|
+
html_doctype_node_tag_closing
|
370
|
+
};
|
371
|
+
|
372
|
+
return rb_class_new_instance(6, args, HTMLDoctypeNode);
|
373
|
+
};
|
374
|
+
|
375
|
+
static VALUE rb_whitespace_node_from_c_struct(AST_WHITESPACE_NODE_T* whitespace_node) {
|
376
|
+
if (whitespace_node == NULL) { return Qnil; }
|
377
|
+
|
378
|
+
AST_NODE_T* node = &whitespace_node->base;
|
379
|
+
|
380
|
+
VALUE Herb = rb_define_module("Herb");
|
381
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
382
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
383
|
+
VALUE WhitespaceNode = rb_define_class_under(AST, "WhitespaceNode", Node);
|
384
|
+
|
385
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
386
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
387
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
388
|
+
|
389
|
+
VALUE whitespace_node_value = rb_token_from_c_struct(whitespace_node->value);
|
390
|
+
|
391
|
+
VALUE args[4] = {
|
392
|
+
type,
|
393
|
+
location,
|
394
|
+
errors,
|
395
|
+
whitespace_node_value
|
396
|
+
};
|
397
|
+
|
398
|
+
return rb_class_new_instance(4, args, WhitespaceNode);
|
399
|
+
};
|
400
|
+
|
401
|
+
static VALUE rb_erb_content_node_from_c_struct(AST_ERB_CONTENT_NODE_T* erb_content_node) {
|
402
|
+
if (erb_content_node == NULL) { return Qnil; }
|
403
|
+
|
404
|
+
AST_NODE_T* node = &erb_content_node->base;
|
405
|
+
|
406
|
+
VALUE Herb = rb_define_module("Herb");
|
407
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
408
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
409
|
+
VALUE ERBContentNode = rb_define_class_under(AST, "ERBContentNode", Node);
|
410
|
+
|
411
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
412
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
413
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
414
|
+
|
415
|
+
VALUE erb_content_node_tag_opening = rb_token_from_c_struct(erb_content_node->tag_opening);
|
416
|
+
VALUE erb_content_node_content = rb_token_from_c_struct(erb_content_node->content);
|
417
|
+
VALUE erb_content_node_tag_closing = rb_token_from_c_struct(erb_content_node->tag_closing);
|
418
|
+
/* #<Herb::Template::AnalyzedRubyField:0x00007fffe32c9800 @name="analyzed_ruby", @options={kind: nil}> */
|
419
|
+
VALUE erb_content_node_analyzed_ruby = Qnil;
|
420
|
+
VALUE erb_content_node_parsed = (erb_content_node->parsed) ? Qtrue : Qfalse;
|
421
|
+
VALUE erb_content_node_valid = (erb_content_node->valid) ? Qtrue : Qfalse;
|
422
|
+
|
423
|
+
VALUE args[9] = {
|
424
|
+
type,
|
425
|
+
location,
|
426
|
+
errors,
|
427
|
+
erb_content_node_tag_opening,
|
428
|
+
erb_content_node_content,
|
429
|
+
erb_content_node_tag_closing,
|
430
|
+
erb_content_node_analyzed_ruby,
|
431
|
+
erb_content_node_parsed,
|
432
|
+
erb_content_node_valid
|
433
|
+
};
|
434
|
+
|
435
|
+
return rb_class_new_instance(9, args, ERBContentNode);
|
436
|
+
};
|
437
|
+
|
438
|
+
static VALUE rb_erb_end_node_from_c_struct(AST_ERB_END_NODE_T* erb_end_node) {
|
439
|
+
if (erb_end_node == NULL) { return Qnil; }
|
440
|
+
|
441
|
+
AST_NODE_T* node = &erb_end_node->base;
|
442
|
+
|
443
|
+
VALUE Herb = rb_define_module("Herb");
|
444
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
445
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
446
|
+
VALUE ERBEndNode = rb_define_class_under(AST, "ERBEndNode", Node);
|
447
|
+
|
448
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
449
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
450
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
451
|
+
|
452
|
+
VALUE erb_end_node_tag_opening = rb_token_from_c_struct(erb_end_node->tag_opening);
|
453
|
+
VALUE erb_end_node_content = rb_token_from_c_struct(erb_end_node->content);
|
454
|
+
VALUE erb_end_node_tag_closing = rb_token_from_c_struct(erb_end_node->tag_closing);
|
455
|
+
|
456
|
+
VALUE args[6] = {
|
457
|
+
type,
|
458
|
+
location,
|
459
|
+
errors,
|
460
|
+
erb_end_node_tag_opening,
|
461
|
+
erb_end_node_content,
|
462
|
+
erb_end_node_tag_closing
|
463
|
+
};
|
464
|
+
|
465
|
+
return rb_class_new_instance(6, args, ERBEndNode);
|
466
|
+
};
|
467
|
+
|
468
|
+
static VALUE rb_erb_else_node_from_c_struct(AST_ERB_ELSE_NODE_T* erb_else_node) {
|
469
|
+
if (erb_else_node == NULL) { return Qnil; }
|
470
|
+
|
471
|
+
AST_NODE_T* node = &erb_else_node->base;
|
472
|
+
|
473
|
+
VALUE Herb = rb_define_module("Herb");
|
474
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
475
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
476
|
+
VALUE ERBElseNode = rb_define_class_under(AST, "ERBElseNode", Node);
|
477
|
+
|
478
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
479
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
480
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
481
|
+
|
482
|
+
VALUE erb_else_node_tag_opening = rb_token_from_c_struct(erb_else_node->tag_opening);
|
483
|
+
VALUE erb_else_node_content = rb_token_from_c_struct(erb_else_node->content);
|
484
|
+
VALUE erb_else_node_tag_closing = rb_token_from_c_struct(erb_else_node->tag_closing);
|
485
|
+
VALUE erb_else_node_statements = rb_nodes_array_from_c_array(erb_else_node->statements);
|
486
|
+
|
487
|
+
VALUE args[7] = {
|
488
|
+
type,
|
489
|
+
location,
|
490
|
+
errors,
|
491
|
+
erb_else_node_tag_opening,
|
492
|
+
erb_else_node_content,
|
493
|
+
erb_else_node_tag_closing,
|
494
|
+
erb_else_node_statements
|
495
|
+
};
|
496
|
+
|
497
|
+
return rb_class_new_instance(7, args, ERBElseNode);
|
498
|
+
};
|
499
|
+
|
500
|
+
static VALUE rb_erb_if_node_from_c_struct(AST_ERB_IF_NODE_T* erb_if_node) {
|
501
|
+
if (erb_if_node == NULL) { return Qnil; }
|
502
|
+
|
503
|
+
AST_NODE_T* node = &erb_if_node->base;
|
504
|
+
|
505
|
+
VALUE Herb = rb_define_module("Herb");
|
506
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
507
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
508
|
+
VALUE ERBIfNode = rb_define_class_under(AST, "ERBIfNode", Node);
|
509
|
+
|
510
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
511
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
512
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
513
|
+
|
514
|
+
VALUE erb_if_node_tag_opening = rb_token_from_c_struct(erb_if_node->tag_opening);
|
515
|
+
VALUE erb_if_node_content = rb_token_from_c_struct(erb_if_node->content);
|
516
|
+
VALUE erb_if_node_tag_closing = rb_token_from_c_struct(erb_if_node->tag_closing);
|
517
|
+
VALUE erb_if_node_statements = rb_nodes_array_from_c_array(erb_if_node->statements);
|
518
|
+
VALUE erb_if_node_subsequent = rb_node_from_c_struct((AST_NODE_T*) erb_if_node->subsequent);
|
519
|
+
VALUE erb_if_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_if_node->end_node);
|
520
|
+
|
521
|
+
VALUE args[9] = {
|
522
|
+
type,
|
523
|
+
location,
|
524
|
+
errors,
|
525
|
+
erb_if_node_tag_opening,
|
526
|
+
erb_if_node_content,
|
527
|
+
erb_if_node_tag_closing,
|
528
|
+
erb_if_node_statements,
|
529
|
+
erb_if_node_subsequent,
|
530
|
+
erb_if_node_end_node
|
531
|
+
};
|
532
|
+
|
533
|
+
return rb_class_new_instance(9, args, ERBIfNode);
|
534
|
+
};
|
535
|
+
|
536
|
+
static VALUE rb_erb_block_node_from_c_struct(AST_ERB_BLOCK_NODE_T* erb_block_node) {
|
537
|
+
if (erb_block_node == NULL) { return Qnil; }
|
538
|
+
|
539
|
+
AST_NODE_T* node = &erb_block_node->base;
|
540
|
+
|
541
|
+
VALUE Herb = rb_define_module("Herb");
|
542
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
543
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
544
|
+
VALUE ERBBlockNode = rb_define_class_under(AST, "ERBBlockNode", Node);
|
545
|
+
|
546
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
547
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
548
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
549
|
+
|
550
|
+
VALUE erb_block_node_tag_opening = rb_token_from_c_struct(erb_block_node->tag_opening);
|
551
|
+
VALUE erb_block_node_content = rb_token_from_c_struct(erb_block_node->content);
|
552
|
+
VALUE erb_block_node_tag_closing = rb_token_from_c_struct(erb_block_node->tag_closing);
|
553
|
+
VALUE erb_block_node_body = rb_nodes_array_from_c_array(erb_block_node->body);
|
554
|
+
VALUE erb_block_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_block_node->end_node);
|
555
|
+
|
556
|
+
VALUE args[8] = {
|
557
|
+
type,
|
558
|
+
location,
|
559
|
+
errors,
|
560
|
+
erb_block_node_tag_opening,
|
561
|
+
erb_block_node_content,
|
562
|
+
erb_block_node_tag_closing,
|
563
|
+
erb_block_node_body,
|
564
|
+
erb_block_node_end_node
|
565
|
+
};
|
566
|
+
|
567
|
+
return rb_class_new_instance(8, args, ERBBlockNode);
|
568
|
+
};
|
569
|
+
|
570
|
+
static VALUE rb_erb_when_node_from_c_struct(AST_ERB_WHEN_NODE_T* erb_when_node) {
|
571
|
+
if (erb_when_node == NULL) { return Qnil; }
|
572
|
+
|
573
|
+
AST_NODE_T* node = &erb_when_node->base;
|
574
|
+
|
575
|
+
VALUE Herb = rb_define_module("Herb");
|
576
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
577
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
578
|
+
VALUE ERBWhenNode = rb_define_class_under(AST, "ERBWhenNode", Node);
|
579
|
+
|
580
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
581
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
582
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
583
|
+
|
584
|
+
VALUE erb_when_node_tag_opening = rb_token_from_c_struct(erb_when_node->tag_opening);
|
585
|
+
VALUE erb_when_node_content = rb_token_from_c_struct(erb_when_node->content);
|
586
|
+
VALUE erb_when_node_tag_closing = rb_token_from_c_struct(erb_when_node->tag_closing);
|
587
|
+
VALUE erb_when_node_statements = rb_nodes_array_from_c_array(erb_when_node->statements);
|
588
|
+
|
589
|
+
VALUE args[7] = {
|
590
|
+
type,
|
591
|
+
location,
|
592
|
+
errors,
|
593
|
+
erb_when_node_tag_opening,
|
594
|
+
erb_when_node_content,
|
595
|
+
erb_when_node_tag_closing,
|
596
|
+
erb_when_node_statements
|
597
|
+
};
|
598
|
+
|
599
|
+
return rb_class_new_instance(7, args, ERBWhenNode);
|
600
|
+
};
|
601
|
+
|
602
|
+
static VALUE rb_erb_case_node_from_c_struct(AST_ERB_CASE_NODE_T* erb_case_node) {
|
603
|
+
if (erb_case_node == NULL) { return Qnil; }
|
604
|
+
|
605
|
+
AST_NODE_T* node = &erb_case_node->base;
|
606
|
+
|
607
|
+
VALUE Herb = rb_define_module("Herb");
|
608
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
609
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
610
|
+
VALUE ERBCaseNode = rb_define_class_under(AST, "ERBCaseNode", Node);
|
611
|
+
|
612
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
613
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
614
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
615
|
+
|
616
|
+
VALUE erb_case_node_tag_opening = rb_token_from_c_struct(erb_case_node->tag_opening);
|
617
|
+
VALUE erb_case_node_content = rb_token_from_c_struct(erb_case_node->content);
|
618
|
+
VALUE erb_case_node_tag_closing = rb_token_from_c_struct(erb_case_node->tag_closing);
|
619
|
+
VALUE erb_case_node_children = rb_nodes_array_from_c_array(erb_case_node->children);
|
620
|
+
VALUE erb_case_node_conditions = rb_nodes_array_from_c_array(erb_case_node->conditions);
|
621
|
+
VALUE erb_case_node_else_clause = rb_node_from_c_struct((AST_NODE_T*) erb_case_node->else_clause);
|
622
|
+
VALUE erb_case_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_case_node->end_node);
|
623
|
+
|
624
|
+
VALUE args[10] = {
|
625
|
+
type,
|
626
|
+
location,
|
627
|
+
errors,
|
628
|
+
erb_case_node_tag_opening,
|
629
|
+
erb_case_node_content,
|
630
|
+
erb_case_node_tag_closing,
|
631
|
+
erb_case_node_children,
|
632
|
+
erb_case_node_conditions,
|
633
|
+
erb_case_node_else_clause,
|
634
|
+
erb_case_node_end_node
|
635
|
+
};
|
636
|
+
|
637
|
+
return rb_class_new_instance(10, args, ERBCaseNode);
|
638
|
+
};
|
639
|
+
|
640
|
+
static VALUE rb_erb_while_node_from_c_struct(AST_ERB_WHILE_NODE_T* erb_while_node) {
|
641
|
+
if (erb_while_node == NULL) { return Qnil; }
|
642
|
+
|
643
|
+
AST_NODE_T* node = &erb_while_node->base;
|
644
|
+
|
645
|
+
VALUE Herb = rb_define_module("Herb");
|
646
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
647
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
648
|
+
VALUE ERBWhileNode = rb_define_class_under(AST, "ERBWhileNode", Node);
|
649
|
+
|
650
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
651
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
652
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
653
|
+
|
654
|
+
VALUE erb_while_node_tag_opening = rb_token_from_c_struct(erb_while_node->tag_opening);
|
655
|
+
VALUE erb_while_node_content = rb_token_from_c_struct(erb_while_node->content);
|
656
|
+
VALUE erb_while_node_tag_closing = rb_token_from_c_struct(erb_while_node->tag_closing);
|
657
|
+
VALUE erb_while_node_statements = rb_nodes_array_from_c_array(erb_while_node->statements);
|
658
|
+
VALUE erb_while_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_while_node->end_node);
|
659
|
+
|
660
|
+
VALUE args[8] = {
|
661
|
+
type,
|
662
|
+
location,
|
663
|
+
errors,
|
664
|
+
erb_while_node_tag_opening,
|
665
|
+
erb_while_node_content,
|
666
|
+
erb_while_node_tag_closing,
|
667
|
+
erb_while_node_statements,
|
668
|
+
erb_while_node_end_node
|
669
|
+
};
|
670
|
+
|
671
|
+
return rb_class_new_instance(8, args, ERBWhileNode);
|
672
|
+
};
|
673
|
+
|
674
|
+
static VALUE rb_erb_until_node_from_c_struct(AST_ERB_UNTIL_NODE_T* erb_until_node) {
|
675
|
+
if (erb_until_node == NULL) { return Qnil; }
|
676
|
+
|
677
|
+
AST_NODE_T* node = &erb_until_node->base;
|
678
|
+
|
679
|
+
VALUE Herb = rb_define_module("Herb");
|
680
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
681
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
682
|
+
VALUE ERBUntilNode = rb_define_class_under(AST, "ERBUntilNode", Node);
|
683
|
+
|
684
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
685
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
686
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
687
|
+
|
688
|
+
VALUE erb_until_node_tag_opening = rb_token_from_c_struct(erb_until_node->tag_opening);
|
689
|
+
VALUE erb_until_node_content = rb_token_from_c_struct(erb_until_node->content);
|
690
|
+
VALUE erb_until_node_tag_closing = rb_token_from_c_struct(erb_until_node->tag_closing);
|
691
|
+
VALUE erb_until_node_statements = rb_nodes_array_from_c_array(erb_until_node->statements);
|
692
|
+
VALUE erb_until_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_until_node->end_node);
|
693
|
+
|
694
|
+
VALUE args[8] = {
|
695
|
+
type,
|
696
|
+
location,
|
697
|
+
errors,
|
698
|
+
erb_until_node_tag_opening,
|
699
|
+
erb_until_node_content,
|
700
|
+
erb_until_node_tag_closing,
|
701
|
+
erb_until_node_statements,
|
702
|
+
erb_until_node_end_node
|
703
|
+
};
|
704
|
+
|
705
|
+
return rb_class_new_instance(8, args, ERBUntilNode);
|
706
|
+
};
|
707
|
+
|
708
|
+
static VALUE rb_erb_for_node_from_c_struct(AST_ERB_FOR_NODE_T* erb_for_node) {
|
709
|
+
if (erb_for_node == NULL) { return Qnil; }
|
710
|
+
|
711
|
+
AST_NODE_T* node = &erb_for_node->base;
|
712
|
+
|
713
|
+
VALUE Herb = rb_define_module("Herb");
|
714
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
715
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
716
|
+
VALUE ERBForNode = rb_define_class_under(AST, "ERBForNode", Node);
|
717
|
+
|
718
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
719
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
720
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
721
|
+
|
722
|
+
VALUE erb_for_node_tag_opening = rb_token_from_c_struct(erb_for_node->tag_opening);
|
723
|
+
VALUE erb_for_node_content = rb_token_from_c_struct(erb_for_node->content);
|
724
|
+
VALUE erb_for_node_tag_closing = rb_token_from_c_struct(erb_for_node->tag_closing);
|
725
|
+
VALUE erb_for_node_statements = rb_nodes_array_from_c_array(erb_for_node->statements);
|
726
|
+
VALUE erb_for_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_for_node->end_node);
|
727
|
+
|
728
|
+
VALUE args[8] = {
|
729
|
+
type,
|
730
|
+
location,
|
731
|
+
errors,
|
732
|
+
erb_for_node_tag_opening,
|
733
|
+
erb_for_node_content,
|
734
|
+
erb_for_node_tag_closing,
|
735
|
+
erb_for_node_statements,
|
736
|
+
erb_for_node_end_node
|
737
|
+
};
|
738
|
+
|
739
|
+
return rb_class_new_instance(8, args, ERBForNode);
|
740
|
+
};
|
741
|
+
|
742
|
+
static VALUE rb_erb_rescue_node_from_c_struct(AST_ERB_RESCUE_NODE_T* erb_rescue_node) {
|
743
|
+
if (erb_rescue_node == NULL) { return Qnil; }
|
744
|
+
|
745
|
+
AST_NODE_T* node = &erb_rescue_node->base;
|
746
|
+
|
747
|
+
VALUE Herb = rb_define_module("Herb");
|
748
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
749
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
750
|
+
VALUE ERBRescueNode = rb_define_class_under(AST, "ERBRescueNode", Node);
|
751
|
+
|
752
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
753
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
754
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
755
|
+
|
756
|
+
VALUE erb_rescue_node_tag_opening = rb_token_from_c_struct(erb_rescue_node->tag_opening);
|
757
|
+
VALUE erb_rescue_node_content = rb_token_from_c_struct(erb_rescue_node->content);
|
758
|
+
VALUE erb_rescue_node_tag_closing = rb_token_from_c_struct(erb_rescue_node->tag_closing);
|
759
|
+
VALUE erb_rescue_node_statements = rb_nodes_array_from_c_array(erb_rescue_node->statements);
|
760
|
+
VALUE erb_rescue_node_subsequent = rb_node_from_c_struct((AST_NODE_T*) erb_rescue_node->subsequent);
|
761
|
+
|
762
|
+
VALUE args[8] = {
|
763
|
+
type,
|
764
|
+
location,
|
765
|
+
errors,
|
766
|
+
erb_rescue_node_tag_opening,
|
767
|
+
erb_rescue_node_content,
|
768
|
+
erb_rescue_node_tag_closing,
|
769
|
+
erb_rescue_node_statements,
|
770
|
+
erb_rescue_node_subsequent
|
771
|
+
};
|
772
|
+
|
773
|
+
return rb_class_new_instance(8, args, ERBRescueNode);
|
774
|
+
};
|
775
|
+
|
776
|
+
static VALUE rb_erb_ensure_node_from_c_struct(AST_ERB_ENSURE_NODE_T* erb_ensure_node) {
|
777
|
+
if (erb_ensure_node == NULL) { return Qnil; }
|
778
|
+
|
779
|
+
AST_NODE_T* node = &erb_ensure_node->base;
|
780
|
+
|
781
|
+
VALUE Herb = rb_define_module("Herb");
|
782
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
783
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
784
|
+
VALUE ERBEnsureNode = rb_define_class_under(AST, "ERBEnsureNode", Node);
|
785
|
+
|
786
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
787
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
788
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
789
|
+
|
790
|
+
VALUE erb_ensure_node_tag_opening = rb_token_from_c_struct(erb_ensure_node->tag_opening);
|
791
|
+
VALUE erb_ensure_node_content = rb_token_from_c_struct(erb_ensure_node->content);
|
792
|
+
VALUE erb_ensure_node_tag_closing = rb_token_from_c_struct(erb_ensure_node->tag_closing);
|
793
|
+
VALUE erb_ensure_node_statements = rb_nodes_array_from_c_array(erb_ensure_node->statements);
|
794
|
+
|
795
|
+
VALUE args[7] = {
|
796
|
+
type,
|
797
|
+
location,
|
798
|
+
errors,
|
799
|
+
erb_ensure_node_tag_opening,
|
800
|
+
erb_ensure_node_content,
|
801
|
+
erb_ensure_node_tag_closing,
|
802
|
+
erb_ensure_node_statements
|
803
|
+
};
|
804
|
+
|
805
|
+
return rb_class_new_instance(7, args, ERBEnsureNode);
|
806
|
+
};
|
807
|
+
|
808
|
+
static VALUE rb_erb_begin_node_from_c_struct(AST_ERB_BEGIN_NODE_T* erb_begin_node) {
|
809
|
+
if (erb_begin_node == NULL) { return Qnil; }
|
810
|
+
|
811
|
+
AST_NODE_T* node = &erb_begin_node->base;
|
812
|
+
|
813
|
+
VALUE Herb = rb_define_module("Herb");
|
814
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
815
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
816
|
+
VALUE ERBBeginNode = rb_define_class_under(AST, "ERBBeginNode", Node);
|
817
|
+
|
818
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
819
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
820
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
821
|
+
|
822
|
+
VALUE erb_begin_node_tag_opening = rb_token_from_c_struct(erb_begin_node->tag_opening);
|
823
|
+
VALUE erb_begin_node_content = rb_token_from_c_struct(erb_begin_node->content);
|
824
|
+
VALUE erb_begin_node_tag_closing = rb_token_from_c_struct(erb_begin_node->tag_closing);
|
825
|
+
VALUE erb_begin_node_statements = rb_nodes_array_from_c_array(erb_begin_node->statements);
|
826
|
+
VALUE erb_begin_node_rescue_clause = rb_node_from_c_struct((AST_NODE_T*) erb_begin_node->rescue_clause);
|
827
|
+
VALUE erb_begin_node_else_clause = rb_node_from_c_struct((AST_NODE_T*) erb_begin_node->else_clause);
|
828
|
+
VALUE erb_begin_node_ensure_clause = rb_node_from_c_struct((AST_NODE_T*) erb_begin_node->ensure_clause);
|
829
|
+
VALUE erb_begin_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_begin_node->end_node);
|
830
|
+
|
831
|
+
VALUE args[11] = {
|
832
|
+
type,
|
833
|
+
location,
|
834
|
+
errors,
|
835
|
+
erb_begin_node_tag_opening,
|
836
|
+
erb_begin_node_content,
|
837
|
+
erb_begin_node_tag_closing,
|
838
|
+
erb_begin_node_statements,
|
839
|
+
erb_begin_node_rescue_clause,
|
840
|
+
erb_begin_node_else_clause,
|
841
|
+
erb_begin_node_ensure_clause,
|
842
|
+
erb_begin_node_end_node
|
843
|
+
};
|
844
|
+
|
845
|
+
return rb_class_new_instance(11, args, ERBBeginNode);
|
846
|
+
};
|
847
|
+
|
848
|
+
static VALUE rb_erb_unless_node_from_c_struct(AST_ERB_UNLESS_NODE_T* erb_unless_node) {
|
849
|
+
if (erb_unless_node == NULL) { return Qnil; }
|
850
|
+
|
851
|
+
AST_NODE_T* node = &erb_unless_node->base;
|
852
|
+
|
853
|
+
VALUE Herb = rb_define_module("Herb");
|
854
|
+
VALUE AST = rb_define_module_under(Herb, "AST");
|
855
|
+
VALUE Node = rb_define_class_under(AST, "Node", rb_cObject);
|
856
|
+
VALUE ERBUnlessNode = rb_define_class_under(AST, "ERBUnlessNode", Node);
|
857
|
+
|
858
|
+
VALUE type = rb_str_new_cstr(ast_node_type_to_string(node));
|
859
|
+
VALUE location = rb_location_from_c_struct(node->location);
|
860
|
+
VALUE errors = rb_errors_array_from_c_array(node->errors);
|
861
|
+
|
862
|
+
VALUE erb_unless_node_tag_opening = rb_token_from_c_struct(erb_unless_node->tag_opening);
|
863
|
+
VALUE erb_unless_node_content = rb_token_from_c_struct(erb_unless_node->content);
|
864
|
+
VALUE erb_unless_node_tag_closing = rb_token_from_c_struct(erb_unless_node->tag_closing);
|
865
|
+
VALUE erb_unless_node_statements = rb_nodes_array_from_c_array(erb_unless_node->statements);
|
866
|
+
VALUE erb_unless_node_else_clause = rb_node_from_c_struct((AST_NODE_T*) erb_unless_node->else_clause);
|
867
|
+
VALUE erb_unless_node_end_node = rb_node_from_c_struct((AST_NODE_T*) erb_unless_node->end_node);
|
868
|
+
|
869
|
+
VALUE args[9] = {
|
870
|
+
type,
|
871
|
+
location,
|
872
|
+
errors,
|
873
|
+
erb_unless_node_tag_opening,
|
874
|
+
erb_unless_node_content,
|
875
|
+
erb_unless_node_tag_closing,
|
876
|
+
erb_unless_node_statements,
|
877
|
+
erb_unless_node_else_clause,
|
878
|
+
erb_unless_node_end_node
|
879
|
+
};
|
880
|
+
|
881
|
+
return rb_class_new_instance(9, args, ERBUnlessNode);
|
882
|
+
};
|
883
|
+
|
884
|
+
|
885
|
+
VALUE rb_node_from_c_struct(AST_NODE_T* node) {
|
886
|
+
if (!node) { return Qnil; }
|
887
|
+
|
888
|
+
switch (node->type) {
|
889
|
+
case AST_DOCUMENT_NODE: return rb_document_node_from_c_struct((AST_DOCUMENT_NODE_T*) node); break;
|
890
|
+
case AST_LITERAL_NODE: return rb_literal_node_from_c_struct((AST_LITERAL_NODE_T*) node); break;
|
891
|
+
case AST_HTML_OPEN_TAG_NODE: return rb_html_open_tag_node_from_c_struct((AST_HTML_OPEN_TAG_NODE_T*) node); break;
|
892
|
+
case AST_HTML_CLOSE_TAG_NODE: return rb_html_close_tag_node_from_c_struct((AST_HTML_CLOSE_TAG_NODE_T*) node); break;
|
893
|
+
case AST_HTML_SELF_CLOSE_TAG_NODE: return rb_html_self_close_tag_node_from_c_struct((AST_HTML_SELF_CLOSE_TAG_NODE_T*) node); break;
|
894
|
+
case AST_HTML_ELEMENT_NODE: return rb_html_element_node_from_c_struct((AST_HTML_ELEMENT_NODE_T*) node); break;
|
895
|
+
case AST_HTML_ATTRIBUTE_VALUE_NODE: return rb_html_attribute_value_node_from_c_struct((AST_HTML_ATTRIBUTE_VALUE_NODE_T*) node); break;
|
896
|
+
case AST_HTML_ATTRIBUTE_NAME_NODE: return rb_html_attribute_name_node_from_c_struct((AST_HTML_ATTRIBUTE_NAME_NODE_T*) node); break;
|
897
|
+
case AST_HTML_ATTRIBUTE_NODE: return rb_html_attribute_node_from_c_struct((AST_HTML_ATTRIBUTE_NODE_T*) node); break;
|
898
|
+
case AST_HTML_TEXT_NODE: return rb_html_text_node_from_c_struct((AST_HTML_TEXT_NODE_T*) node); break;
|
899
|
+
case AST_HTML_COMMENT_NODE: return rb_html_comment_node_from_c_struct((AST_HTML_COMMENT_NODE_T*) node); break;
|
900
|
+
case AST_HTML_DOCTYPE_NODE: return rb_html_doctype_node_from_c_struct((AST_HTML_DOCTYPE_NODE_T*) node); break;
|
901
|
+
case AST_WHITESPACE_NODE: return rb_whitespace_node_from_c_struct((AST_WHITESPACE_NODE_T*) node); break;
|
902
|
+
case AST_ERB_CONTENT_NODE: return rb_erb_content_node_from_c_struct((AST_ERB_CONTENT_NODE_T*) node); break;
|
903
|
+
case AST_ERB_END_NODE: return rb_erb_end_node_from_c_struct((AST_ERB_END_NODE_T*) node); break;
|
904
|
+
case AST_ERB_ELSE_NODE: return rb_erb_else_node_from_c_struct((AST_ERB_ELSE_NODE_T*) node); break;
|
905
|
+
case AST_ERB_IF_NODE: return rb_erb_if_node_from_c_struct((AST_ERB_IF_NODE_T*) node); break;
|
906
|
+
case AST_ERB_BLOCK_NODE: return rb_erb_block_node_from_c_struct((AST_ERB_BLOCK_NODE_T*) node); break;
|
907
|
+
case AST_ERB_WHEN_NODE: return rb_erb_when_node_from_c_struct((AST_ERB_WHEN_NODE_T*) node); break;
|
908
|
+
case AST_ERB_CASE_NODE: return rb_erb_case_node_from_c_struct((AST_ERB_CASE_NODE_T*) node); break;
|
909
|
+
case AST_ERB_WHILE_NODE: return rb_erb_while_node_from_c_struct((AST_ERB_WHILE_NODE_T*) node); break;
|
910
|
+
case AST_ERB_UNTIL_NODE: return rb_erb_until_node_from_c_struct((AST_ERB_UNTIL_NODE_T*) node); break;
|
911
|
+
case AST_ERB_FOR_NODE: return rb_erb_for_node_from_c_struct((AST_ERB_FOR_NODE_T*) node); break;
|
912
|
+
case AST_ERB_RESCUE_NODE: return rb_erb_rescue_node_from_c_struct((AST_ERB_RESCUE_NODE_T*) node); break;
|
913
|
+
case AST_ERB_ENSURE_NODE: return rb_erb_ensure_node_from_c_struct((AST_ERB_ENSURE_NODE_T*) node); break;
|
914
|
+
case AST_ERB_BEGIN_NODE: return rb_erb_begin_node_from_c_struct((AST_ERB_BEGIN_NODE_T*) node); break;
|
915
|
+
case AST_ERB_UNLESS_NODE: return rb_erb_unless_node_from_c_struct((AST_ERB_UNLESS_NODE_T*) node); break;
|
916
|
+
}
|
917
|
+
|
918
|
+
return Qnil;
|
919
|
+
}
|
920
|
+
|
921
|
+
static VALUE rb_nodes_array_from_c_array(array_T* array) {
|
922
|
+
VALUE rb_array = rb_ary_new();
|
923
|
+
|
924
|
+
if (array) {
|
925
|
+
for (size_t i = 0; i < array_size(array); i++) {
|
926
|
+
AST_NODE_T* child_node = (AST_NODE_T*) array_get(array, i);
|
927
|
+
|
928
|
+
if (child_node) {
|
929
|
+
VALUE rb_child = rb_node_from_c_struct(child_node);
|
930
|
+
rb_ary_push(rb_array, rb_child);
|
931
|
+
}
|
932
|
+
}
|
933
|
+
}
|
934
|
+
|
935
|
+
return rb_array;
|
936
|
+
}
|