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
@@ -0,0 +1,1542 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# NOTE: This file is generated by the templates/template.rb script and should not be
|
4
|
+
# modified manually. See /Users/marcoroth/Development/herb-release/templates/lib/herb/ast/nodes.rb.erb
|
5
|
+
|
6
|
+
module Herb
|
7
|
+
module AST
|
8
|
+
class DocumentNode < Node
|
9
|
+
attr_reader :children
|
10
|
+
|
11
|
+
def initialize(type, location, errors, children)
|
12
|
+
super(type, location, errors)
|
13
|
+
@children = children
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_hash
|
17
|
+
super.merge({
|
18
|
+
children: children,
|
19
|
+
})
|
20
|
+
end
|
21
|
+
|
22
|
+
def inspect
|
23
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
24
|
+
end
|
25
|
+
|
26
|
+
def tree_inspect(indent = 0)
|
27
|
+
output = +""
|
28
|
+
|
29
|
+
output += "@ #{node_name} "
|
30
|
+
output += location.tree_inspect
|
31
|
+
output += "\n"
|
32
|
+
|
33
|
+
output += inspect_errors(prefix: "│ ")
|
34
|
+
|
35
|
+
output += "└── children: "
|
36
|
+
output += inspect_array(children, prefix: " ")
|
37
|
+
output += "\n"
|
38
|
+
|
39
|
+
output.gsub(/^/, " " * indent)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class LiteralNode < Node
|
44
|
+
attr_reader :content
|
45
|
+
|
46
|
+
def initialize(type, location, errors, content)
|
47
|
+
super(type, location, errors)
|
48
|
+
@content = content.force_encoding("utf-8")
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_hash
|
52
|
+
super.merge({
|
53
|
+
content: content,
|
54
|
+
})
|
55
|
+
end
|
56
|
+
|
57
|
+
def inspect
|
58
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
59
|
+
end
|
60
|
+
|
61
|
+
def tree_inspect(indent = 0)
|
62
|
+
output = +""
|
63
|
+
|
64
|
+
output += "@ #{node_name} "
|
65
|
+
output += location.tree_inspect
|
66
|
+
output += "\n"
|
67
|
+
|
68
|
+
output += inspect_errors(prefix: "│ ")
|
69
|
+
|
70
|
+
output += %(└── content: #{content.inspect}\n)
|
71
|
+
output += "\n"
|
72
|
+
|
73
|
+
output.gsub(/^/, " " * indent)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class HTMLOpenTagNode < Node
|
78
|
+
attr_reader :tag_opening
|
79
|
+
attr_reader :tag_name
|
80
|
+
attr_reader :tag_closing
|
81
|
+
attr_reader :children
|
82
|
+
attr_reader :is_void
|
83
|
+
|
84
|
+
def initialize(type, location, errors, tag_opening, tag_name, tag_closing, children, is_void)
|
85
|
+
super(type, location, errors)
|
86
|
+
@tag_opening = tag_opening
|
87
|
+
@tag_name = tag_name
|
88
|
+
@tag_closing = tag_closing
|
89
|
+
@children = children
|
90
|
+
@is_void = is_void
|
91
|
+
end
|
92
|
+
|
93
|
+
def to_hash
|
94
|
+
super.merge({
|
95
|
+
tag_opening: tag_opening,
|
96
|
+
tag_name: tag_name,
|
97
|
+
tag_closing: tag_closing,
|
98
|
+
children: children,
|
99
|
+
is_void: is_void,
|
100
|
+
})
|
101
|
+
end
|
102
|
+
|
103
|
+
def inspect
|
104
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
105
|
+
end
|
106
|
+
|
107
|
+
def tree_inspect(indent = 0)
|
108
|
+
output = +""
|
109
|
+
|
110
|
+
output += "@ #{node_name} "
|
111
|
+
output += location.tree_inspect
|
112
|
+
output += "\n"
|
113
|
+
|
114
|
+
output += inspect_errors(prefix: "│ ")
|
115
|
+
|
116
|
+
output += "├── tag_opening: "
|
117
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
118
|
+
output += "\n"
|
119
|
+
output += "├── tag_name: "
|
120
|
+
output += tag_name ? tag_name.tree_inspect : "∅"
|
121
|
+
output += "\n"
|
122
|
+
output += "├── tag_closing: "
|
123
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
124
|
+
output += "\n"
|
125
|
+
output += "├── children: "
|
126
|
+
output += inspect_array(children, prefix: "│ ")
|
127
|
+
output += "└── is_void: "
|
128
|
+
output += [true, false].include?(is_void) ? is_void.to_s : "∅"
|
129
|
+
output += "\n"
|
130
|
+
output += "\n"
|
131
|
+
|
132
|
+
output.gsub(/^/, " " * indent)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
class HTMLCloseTagNode < Node
|
137
|
+
attr_reader :tag_opening
|
138
|
+
attr_reader :tag_name
|
139
|
+
attr_reader :tag_closing
|
140
|
+
|
141
|
+
def initialize(type, location, errors, tag_opening, tag_name, tag_closing)
|
142
|
+
super(type, location, errors)
|
143
|
+
@tag_opening = tag_opening
|
144
|
+
@tag_name = tag_name
|
145
|
+
@tag_closing = tag_closing
|
146
|
+
end
|
147
|
+
|
148
|
+
def to_hash
|
149
|
+
super.merge({
|
150
|
+
tag_opening: tag_opening,
|
151
|
+
tag_name: tag_name,
|
152
|
+
tag_closing: tag_closing,
|
153
|
+
})
|
154
|
+
end
|
155
|
+
|
156
|
+
def inspect
|
157
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
158
|
+
end
|
159
|
+
|
160
|
+
def tree_inspect(indent = 0)
|
161
|
+
output = +""
|
162
|
+
|
163
|
+
output += "@ #{node_name} "
|
164
|
+
output += location.tree_inspect
|
165
|
+
output += "\n"
|
166
|
+
|
167
|
+
output += inspect_errors(prefix: "│ ")
|
168
|
+
|
169
|
+
output += "├── tag_opening: "
|
170
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
171
|
+
output += "\n"
|
172
|
+
output += "├── tag_name: "
|
173
|
+
output += tag_name ? tag_name.tree_inspect : "∅"
|
174
|
+
output += "\n"
|
175
|
+
output += "└── tag_closing: "
|
176
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
177
|
+
output += "\n"
|
178
|
+
output += "\n"
|
179
|
+
|
180
|
+
output.gsub(/^/, " " * indent)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
class HTMLSelfCloseTagNode < Node
|
185
|
+
attr_reader :tag_opening
|
186
|
+
attr_reader :tag_name
|
187
|
+
attr_reader :attributes
|
188
|
+
attr_reader :tag_closing
|
189
|
+
attr_reader :is_void
|
190
|
+
|
191
|
+
def initialize(type, location, errors, tag_opening, tag_name, attributes, tag_closing, is_void)
|
192
|
+
super(type, location, errors)
|
193
|
+
@tag_opening = tag_opening
|
194
|
+
@tag_name = tag_name
|
195
|
+
@attributes = attributes
|
196
|
+
@tag_closing = tag_closing
|
197
|
+
@is_void = is_void
|
198
|
+
end
|
199
|
+
|
200
|
+
def to_hash
|
201
|
+
super.merge({
|
202
|
+
tag_opening: tag_opening,
|
203
|
+
tag_name: tag_name,
|
204
|
+
attributes: attributes,
|
205
|
+
tag_closing: tag_closing,
|
206
|
+
is_void: is_void,
|
207
|
+
})
|
208
|
+
end
|
209
|
+
|
210
|
+
def inspect
|
211
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
212
|
+
end
|
213
|
+
|
214
|
+
def tree_inspect(indent = 0)
|
215
|
+
output = +""
|
216
|
+
|
217
|
+
output += "@ #{node_name} "
|
218
|
+
output += location.tree_inspect
|
219
|
+
output += "\n"
|
220
|
+
|
221
|
+
output += inspect_errors(prefix: "│ ")
|
222
|
+
|
223
|
+
output += "├── tag_opening: "
|
224
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
225
|
+
output += "\n"
|
226
|
+
output += "├── tag_name: "
|
227
|
+
output += tag_name ? tag_name.tree_inspect : "∅"
|
228
|
+
output += "\n"
|
229
|
+
output += "├── attributes: "
|
230
|
+
output += inspect_array(attributes, prefix: "│ ")
|
231
|
+
output += "├── tag_closing: "
|
232
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
233
|
+
output += "\n"
|
234
|
+
output += "└── is_void: "
|
235
|
+
output += [true, false].include?(is_void) ? is_void.to_s : "∅"
|
236
|
+
output += "\n"
|
237
|
+
output += "\n"
|
238
|
+
|
239
|
+
output.gsub(/^/, " " * indent)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
class HTMLElementNode < Node
|
244
|
+
attr_reader :open_tag
|
245
|
+
attr_reader :tag_name
|
246
|
+
attr_reader :body
|
247
|
+
attr_reader :close_tag
|
248
|
+
attr_reader :is_void
|
249
|
+
|
250
|
+
def initialize(type, location, errors, open_tag, tag_name, body, close_tag, is_void)
|
251
|
+
super(type, location, errors)
|
252
|
+
@open_tag = open_tag
|
253
|
+
@tag_name = tag_name
|
254
|
+
@body = body
|
255
|
+
@close_tag = close_tag
|
256
|
+
@is_void = is_void
|
257
|
+
end
|
258
|
+
|
259
|
+
def to_hash
|
260
|
+
super.merge({
|
261
|
+
open_tag: open_tag,
|
262
|
+
tag_name: tag_name,
|
263
|
+
body: body,
|
264
|
+
close_tag: close_tag,
|
265
|
+
is_void: is_void,
|
266
|
+
})
|
267
|
+
end
|
268
|
+
|
269
|
+
def inspect
|
270
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
271
|
+
end
|
272
|
+
|
273
|
+
def tree_inspect(indent = 0)
|
274
|
+
output = +""
|
275
|
+
|
276
|
+
output += "@ #{node_name} "
|
277
|
+
output += location.tree_inspect
|
278
|
+
output += "\n"
|
279
|
+
|
280
|
+
output += inspect_errors(prefix: "│ ")
|
281
|
+
|
282
|
+
output += "├── open_tag: "
|
283
|
+
if open_tag
|
284
|
+
output += "\n"
|
285
|
+
output += "│ └── "
|
286
|
+
output += open_tag.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, "│ ").delete_prefix("│ ")
|
287
|
+
else
|
288
|
+
output += "∅\n"
|
289
|
+
end
|
290
|
+
output += "├── tag_name: "
|
291
|
+
output += tag_name ? tag_name.tree_inspect : "∅"
|
292
|
+
output += "\n"
|
293
|
+
output += "├── body: "
|
294
|
+
output += inspect_array(body, prefix: "│ ")
|
295
|
+
output += "├── close_tag: "
|
296
|
+
if close_tag
|
297
|
+
output += "\n"
|
298
|
+
output += "│ └── "
|
299
|
+
output += close_tag.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, "│ ").delete_prefix("│ ")
|
300
|
+
else
|
301
|
+
output += "∅\n"
|
302
|
+
end
|
303
|
+
output += "└── is_void: "
|
304
|
+
output += [true, false].include?(is_void) ? is_void.to_s : "∅"
|
305
|
+
output += "\n"
|
306
|
+
output += "\n"
|
307
|
+
|
308
|
+
output.gsub(/^/, " " * indent)
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
class HTMLAttributeValueNode < Node
|
313
|
+
attr_reader :open_quote
|
314
|
+
attr_reader :children
|
315
|
+
attr_reader :close_quote
|
316
|
+
attr_reader :quoted
|
317
|
+
|
318
|
+
def initialize(type, location, errors, open_quote, children, close_quote, quoted)
|
319
|
+
super(type, location, errors)
|
320
|
+
@open_quote = open_quote
|
321
|
+
@children = children
|
322
|
+
@close_quote = close_quote
|
323
|
+
@quoted = quoted
|
324
|
+
end
|
325
|
+
|
326
|
+
def to_hash
|
327
|
+
super.merge({
|
328
|
+
open_quote: open_quote,
|
329
|
+
children: children,
|
330
|
+
close_quote: close_quote,
|
331
|
+
quoted: quoted,
|
332
|
+
})
|
333
|
+
end
|
334
|
+
|
335
|
+
def inspect
|
336
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
337
|
+
end
|
338
|
+
|
339
|
+
def tree_inspect(indent = 0)
|
340
|
+
output = +""
|
341
|
+
|
342
|
+
output += "@ #{node_name} "
|
343
|
+
output += location.tree_inspect
|
344
|
+
output += "\n"
|
345
|
+
|
346
|
+
output += inspect_errors(prefix: "│ ")
|
347
|
+
|
348
|
+
output += "├── open_quote: "
|
349
|
+
output += open_quote ? open_quote.tree_inspect : "∅"
|
350
|
+
output += "\n"
|
351
|
+
output += "├── children: "
|
352
|
+
output += inspect_array(children, prefix: "│ ")
|
353
|
+
output += "├── close_quote: "
|
354
|
+
output += close_quote ? close_quote.tree_inspect : "∅"
|
355
|
+
output += "\n"
|
356
|
+
output += "└── quoted: "
|
357
|
+
output += [true, false].include?(quoted) ? quoted.to_s : "∅"
|
358
|
+
output += "\n"
|
359
|
+
output += "\n"
|
360
|
+
|
361
|
+
output.gsub(/^/, " " * indent)
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
class HTMLAttributeNameNode < Node
|
366
|
+
attr_reader :name
|
367
|
+
|
368
|
+
def initialize(type, location, errors, name)
|
369
|
+
super(type, location, errors)
|
370
|
+
@name = name
|
371
|
+
end
|
372
|
+
|
373
|
+
def to_hash
|
374
|
+
super.merge({
|
375
|
+
name: name,
|
376
|
+
})
|
377
|
+
end
|
378
|
+
|
379
|
+
def inspect
|
380
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
381
|
+
end
|
382
|
+
|
383
|
+
def tree_inspect(indent = 0)
|
384
|
+
output = +""
|
385
|
+
|
386
|
+
output += "@ #{node_name} "
|
387
|
+
output += location.tree_inspect
|
388
|
+
output += "\n"
|
389
|
+
|
390
|
+
output += inspect_errors(prefix: "│ ")
|
391
|
+
|
392
|
+
output += "└── name: "
|
393
|
+
output += name ? name.tree_inspect : "∅"
|
394
|
+
output += "\n"
|
395
|
+
output += "\n"
|
396
|
+
|
397
|
+
output.gsub(/^/, " " * indent)
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
class HTMLAttributeNode < Node
|
402
|
+
attr_reader :name
|
403
|
+
attr_reader :equals
|
404
|
+
attr_reader :value
|
405
|
+
|
406
|
+
def initialize(type, location, errors, name, equals, value)
|
407
|
+
super(type, location, errors)
|
408
|
+
@name = name
|
409
|
+
@equals = equals
|
410
|
+
@value = value
|
411
|
+
end
|
412
|
+
|
413
|
+
def to_hash
|
414
|
+
super.merge({
|
415
|
+
name: name,
|
416
|
+
equals: equals,
|
417
|
+
value: value,
|
418
|
+
})
|
419
|
+
end
|
420
|
+
|
421
|
+
def inspect
|
422
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
423
|
+
end
|
424
|
+
|
425
|
+
def tree_inspect(indent = 0)
|
426
|
+
output = +""
|
427
|
+
|
428
|
+
output += "@ #{node_name} "
|
429
|
+
output += location.tree_inspect
|
430
|
+
output += "\n"
|
431
|
+
|
432
|
+
output += inspect_errors(prefix: "│ ")
|
433
|
+
|
434
|
+
output += "├── name: "
|
435
|
+
if name
|
436
|
+
output += "\n"
|
437
|
+
output += "│ └── "
|
438
|
+
output += name.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, "│ ").delete_prefix("│ ")
|
439
|
+
else
|
440
|
+
output += "∅\n"
|
441
|
+
end
|
442
|
+
output += "├── equals: "
|
443
|
+
output += equals ? equals.tree_inspect : "∅"
|
444
|
+
output += "\n"
|
445
|
+
output += "└── value: "
|
446
|
+
if value
|
447
|
+
output += "\n"
|
448
|
+
output += " └── "
|
449
|
+
output += value.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, " ").delete_prefix(" ")
|
450
|
+
else
|
451
|
+
output += "∅\n"
|
452
|
+
end
|
453
|
+
output += "\n"
|
454
|
+
|
455
|
+
output.gsub(/^/, " " * indent)
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
class HTMLTextNode < Node
|
460
|
+
attr_reader :content
|
461
|
+
|
462
|
+
def initialize(type, location, errors, content)
|
463
|
+
super(type, location, errors)
|
464
|
+
@content = content.force_encoding("utf-8")
|
465
|
+
end
|
466
|
+
|
467
|
+
def to_hash
|
468
|
+
super.merge({
|
469
|
+
content: content,
|
470
|
+
})
|
471
|
+
end
|
472
|
+
|
473
|
+
def inspect
|
474
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
475
|
+
end
|
476
|
+
|
477
|
+
def tree_inspect(indent = 0)
|
478
|
+
output = +""
|
479
|
+
|
480
|
+
output += "@ #{node_name} "
|
481
|
+
output += location.tree_inspect
|
482
|
+
output += "\n"
|
483
|
+
|
484
|
+
output += inspect_errors(prefix: "│ ")
|
485
|
+
|
486
|
+
output += %(└── content: #{content.inspect}\n)
|
487
|
+
output += "\n"
|
488
|
+
|
489
|
+
output.gsub(/^/, " " * indent)
|
490
|
+
end
|
491
|
+
end
|
492
|
+
|
493
|
+
class HTMLCommentNode < Node
|
494
|
+
attr_reader :comment_start
|
495
|
+
attr_reader :children
|
496
|
+
attr_reader :comment_end
|
497
|
+
|
498
|
+
def initialize(type, location, errors, comment_start, children, comment_end)
|
499
|
+
super(type, location, errors)
|
500
|
+
@comment_start = comment_start
|
501
|
+
@children = children
|
502
|
+
@comment_end = comment_end
|
503
|
+
end
|
504
|
+
|
505
|
+
def to_hash
|
506
|
+
super.merge({
|
507
|
+
comment_start: comment_start,
|
508
|
+
children: children,
|
509
|
+
comment_end: comment_end,
|
510
|
+
})
|
511
|
+
end
|
512
|
+
|
513
|
+
def inspect
|
514
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
515
|
+
end
|
516
|
+
|
517
|
+
def tree_inspect(indent = 0)
|
518
|
+
output = +""
|
519
|
+
|
520
|
+
output += "@ #{node_name} "
|
521
|
+
output += location.tree_inspect
|
522
|
+
output += "\n"
|
523
|
+
|
524
|
+
output += inspect_errors(prefix: "│ ")
|
525
|
+
|
526
|
+
output += "├── comment_start: "
|
527
|
+
output += comment_start ? comment_start.tree_inspect : "∅"
|
528
|
+
output += "\n"
|
529
|
+
output += "├── children: "
|
530
|
+
output += inspect_array(children, prefix: "│ ")
|
531
|
+
output += "└── comment_end: "
|
532
|
+
output += comment_end ? comment_end.tree_inspect : "∅"
|
533
|
+
output += "\n"
|
534
|
+
output += "\n"
|
535
|
+
|
536
|
+
output.gsub(/^/, " " * indent)
|
537
|
+
end
|
538
|
+
end
|
539
|
+
|
540
|
+
class HTMLDoctypeNode < Node
|
541
|
+
attr_reader :tag_opening
|
542
|
+
attr_reader :children
|
543
|
+
attr_reader :tag_closing
|
544
|
+
|
545
|
+
def initialize(type, location, errors, tag_opening, children, tag_closing)
|
546
|
+
super(type, location, errors)
|
547
|
+
@tag_opening = tag_opening
|
548
|
+
@children = children
|
549
|
+
@tag_closing = tag_closing
|
550
|
+
end
|
551
|
+
|
552
|
+
def to_hash
|
553
|
+
super.merge({
|
554
|
+
tag_opening: tag_opening,
|
555
|
+
children: children,
|
556
|
+
tag_closing: tag_closing,
|
557
|
+
})
|
558
|
+
end
|
559
|
+
|
560
|
+
def inspect
|
561
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
562
|
+
end
|
563
|
+
|
564
|
+
def tree_inspect(indent = 0)
|
565
|
+
output = +""
|
566
|
+
|
567
|
+
output += "@ #{node_name} "
|
568
|
+
output += location.tree_inspect
|
569
|
+
output += "\n"
|
570
|
+
|
571
|
+
output += inspect_errors(prefix: "│ ")
|
572
|
+
|
573
|
+
output += "├── tag_opening: "
|
574
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
575
|
+
output += "\n"
|
576
|
+
output += "├── children: "
|
577
|
+
output += inspect_array(children, prefix: "│ ")
|
578
|
+
output += "└── tag_closing: "
|
579
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
580
|
+
output += "\n"
|
581
|
+
output += "\n"
|
582
|
+
|
583
|
+
output.gsub(/^/, " " * indent)
|
584
|
+
end
|
585
|
+
end
|
586
|
+
|
587
|
+
class WhitespaceNode < Node
|
588
|
+
attr_reader :value
|
589
|
+
|
590
|
+
def initialize(type, location, errors, value)
|
591
|
+
super(type, location, errors)
|
592
|
+
@value = value
|
593
|
+
end
|
594
|
+
|
595
|
+
def to_hash
|
596
|
+
super.merge({
|
597
|
+
value: value,
|
598
|
+
})
|
599
|
+
end
|
600
|
+
|
601
|
+
def inspect
|
602
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
603
|
+
end
|
604
|
+
|
605
|
+
def tree_inspect(indent = 0)
|
606
|
+
output = +""
|
607
|
+
|
608
|
+
output += "@ #{node_name} "
|
609
|
+
output += location.tree_inspect
|
610
|
+
output += "\n"
|
611
|
+
|
612
|
+
output += inspect_errors(prefix: "│ ")
|
613
|
+
|
614
|
+
output += "└── value: "
|
615
|
+
output += value ? value.tree_inspect : "∅"
|
616
|
+
output += "\n"
|
617
|
+
output += "\n"
|
618
|
+
|
619
|
+
output.gsub(/^/, " " * indent)
|
620
|
+
end
|
621
|
+
end
|
622
|
+
|
623
|
+
class ERBContentNode < Node
|
624
|
+
attr_reader :tag_opening
|
625
|
+
attr_reader :content
|
626
|
+
attr_reader :tag_closing
|
627
|
+
attr_reader :analyzed_ruby
|
628
|
+
attr_reader :parsed
|
629
|
+
attr_reader :valid
|
630
|
+
|
631
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, analyzed_ruby, parsed, valid)
|
632
|
+
super(type, location, errors)
|
633
|
+
@tag_opening = tag_opening
|
634
|
+
@content = content
|
635
|
+
@tag_closing = tag_closing
|
636
|
+
@analyzed_ruby = analyzed_ruby
|
637
|
+
@parsed = parsed
|
638
|
+
@valid = valid
|
639
|
+
end
|
640
|
+
|
641
|
+
def to_hash
|
642
|
+
super.merge({
|
643
|
+
tag_opening: tag_opening,
|
644
|
+
content: content,
|
645
|
+
tag_closing: tag_closing,
|
646
|
+
analyzed_ruby: analyzed_ruby,
|
647
|
+
parsed: parsed,
|
648
|
+
valid: valid,
|
649
|
+
})
|
650
|
+
end
|
651
|
+
|
652
|
+
def inspect
|
653
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
654
|
+
end
|
655
|
+
|
656
|
+
def tree_inspect(indent = 0)
|
657
|
+
output = +""
|
658
|
+
|
659
|
+
output += "@ #{node_name} "
|
660
|
+
output += location.tree_inspect
|
661
|
+
output += "\n"
|
662
|
+
|
663
|
+
output += inspect_errors(prefix: "│ ")
|
664
|
+
|
665
|
+
output += "├── tag_opening: "
|
666
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
667
|
+
output += "\n"
|
668
|
+
output += "├── content: "
|
669
|
+
output += content ? content.tree_inspect : "∅"
|
670
|
+
output += "\n"
|
671
|
+
output += "├── tag_closing: "
|
672
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
673
|
+
output += "\n"
|
674
|
+
# no-op for analyzed_ruby
|
675
|
+
output += "├── parsed: "
|
676
|
+
output += [true, false].include?(parsed) ? parsed.to_s : "∅"
|
677
|
+
output += "\n"
|
678
|
+
output += "└── valid: "
|
679
|
+
output += [true, false].include?(valid) ? valid.to_s : "∅"
|
680
|
+
output += "\n"
|
681
|
+
output += "\n"
|
682
|
+
|
683
|
+
output.gsub(/^/, " " * indent)
|
684
|
+
end
|
685
|
+
end
|
686
|
+
|
687
|
+
class ERBEndNode < Node
|
688
|
+
attr_reader :tag_opening
|
689
|
+
attr_reader :content
|
690
|
+
attr_reader :tag_closing
|
691
|
+
|
692
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing)
|
693
|
+
super(type, location, errors)
|
694
|
+
@tag_opening = tag_opening
|
695
|
+
@content = content
|
696
|
+
@tag_closing = tag_closing
|
697
|
+
end
|
698
|
+
|
699
|
+
def to_hash
|
700
|
+
super.merge({
|
701
|
+
tag_opening: tag_opening,
|
702
|
+
content: content,
|
703
|
+
tag_closing: tag_closing,
|
704
|
+
})
|
705
|
+
end
|
706
|
+
|
707
|
+
def inspect
|
708
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
709
|
+
end
|
710
|
+
|
711
|
+
def tree_inspect(indent = 0)
|
712
|
+
output = +""
|
713
|
+
|
714
|
+
output += "@ #{node_name} "
|
715
|
+
output += location.tree_inspect
|
716
|
+
output += "\n"
|
717
|
+
|
718
|
+
output += inspect_errors(prefix: "│ ")
|
719
|
+
|
720
|
+
output += "├── tag_opening: "
|
721
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
722
|
+
output += "\n"
|
723
|
+
output += "├── content: "
|
724
|
+
output += content ? content.tree_inspect : "∅"
|
725
|
+
output += "\n"
|
726
|
+
output += "└── tag_closing: "
|
727
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
728
|
+
output += "\n"
|
729
|
+
output += "\n"
|
730
|
+
|
731
|
+
output.gsub(/^/, " " * indent)
|
732
|
+
end
|
733
|
+
end
|
734
|
+
|
735
|
+
class ERBElseNode < Node
|
736
|
+
attr_reader :tag_opening
|
737
|
+
attr_reader :content
|
738
|
+
attr_reader :tag_closing
|
739
|
+
attr_reader :statements
|
740
|
+
|
741
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, statements)
|
742
|
+
super(type, location, errors)
|
743
|
+
@tag_opening = tag_opening
|
744
|
+
@content = content
|
745
|
+
@tag_closing = tag_closing
|
746
|
+
@statements = statements
|
747
|
+
end
|
748
|
+
|
749
|
+
def to_hash
|
750
|
+
super.merge({
|
751
|
+
tag_opening: tag_opening,
|
752
|
+
content: content,
|
753
|
+
tag_closing: tag_closing,
|
754
|
+
statements: statements,
|
755
|
+
})
|
756
|
+
end
|
757
|
+
|
758
|
+
def inspect
|
759
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
760
|
+
end
|
761
|
+
|
762
|
+
def tree_inspect(indent = 0)
|
763
|
+
output = +""
|
764
|
+
|
765
|
+
output += "@ #{node_name} "
|
766
|
+
output += location.tree_inspect
|
767
|
+
output += "\n"
|
768
|
+
|
769
|
+
output += inspect_errors(prefix: "│ ")
|
770
|
+
|
771
|
+
output += "├── tag_opening: "
|
772
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
773
|
+
output += "\n"
|
774
|
+
output += "├── content: "
|
775
|
+
output += content ? content.tree_inspect : "∅"
|
776
|
+
output += "\n"
|
777
|
+
output += "├── tag_closing: "
|
778
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
779
|
+
output += "\n"
|
780
|
+
output += "└── statements: "
|
781
|
+
output += inspect_array(statements, prefix: " ")
|
782
|
+
output += "\n"
|
783
|
+
|
784
|
+
output.gsub(/^/, " " * indent)
|
785
|
+
end
|
786
|
+
end
|
787
|
+
|
788
|
+
class ERBIfNode < Node
|
789
|
+
attr_reader :tag_opening
|
790
|
+
attr_reader :content
|
791
|
+
attr_reader :tag_closing
|
792
|
+
attr_reader :statements
|
793
|
+
attr_reader :subsequent
|
794
|
+
attr_reader :end_node
|
795
|
+
|
796
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, statements, subsequent, end_node)
|
797
|
+
super(type, location, errors)
|
798
|
+
@tag_opening = tag_opening
|
799
|
+
@content = content
|
800
|
+
@tag_closing = tag_closing
|
801
|
+
@statements = statements
|
802
|
+
@subsequent = subsequent
|
803
|
+
@end_node = end_node
|
804
|
+
end
|
805
|
+
|
806
|
+
def to_hash
|
807
|
+
super.merge({
|
808
|
+
tag_opening: tag_opening,
|
809
|
+
content: content,
|
810
|
+
tag_closing: tag_closing,
|
811
|
+
statements: statements,
|
812
|
+
subsequent: subsequent,
|
813
|
+
end_node: end_node,
|
814
|
+
})
|
815
|
+
end
|
816
|
+
|
817
|
+
def inspect
|
818
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
819
|
+
end
|
820
|
+
|
821
|
+
def tree_inspect(indent = 0)
|
822
|
+
output = +""
|
823
|
+
|
824
|
+
output += "@ #{node_name} "
|
825
|
+
output += location.tree_inspect
|
826
|
+
output += "\n"
|
827
|
+
|
828
|
+
output += inspect_errors(prefix: "│ ")
|
829
|
+
|
830
|
+
output += "├── tag_opening: "
|
831
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
832
|
+
output += "\n"
|
833
|
+
output += "├── content: "
|
834
|
+
output += content ? content.tree_inspect : "∅"
|
835
|
+
output += "\n"
|
836
|
+
output += "├── tag_closing: "
|
837
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
838
|
+
output += "\n"
|
839
|
+
output += "├── statements: "
|
840
|
+
output += inspect_array(statements, prefix: "│ ")
|
841
|
+
output += "├── subsequent: "
|
842
|
+
if subsequent
|
843
|
+
output += "\n"
|
844
|
+
output += "│ └── "
|
845
|
+
output += subsequent.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, "│ ").delete_prefix("│ ")
|
846
|
+
else
|
847
|
+
output += "∅\n"
|
848
|
+
end
|
849
|
+
output += "└── end_node: "
|
850
|
+
if end_node
|
851
|
+
output += "\n"
|
852
|
+
output += " └── "
|
853
|
+
output += end_node.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, " ").delete_prefix(" ")
|
854
|
+
else
|
855
|
+
output += "∅\n"
|
856
|
+
end
|
857
|
+
output += "\n"
|
858
|
+
|
859
|
+
output.gsub(/^/, " " * indent)
|
860
|
+
end
|
861
|
+
end
|
862
|
+
|
863
|
+
class ERBBlockNode < Node
|
864
|
+
attr_reader :tag_opening
|
865
|
+
attr_reader :content
|
866
|
+
attr_reader :tag_closing
|
867
|
+
attr_reader :body
|
868
|
+
attr_reader :end_node
|
869
|
+
|
870
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, body, end_node)
|
871
|
+
super(type, location, errors)
|
872
|
+
@tag_opening = tag_opening
|
873
|
+
@content = content
|
874
|
+
@tag_closing = tag_closing
|
875
|
+
@body = body
|
876
|
+
@end_node = end_node
|
877
|
+
end
|
878
|
+
|
879
|
+
def to_hash
|
880
|
+
super.merge({
|
881
|
+
tag_opening: tag_opening,
|
882
|
+
content: content,
|
883
|
+
tag_closing: tag_closing,
|
884
|
+
body: body,
|
885
|
+
end_node: end_node,
|
886
|
+
})
|
887
|
+
end
|
888
|
+
|
889
|
+
def inspect
|
890
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
891
|
+
end
|
892
|
+
|
893
|
+
def tree_inspect(indent = 0)
|
894
|
+
output = +""
|
895
|
+
|
896
|
+
output += "@ #{node_name} "
|
897
|
+
output += location.tree_inspect
|
898
|
+
output += "\n"
|
899
|
+
|
900
|
+
output += inspect_errors(prefix: "│ ")
|
901
|
+
|
902
|
+
output += "├── tag_opening: "
|
903
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
904
|
+
output += "\n"
|
905
|
+
output += "├── content: "
|
906
|
+
output += content ? content.tree_inspect : "∅"
|
907
|
+
output += "\n"
|
908
|
+
output += "├── tag_closing: "
|
909
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
910
|
+
output += "\n"
|
911
|
+
output += "├── body: "
|
912
|
+
output += inspect_array(body, prefix: "│ ")
|
913
|
+
output += "└── end_node: "
|
914
|
+
if end_node
|
915
|
+
output += "\n"
|
916
|
+
output += " └── "
|
917
|
+
output += end_node.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, " ").delete_prefix(" ")
|
918
|
+
else
|
919
|
+
output += "∅\n"
|
920
|
+
end
|
921
|
+
output += "\n"
|
922
|
+
|
923
|
+
output.gsub(/^/, " " * indent)
|
924
|
+
end
|
925
|
+
end
|
926
|
+
|
927
|
+
class ERBWhenNode < Node
|
928
|
+
attr_reader :tag_opening
|
929
|
+
attr_reader :content
|
930
|
+
attr_reader :tag_closing
|
931
|
+
attr_reader :statements
|
932
|
+
|
933
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, statements)
|
934
|
+
super(type, location, errors)
|
935
|
+
@tag_opening = tag_opening
|
936
|
+
@content = content
|
937
|
+
@tag_closing = tag_closing
|
938
|
+
@statements = statements
|
939
|
+
end
|
940
|
+
|
941
|
+
def to_hash
|
942
|
+
super.merge({
|
943
|
+
tag_opening: tag_opening,
|
944
|
+
content: content,
|
945
|
+
tag_closing: tag_closing,
|
946
|
+
statements: statements,
|
947
|
+
})
|
948
|
+
end
|
949
|
+
|
950
|
+
def inspect
|
951
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
952
|
+
end
|
953
|
+
|
954
|
+
def tree_inspect(indent = 0)
|
955
|
+
output = +""
|
956
|
+
|
957
|
+
output += "@ #{node_name} "
|
958
|
+
output += location.tree_inspect
|
959
|
+
output += "\n"
|
960
|
+
|
961
|
+
output += inspect_errors(prefix: "│ ")
|
962
|
+
|
963
|
+
output += "├── tag_opening: "
|
964
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
965
|
+
output += "\n"
|
966
|
+
output += "├── content: "
|
967
|
+
output += content ? content.tree_inspect : "∅"
|
968
|
+
output += "\n"
|
969
|
+
output += "├── tag_closing: "
|
970
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
971
|
+
output += "\n"
|
972
|
+
output += "└── statements: "
|
973
|
+
output += inspect_array(statements, prefix: " ")
|
974
|
+
output += "\n"
|
975
|
+
|
976
|
+
output.gsub(/^/, " " * indent)
|
977
|
+
end
|
978
|
+
end
|
979
|
+
|
980
|
+
class ERBCaseNode < Node
|
981
|
+
attr_reader :tag_opening
|
982
|
+
attr_reader :content
|
983
|
+
attr_reader :tag_closing
|
984
|
+
attr_reader :children
|
985
|
+
attr_reader :conditions
|
986
|
+
attr_reader :else_clause
|
987
|
+
attr_reader :end_node
|
988
|
+
|
989
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, children, conditions, else_clause, end_node)
|
990
|
+
super(type, location, errors)
|
991
|
+
@tag_opening = tag_opening
|
992
|
+
@content = content
|
993
|
+
@tag_closing = tag_closing
|
994
|
+
@children = children
|
995
|
+
@conditions = conditions
|
996
|
+
@else_clause = else_clause
|
997
|
+
@end_node = end_node
|
998
|
+
end
|
999
|
+
|
1000
|
+
def to_hash
|
1001
|
+
super.merge({
|
1002
|
+
tag_opening: tag_opening,
|
1003
|
+
content: content,
|
1004
|
+
tag_closing: tag_closing,
|
1005
|
+
children: children,
|
1006
|
+
conditions: conditions,
|
1007
|
+
else_clause: else_clause,
|
1008
|
+
end_node: end_node,
|
1009
|
+
})
|
1010
|
+
end
|
1011
|
+
|
1012
|
+
def inspect
|
1013
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
1014
|
+
end
|
1015
|
+
|
1016
|
+
def tree_inspect(indent = 0)
|
1017
|
+
output = +""
|
1018
|
+
|
1019
|
+
output += "@ #{node_name} "
|
1020
|
+
output += location.tree_inspect
|
1021
|
+
output += "\n"
|
1022
|
+
|
1023
|
+
output += inspect_errors(prefix: "│ ")
|
1024
|
+
|
1025
|
+
output += "├── tag_opening: "
|
1026
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
1027
|
+
output += "\n"
|
1028
|
+
output += "├── content: "
|
1029
|
+
output += content ? content.tree_inspect : "∅"
|
1030
|
+
output += "\n"
|
1031
|
+
output += "├── tag_closing: "
|
1032
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
1033
|
+
output += "\n"
|
1034
|
+
output += "├── children: "
|
1035
|
+
output += inspect_array(children, prefix: "│ ")
|
1036
|
+
output += "├── conditions: "
|
1037
|
+
output += inspect_array(conditions, prefix: "│ ")
|
1038
|
+
output += "├── else_clause: "
|
1039
|
+
if else_clause
|
1040
|
+
output += "\n"
|
1041
|
+
output += "│ └── "
|
1042
|
+
output += else_clause.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, "│ ").delete_prefix("│ ")
|
1043
|
+
else
|
1044
|
+
output += "∅\n"
|
1045
|
+
end
|
1046
|
+
output += "└── end_node: "
|
1047
|
+
if end_node
|
1048
|
+
output += "\n"
|
1049
|
+
output += " └── "
|
1050
|
+
output += end_node.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, " ").delete_prefix(" ")
|
1051
|
+
else
|
1052
|
+
output += "∅\n"
|
1053
|
+
end
|
1054
|
+
output += "\n"
|
1055
|
+
|
1056
|
+
output.gsub(/^/, " " * indent)
|
1057
|
+
end
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
class ERBWhileNode < Node
|
1061
|
+
attr_reader :tag_opening
|
1062
|
+
attr_reader :content
|
1063
|
+
attr_reader :tag_closing
|
1064
|
+
attr_reader :statements
|
1065
|
+
attr_reader :end_node
|
1066
|
+
|
1067
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, statements, end_node)
|
1068
|
+
super(type, location, errors)
|
1069
|
+
@tag_opening = tag_opening
|
1070
|
+
@content = content
|
1071
|
+
@tag_closing = tag_closing
|
1072
|
+
@statements = statements
|
1073
|
+
@end_node = end_node
|
1074
|
+
end
|
1075
|
+
|
1076
|
+
def to_hash
|
1077
|
+
super.merge({
|
1078
|
+
tag_opening: tag_opening,
|
1079
|
+
content: content,
|
1080
|
+
tag_closing: tag_closing,
|
1081
|
+
statements: statements,
|
1082
|
+
end_node: end_node,
|
1083
|
+
})
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
def inspect
|
1087
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
def tree_inspect(indent = 0)
|
1091
|
+
output = +""
|
1092
|
+
|
1093
|
+
output += "@ #{node_name} "
|
1094
|
+
output += location.tree_inspect
|
1095
|
+
output += "\n"
|
1096
|
+
|
1097
|
+
output += inspect_errors(prefix: "│ ")
|
1098
|
+
|
1099
|
+
output += "├── tag_opening: "
|
1100
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
1101
|
+
output += "\n"
|
1102
|
+
output += "├── content: "
|
1103
|
+
output += content ? content.tree_inspect : "∅"
|
1104
|
+
output += "\n"
|
1105
|
+
output += "├── tag_closing: "
|
1106
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
1107
|
+
output += "\n"
|
1108
|
+
output += "├── statements: "
|
1109
|
+
output += inspect_array(statements, prefix: "│ ")
|
1110
|
+
output += "└── end_node: "
|
1111
|
+
if end_node
|
1112
|
+
output += "\n"
|
1113
|
+
output += " └── "
|
1114
|
+
output += end_node.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, " ").delete_prefix(" ")
|
1115
|
+
else
|
1116
|
+
output += "∅\n"
|
1117
|
+
end
|
1118
|
+
output += "\n"
|
1119
|
+
|
1120
|
+
output.gsub(/^/, " " * indent)
|
1121
|
+
end
|
1122
|
+
end
|
1123
|
+
|
1124
|
+
class ERBUntilNode < Node
|
1125
|
+
attr_reader :tag_opening
|
1126
|
+
attr_reader :content
|
1127
|
+
attr_reader :tag_closing
|
1128
|
+
attr_reader :statements
|
1129
|
+
attr_reader :end_node
|
1130
|
+
|
1131
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, statements, end_node)
|
1132
|
+
super(type, location, errors)
|
1133
|
+
@tag_opening = tag_opening
|
1134
|
+
@content = content
|
1135
|
+
@tag_closing = tag_closing
|
1136
|
+
@statements = statements
|
1137
|
+
@end_node = end_node
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
def to_hash
|
1141
|
+
super.merge({
|
1142
|
+
tag_opening: tag_opening,
|
1143
|
+
content: content,
|
1144
|
+
tag_closing: tag_closing,
|
1145
|
+
statements: statements,
|
1146
|
+
end_node: end_node,
|
1147
|
+
})
|
1148
|
+
end
|
1149
|
+
|
1150
|
+
def inspect
|
1151
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
1152
|
+
end
|
1153
|
+
|
1154
|
+
def tree_inspect(indent = 0)
|
1155
|
+
output = +""
|
1156
|
+
|
1157
|
+
output += "@ #{node_name} "
|
1158
|
+
output += location.tree_inspect
|
1159
|
+
output += "\n"
|
1160
|
+
|
1161
|
+
output += inspect_errors(prefix: "│ ")
|
1162
|
+
|
1163
|
+
output += "├── tag_opening: "
|
1164
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
1165
|
+
output += "\n"
|
1166
|
+
output += "├── content: "
|
1167
|
+
output += content ? content.tree_inspect : "∅"
|
1168
|
+
output += "\n"
|
1169
|
+
output += "├── tag_closing: "
|
1170
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
1171
|
+
output += "\n"
|
1172
|
+
output += "├── statements: "
|
1173
|
+
output += inspect_array(statements, prefix: "│ ")
|
1174
|
+
output += "└── end_node: "
|
1175
|
+
if end_node
|
1176
|
+
output += "\n"
|
1177
|
+
output += " └── "
|
1178
|
+
output += end_node.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, " ").delete_prefix(" ")
|
1179
|
+
else
|
1180
|
+
output += "∅\n"
|
1181
|
+
end
|
1182
|
+
output += "\n"
|
1183
|
+
|
1184
|
+
output.gsub(/^/, " " * indent)
|
1185
|
+
end
|
1186
|
+
end
|
1187
|
+
|
1188
|
+
class ERBForNode < Node
|
1189
|
+
attr_reader :tag_opening
|
1190
|
+
attr_reader :content
|
1191
|
+
attr_reader :tag_closing
|
1192
|
+
attr_reader :statements
|
1193
|
+
attr_reader :end_node
|
1194
|
+
|
1195
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, statements, end_node)
|
1196
|
+
super(type, location, errors)
|
1197
|
+
@tag_opening = tag_opening
|
1198
|
+
@content = content
|
1199
|
+
@tag_closing = tag_closing
|
1200
|
+
@statements = statements
|
1201
|
+
@end_node = end_node
|
1202
|
+
end
|
1203
|
+
|
1204
|
+
def to_hash
|
1205
|
+
super.merge({
|
1206
|
+
tag_opening: tag_opening,
|
1207
|
+
content: content,
|
1208
|
+
tag_closing: tag_closing,
|
1209
|
+
statements: statements,
|
1210
|
+
end_node: end_node,
|
1211
|
+
})
|
1212
|
+
end
|
1213
|
+
|
1214
|
+
def inspect
|
1215
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
1216
|
+
end
|
1217
|
+
|
1218
|
+
def tree_inspect(indent = 0)
|
1219
|
+
output = +""
|
1220
|
+
|
1221
|
+
output += "@ #{node_name} "
|
1222
|
+
output += location.tree_inspect
|
1223
|
+
output += "\n"
|
1224
|
+
|
1225
|
+
output += inspect_errors(prefix: "│ ")
|
1226
|
+
|
1227
|
+
output += "├── tag_opening: "
|
1228
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
1229
|
+
output += "\n"
|
1230
|
+
output += "├── content: "
|
1231
|
+
output += content ? content.tree_inspect : "∅"
|
1232
|
+
output += "\n"
|
1233
|
+
output += "├── tag_closing: "
|
1234
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
1235
|
+
output += "\n"
|
1236
|
+
output += "├── statements: "
|
1237
|
+
output += inspect_array(statements, prefix: "│ ")
|
1238
|
+
output += "└── end_node: "
|
1239
|
+
if end_node
|
1240
|
+
output += "\n"
|
1241
|
+
output += " └── "
|
1242
|
+
output += end_node.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, " ").delete_prefix(" ")
|
1243
|
+
else
|
1244
|
+
output += "∅\n"
|
1245
|
+
end
|
1246
|
+
output += "\n"
|
1247
|
+
|
1248
|
+
output.gsub(/^/, " " * indent)
|
1249
|
+
end
|
1250
|
+
end
|
1251
|
+
|
1252
|
+
class ERBRescueNode < Node
|
1253
|
+
attr_reader :tag_opening
|
1254
|
+
attr_reader :content
|
1255
|
+
attr_reader :tag_closing
|
1256
|
+
attr_reader :statements
|
1257
|
+
attr_reader :subsequent
|
1258
|
+
|
1259
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, statements, subsequent)
|
1260
|
+
super(type, location, errors)
|
1261
|
+
@tag_opening = tag_opening
|
1262
|
+
@content = content
|
1263
|
+
@tag_closing = tag_closing
|
1264
|
+
@statements = statements
|
1265
|
+
@subsequent = subsequent
|
1266
|
+
end
|
1267
|
+
|
1268
|
+
def to_hash
|
1269
|
+
super.merge({
|
1270
|
+
tag_opening: tag_opening,
|
1271
|
+
content: content,
|
1272
|
+
tag_closing: tag_closing,
|
1273
|
+
statements: statements,
|
1274
|
+
subsequent: subsequent,
|
1275
|
+
})
|
1276
|
+
end
|
1277
|
+
|
1278
|
+
def inspect
|
1279
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
1280
|
+
end
|
1281
|
+
|
1282
|
+
def tree_inspect(indent = 0)
|
1283
|
+
output = +""
|
1284
|
+
|
1285
|
+
output += "@ #{node_name} "
|
1286
|
+
output += location.tree_inspect
|
1287
|
+
output += "\n"
|
1288
|
+
|
1289
|
+
output += inspect_errors(prefix: "│ ")
|
1290
|
+
|
1291
|
+
output += "├── tag_opening: "
|
1292
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
1293
|
+
output += "\n"
|
1294
|
+
output += "├── content: "
|
1295
|
+
output += content ? content.tree_inspect : "∅"
|
1296
|
+
output += "\n"
|
1297
|
+
output += "├── tag_closing: "
|
1298
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
1299
|
+
output += "\n"
|
1300
|
+
output += "├── statements: "
|
1301
|
+
output += inspect_array(statements, prefix: "│ ")
|
1302
|
+
output += "└── subsequent: "
|
1303
|
+
if subsequent
|
1304
|
+
output += "\n"
|
1305
|
+
output += " └── "
|
1306
|
+
output += subsequent.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, " ").delete_prefix(" ")
|
1307
|
+
else
|
1308
|
+
output += "∅\n"
|
1309
|
+
end
|
1310
|
+
output += "\n"
|
1311
|
+
|
1312
|
+
output.gsub(/^/, " " * indent)
|
1313
|
+
end
|
1314
|
+
end
|
1315
|
+
|
1316
|
+
class ERBEnsureNode < Node
|
1317
|
+
attr_reader :tag_opening
|
1318
|
+
attr_reader :content
|
1319
|
+
attr_reader :tag_closing
|
1320
|
+
attr_reader :statements
|
1321
|
+
|
1322
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, statements)
|
1323
|
+
super(type, location, errors)
|
1324
|
+
@tag_opening = tag_opening
|
1325
|
+
@content = content
|
1326
|
+
@tag_closing = tag_closing
|
1327
|
+
@statements = statements
|
1328
|
+
end
|
1329
|
+
|
1330
|
+
def to_hash
|
1331
|
+
super.merge({
|
1332
|
+
tag_opening: tag_opening,
|
1333
|
+
content: content,
|
1334
|
+
tag_closing: tag_closing,
|
1335
|
+
statements: statements,
|
1336
|
+
})
|
1337
|
+
end
|
1338
|
+
|
1339
|
+
def inspect
|
1340
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
1341
|
+
end
|
1342
|
+
|
1343
|
+
def tree_inspect(indent = 0)
|
1344
|
+
output = +""
|
1345
|
+
|
1346
|
+
output += "@ #{node_name} "
|
1347
|
+
output += location.tree_inspect
|
1348
|
+
output += "\n"
|
1349
|
+
|
1350
|
+
output += inspect_errors(prefix: "│ ")
|
1351
|
+
|
1352
|
+
output += "├── tag_opening: "
|
1353
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
1354
|
+
output += "\n"
|
1355
|
+
output += "├── content: "
|
1356
|
+
output += content ? content.tree_inspect : "∅"
|
1357
|
+
output += "\n"
|
1358
|
+
output += "├── tag_closing: "
|
1359
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
1360
|
+
output += "\n"
|
1361
|
+
output += "└── statements: "
|
1362
|
+
output += inspect_array(statements, prefix: " ")
|
1363
|
+
output += "\n"
|
1364
|
+
|
1365
|
+
output.gsub(/^/, " " * indent)
|
1366
|
+
end
|
1367
|
+
end
|
1368
|
+
|
1369
|
+
class ERBBeginNode < Node
|
1370
|
+
attr_reader :tag_opening
|
1371
|
+
attr_reader :content
|
1372
|
+
attr_reader :tag_closing
|
1373
|
+
attr_reader :statements
|
1374
|
+
attr_reader :rescue_clause
|
1375
|
+
attr_reader :else_clause
|
1376
|
+
attr_reader :ensure_clause
|
1377
|
+
attr_reader :end_node
|
1378
|
+
|
1379
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, statements, rescue_clause, else_clause, ensure_clause, end_node)
|
1380
|
+
super(type, location, errors)
|
1381
|
+
@tag_opening = tag_opening
|
1382
|
+
@content = content
|
1383
|
+
@tag_closing = tag_closing
|
1384
|
+
@statements = statements
|
1385
|
+
@rescue_clause = rescue_clause
|
1386
|
+
@else_clause = else_clause
|
1387
|
+
@ensure_clause = ensure_clause
|
1388
|
+
@end_node = end_node
|
1389
|
+
end
|
1390
|
+
|
1391
|
+
def to_hash
|
1392
|
+
super.merge({
|
1393
|
+
tag_opening: tag_opening,
|
1394
|
+
content: content,
|
1395
|
+
tag_closing: tag_closing,
|
1396
|
+
statements: statements,
|
1397
|
+
rescue_clause: rescue_clause,
|
1398
|
+
else_clause: else_clause,
|
1399
|
+
ensure_clause: ensure_clause,
|
1400
|
+
end_node: end_node,
|
1401
|
+
})
|
1402
|
+
end
|
1403
|
+
|
1404
|
+
def inspect
|
1405
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
1406
|
+
end
|
1407
|
+
|
1408
|
+
def tree_inspect(indent = 0)
|
1409
|
+
output = +""
|
1410
|
+
|
1411
|
+
output += "@ #{node_name} "
|
1412
|
+
output += location.tree_inspect
|
1413
|
+
output += "\n"
|
1414
|
+
|
1415
|
+
output += inspect_errors(prefix: "│ ")
|
1416
|
+
|
1417
|
+
output += "├── tag_opening: "
|
1418
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
1419
|
+
output += "\n"
|
1420
|
+
output += "├── content: "
|
1421
|
+
output += content ? content.tree_inspect : "∅"
|
1422
|
+
output += "\n"
|
1423
|
+
output += "├── tag_closing: "
|
1424
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
1425
|
+
output += "\n"
|
1426
|
+
output += "├── statements: "
|
1427
|
+
output += inspect_array(statements, prefix: "│ ")
|
1428
|
+
output += "├── rescue_clause: "
|
1429
|
+
if rescue_clause
|
1430
|
+
output += "\n"
|
1431
|
+
output += "│ └── "
|
1432
|
+
output += rescue_clause.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, "│ ").delete_prefix("│ ")
|
1433
|
+
else
|
1434
|
+
output += "∅\n"
|
1435
|
+
end
|
1436
|
+
output += "├── else_clause: "
|
1437
|
+
if else_clause
|
1438
|
+
output += "\n"
|
1439
|
+
output += "│ └── "
|
1440
|
+
output += else_clause.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, "│ ").delete_prefix("│ ")
|
1441
|
+
else
|
1442
|
+
output += "∅\n"
|
1443
|
+
end
|
1444
|
+
output += "├── ensure_clause: "
|
1445
|
+
if ensure_clause
|
1446
|
+
output += "\n"
|
1447
|
+
output += "│ └── "
|
1448
|
+
output += ensure_clause.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, "│ ").delete_prefix("│ ")
|
1449
|
+
else
|
1450
|
+
output += "∅\n"
|
1451
|
+
end
|
1452
|
+
output += "└── end_node: "
|
1453
|
+
if end_node
|
1454
|
+
output += "\n"
|
1455
|
+
output += " └── "
|
1456
|
+
output += end_node.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, " ").delete_prefix(" ")
|
1457
|
+
else
|
1458
|
+
output += "∅\n"
|
1459
|
+
end
|
1460
|
+
output += "\n"
|
1461
|
+
|
1462
|
+
output.gsub(/^/, " " * indent)
|
1463
|
+
end
|
1464
|
+
end
|
1465
|
+
|
1466
|
+
class ERBUnlessNode < Node
|
1467
|
+
attr_reader :tag_opening
|
1468
|
+
attr_reader :content
|
1469
|
+
attr_reader :tag_closing
|
1470
|
+
attr_reader :statements
|
1471
|
+
attr_reader :else_clause
|
1472
|
+
attr_reader :end_node
|
1473
|
+
|
1474
|
+
def initialize(type, location, errors, tag_opening, content, tag_closing, statements, else_clause, end_node)
|
1475
|
+
super(type, location, errors)
|
1476
|
+
@tag_opening = tag_opening
|
1477
|
+
@content = content
|
1478
|
+
@tag_closing = tag_closing
|
1479
|
+
@statements = statements
|
1480
|
+
@else_clause = else_clause
|
1481
|
+
@end_node = end_node
|
1482
|
+
end
|
1483
|
+
|
1484
|
+
def to_hash
|
1485
|
+
super.merge({
|
1486
|
+
tag_opening: tag_opening,
|
1487
|
+
content: content,
|
1488
|
+
tag_closing: tag_closing,
|
1489
|
+
statements: statements,
|
1490
|
+
else_clause: else_clause,
|
1491
|
+
end_node: end_node,
|
1492
|
+
})
|
1493
|
+
end
|
1494
|
+
|
1495
|
+
def inspect
|
1496
|
+
tree_inspect.rstrip.gsub(/\s+$/, "")
|
1497
|
+
end
|
1498
|
+
|
1499
|
+
def tree_inspect(indent = 0)
|
1500
|
+
output = +""
|
1501
|
+
|
1502
|
+
output += "@ #{node_name} "
|
1503
|
+
output += location.tree_inspect
|
1504
|
+
output += "\n"
|
1505
|
+
|
1506
|
+
output += inspect_errors(prefix: "│ ")
|
1507
|
+
|
1508
|
+
output += "├── tag_opening: "
|
1509
|
+
output += tag_opening ? tag_opening.tree_inspect : "∅"
|
1510
|
+
output += "\n"
|
1511
|
+
output += "├── content: "
|
1512
|
+
output += content ? content.tree_inspect : "∅"
|
1513
|
+
output += "\n"
|
1514
|
+
output += "├── tag_closing: "
|
1515
|
+
output += tag_closing ? tag_closing.tree_inspect : "∅"
|
1516
|
+
output += "\n"
|
1517
|
+
output += "├── statements: "
|
1518
|
+
output += inspect_array(statements, prefix: "│ ")
|
1519
|
+
output += "├── else_clause: "
|
1520
|
+
if else_clause
|
1521
|
+
output += "\n"
|
1522
|
+
output += "│ └── "
|
1523
|
+
output += else_clause.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, "│ ").delete_prefix("│ ")
|
1524
|
+
else
|
1525
|
+
output += "∅\n"
|
1526
|
+
end
|
1527
|
+
output += "└── end_node: "
|
1528
|
+
if end_node
|
1529
|
+
output += "\n"
|
1530
|
+
output += " └── "
|
1531
|
+
output += end_node.tree_inspect(indent).gsub(/^/, " " * (indent + 1)).lstrip.gsub(/^/, " ").delete_prefix(" ")
|
1532
|
+
else
|
1533
|
+
output += "∅\n"
|
1534
|
+
end
|
1535
|
+
output += "\n"
|
1536
|
+
|
1537
|
+
output.gsub(/^/, " " * indent)
|
1538
|
+
end
|
1539
|
+
end
|
1540
|
+
|
1541
|
+
end
|
1542
|
+
end
|