jruby-prism-parser 0.23.0.pre.SNAPSHOT-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +401 -0
  3. data/CODE_OF_CONDUCT.md +76 -0
  4. data/CONTRIBUTING.md +62 -0
  5. data/LICENSE.md +7 -0
  6. data/Makefile +101 -0
  7. data/README.md +98 -0
  8. data/config.yml +2902 -0
  9. data/docs/build_system.md +91 -0
  10. data/docs/configuration.md +64 -0
  11. data/docs/cruby_compilation.md +27 -0
  12. data/docs/design.md +53 -0
  13. data/docs/encoding.md +121 -0
  14. data/docs/fuzzing.md +88 -0
  15. data/docs/heredocs.md +36 -0
  16. data/docs/javascript.md +118 -0
  17. data/docs/local_variable_depth.md +229 -0
  18. data/docs/mapping.md +117 -0
  19. data/docs/parser_translation.md +34 -0
  20. data/docs/parsing_rules.md +19 -0
  21. data/docs/releasing.md +98 -0
  22. data/docs/ripper.md +36 -0
  23. data/docs/ruby_api.md +43 -0
  24. data/docs/ruby_parser_translation.md +19 -0
  25. data/docs/serialization.md +209 -0
  26. data/docs/testing.md +55 -0
  27. data/ext/prism/api_node.c +5098 -0
  28. data/ext/prism/api_pack.c +267 -0
  29. data/ext/prism/extconf.rb +110 -0
  30. data/ext/prism/extension.c +1155 -0
  31. data/ext/prism/extension.h +18 -0
  32. data/include/prism/ast.h +5807 -0
  33. data/include/prism/defines.h +102 -0
  34. data/include/prism/diagnostic.h +339 -0
  35. data/include/prism/encoding.h +265 -0
  36. data/include/prism/node.h +57 -0
  37. data/include/prism/options.h +230 -0
  38. data/include/prism/pack.h +152 -0
  39. data/include/prism/parser.h +732 -0
  40. data/include/prism/prettyprint.h +26 -0
  41. data/include/prism/regexp.h +33 -0
  42. data/include/prism/util/pm_buffer.h +155 -0
  43. data/include/prism/util/pm_char.h +205 -0
  44. data/include/prism/util/pm_constant_pool.h +209 -0
  45. data/include/prism/util/pm_list.h +97 -0
  46. data/include/prism/util/pm_memchr.h +29 -0
  47. data/include/prism/util/pm_newline_list.h +93 -0
  48. data/include/prism/util/pm_state_stack.h +42 -0
  49. data/include/prism/util/pm_string.h +150 -0
  50. data/include/prism/util/pm_string_list.h +44 -0
  51. data/include/prism/util/pm_strncasecmp.h +32 -0
  52. data/include/prism/util/pm_strpbrk.h +46 -0
  53. data/include/prism/version.h +29 -0
  54. data/include/prism.h +289 -0
  55. data/jruby-prism.jar +0 -0
  56. data/lib/prism/compiler.rb +486 -0
  57. data/lib/prism/debug.rb +206 -0
  58. data/lib/prism/desugar_compiler.rb +207 -0
  59. data/lib/prism/dispatcher.rb +2150 -0
  60. data/lib/prism/dot_visitor.rb +4634 -0
  61. data/lib/prism/dsl.rb +785 -0
  62. data/lib/prism/ffi.rb +346 -0
  63. data/lib/prism/lex_compat.rb +908 -0
  64. data/lib/prism/mutation_compiler.rb +753 -0
  65. data/lib/prism/node.rb +17864 -0
  66. data/lib/prism/node_ext.rb +212 -0
  67. data/lib/prism/node_inspector.rb +68 -0
  68. data/lib/prism/pack.rb +224 -0
  69. data/lib/prism/parse_result/comments.rb +177 -0
  70. data/lib/prism/parse_result/newlines.rb +64 -0
  71. data/lib/prism/parse_result.rb +498 -0
  72. data/lib/prism/pattern.rb +250 -0
  73. data/lib/prism/serialize.rb +1354 -0
  74. data/lib/prism/translation/parser/compiler.rb +1838 -0
  75. data/lib/prism/translation/parser/lexer.rb +335 -0
  76. data/lib/prism/translation/parser/rubocop.rb +37 -0
  77. data/lib/prism/translation/parser.rb +178 -0
  78. data/lib/prism/translation/ripper.rb +577 -0
  79. data/lib/prism/translation/ruby_parser.rb +1521 -0
  80. data/lib/prism/translation.rb +11 -0
  81. data/lib/prism/version.rb +3 -0
  82. data/lib/prism/visitor.rb +495 -0
  83. data/lib/prism.rb +99 -0
  84. data/prism.gemspec +135 -0
  85. data/rbi/prism.rbi +7767 -0
  86. data/rbi/prism_static.rbi +207 -0
  87. data/sig/prism.rbs +4773 -0
  88. data/sig/prism_static.rbs +201 -0
  89. data/src/diagnostic.c +400 -0
  90. data/src/encoding.c +5132 -0
  91. data/src/node.c +2786 -0
  92. data/src/options.c +213 -0
  93. data/src/pack.c +493 -0
  94. data/src/prettyprint.c +8881 -0
  95. data/src/prism.c +18406 -0
  96. data/src/regexp.c +638 -0
  97. data/src/serialize.c +1554 -0
  98. data/src/token_type.c +700 -0
  99. data/src/util/pm_buffer.c +190 -0
  100. data/src/util/pm_char.c +318 -0
  101. data/src/util/pm_constant_pool.c +322 -0
  102. data/src/util/pm_list.c +49 -0
  103. data/src/util/pm_memchr.c +35 -0
  104. data/src/util/pm_newline_list.c +84 -0
  105. data/src/util/pm_state_stack.c +25 -0
  106. data/src/util/pm_string.c +203 -0
  107. data/src/util/pm_string_list.c +28 -0
  108. data/src/util/pm_strncasecmp.c +24 -0
  109. data/src/util/pm_strpbrk.c +180 -0
  110. metadata +156 -0
@@ -0,0 +1,4634 @@
1
+ # frozen_string_literal: true
2
+ =begin
3
+ This file is generated by the templates/template.rb script and should not be
4
+ modified manually. See templates/lib/prism/dot_visitor.rb.erb
5
+ if you are looking to modify the template
6
+ =end
7
+
8
+ require "cgi"
9
+
10
+ module Prism
11
+ # This visitor provides the ability to call Node#to_dot, which converts a
12
+ # subtree into a graphviz dot graph.
13
+ class DotVisitor < Visitor
14
+ class Field # :nodoc:
15
+ attr_reader :name, :value, :port
16
+
17
+ def initialize(name, value, port)
18
+ @name = name
19
+ @value = value
20
+ @port = port
21
+ end
22
+
23
+ def to_dot
24
+ if port
25
+ "<tr><td align=\"left\" colspan=\"2\" port=\"#{name}\">#{name}</td></tr>"
26
+ else
27
+ "<tr><td align=\"left\">#{name}</td><td>#{CGI.escapeHTML(value)}</td></tr>"
28
+ end
29
+ end
30
+ end
31
+
32
+ class Table # :nodoc:
33
+ attr_reader :name, :fields
34
+
35
+ def initialize(name)
36
+ @name = name
37
+ @fields = []
38
+ end
39
+
40
+ def field(name, value = nil, port: false)
41
+ fields << Field.new(name, value, port)
42
+ end
43
+
44
+ def to_dot
45
+ dot = <<~DOT
46
+ <table border="0" cellborder="1" cellspacing="0" cellpadding="4">
47
+ <tr><td colspan="2"><b>#{name}</b></td></tr>
48
+ DOT
49
+
50
+ if fields.any?
51
+ "#{dot} #{fields.map(&:to_dot).join("\n ")}\n</table>"
52
+ else
53
+ "#{dot}</table>"
54
+ end
55
+ end
56
+ end
57
+
58
+ class Digraph # :nodoc:
59
+ attr_reader :nodes, :waypoints, :edges
60
+
61
+ def initialize
62
+ @nodes = []
63
+ @waypoints = []
64
+ @edges = []
65
+ end
66
+
67
+ def node(value)
68
+ nodes << value
69
+ end
70
+
71
+ def waypoint(value)
72
+ waypoints << value
73
+ end
74
+
75
+ def edge(value)
76
+ edges << value
77
+ end
78
+
79
+ def to_dot
80
+ <<~DOT
81
+ digraph "Prism" {
82
+ node [
83
+ fontname=\"Courier New\"
84
+ shape=plain
85
+ style=filled
86
+ fillcolor=gray95
87
+ ];
88
+
89
+ #{nodes.map { |node| node.gsub(/\n/, "\n ") }.join("\n ")}
90
+ node [shape=point];
91
+ #{waypoints.join("\n ")}
92
+
93
+ #{edges.join("\n ")}
94
+ }
95
+ DOT
96
+ end
97
+ end
98
+
99
+ private_constant :Field, :Table, :Digraph
100
+
101
+ # The digraph that is being built.
102
+ attr_reader :digraph
103
+
104
+ # Initialize a new dot visitor.
105
+ def initialize
106
+ @digraph = Digraph.new
107
+ end
108
+
109
+ # Convert this visitor into a graphviz dot graph string.
110
+ def to_dot
111
+ digraph.to_dot
112
+ end
113
+
114
+ # Visit a AliasGlobalVariableNode node.
115
+ def visit_alias_global_variable_node(node)
116
+ table = Table.new("AliasGlobalVariableNode")
117
+ id = node_id(node)
118
+
119
+ # new_name
120
+ table.field("new_name", port: true)
121
+ digraph.edge("#{id}:new_name -> #{node_id(node.new_name)};")
122
+
123
+ # old_name
124
+ table.field("old_name", port: true)
125
+ digraph.edge("#{id}:old_name -> #{node_id(node.old_name)};")
126
+
127
+ # keyword_loc
128
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
129
+
130
+ digraph.nodes << <<~DOT
131
+ #{id} [
132
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
133
+ ];
134
+ DOT
135
+
136
+ super
137
+ end
138
+
139
+ # Visit a AliasMethodNode node.
140
+ def visit_alias_method_node(node)
141
+ table = Table.new("AliasMethodNode")
142
+ id = node_id(node)
143
+
144
+ # new_name
145
+ table.field("new_name", port: true)
146
+ digraph.edge("#{id}:new_name -> #{node_id(node.new_name)};")
147
+
148
+ # old_name
149
+ table.field("old_name", port: true)
150
+ digraph.edge("#{id}:old_name -> #{node_id(node.old_name)};")
151
+
152
+ # keyword_loc
153
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
154
+
155
+ digraph.nodes << <<~DOT
156
+ #{id} [
157
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
158
+ ];
159
+ DOT
160
+
161
+ super
162
+ end
163
+
164
+ # Visit a AlternationPatternNode node.
165
+ def visit_alternation_pattern_node(node)
166
+ table = Table.new("AlternationPatternNode")
167
+ id = node_id(node)
168
+
169
+ # left
170
+ table.field("left", port: true)
171
+ digraph.edge("#{id}:left -> #{node_id(node.left)};")
172
+
173
+ # right
174
+ table.field("right", port: true)
175
+ digraph.edge("#{id}:right -> #{node_id(node.right)};")
176
+
177
+ # operator_loc
178
+ table.field("operator_loc", location_inspect(node.operator_loc))
179
+
180
+ digraph.nodes << <<~DOT
181
+ #{id} [
182
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
183
+ ];
184
+ DOT
185
+
186
+ super
187
+ end
188
+
189
+ # Visit a AndNode node.
190
+ def visit_and_node(node)
191
+ table = Table.new("AndNode")
192
+ id = node_id(node)
193
+
194
+ # left
195
+ table.field("left", port: true)
196
+ digraph.edge("#{id}:left -> #{node_id(node.left)};")
197
+
198
+ # right
199
+ table.field("right", port: true)
200
+ digraph.edge("#{id}:right -> #{node_id(node.right)};")
201
+
202
+ # operator_loc
203
+ table.field("operator_loc", location_inspect(node.operator_loc))
204
+
205
+ digraph.nodes << <<~DOT
206
+ #{id} [
207
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
208
+ ];
209
+ DOT
210
+
211
+ super
212
+ end
213
+
214
+ # Visit a ArgumentsNode node.
215
+ def visit_arguments_node(node)
216
+ table = Table.new("ArgumentsNode")
217
+ id = node_id(node)
218
+
219
+ # flags
220
+ table.field("flags", arguments_node_flags_inspect(node))
221
+
222
+ # arguments
223
+ if node.arguments.any?
224
+ table.field("arguments", port: true)
225
+
226
+ waypoint = "#{id}_arguments"
227
+ digraph.waypoint("#{waypoint};")
228
+
229
+ digraph.edge("#{id}:arguments -> #{waypoint};")
230
+ node.arguments.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
231
+ else
232
+ table.field("arguments", "[]")
233
+ end
234
+
235
+ digraph.nodes << <<~DOT
236
+ #{id} [
237
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
238
+ ];
239
+ DOT
240
+
241
+ super
242
+ end
243
+
244
+ # Visit a ArrayNode node.
245
+ def visit_array_node(node)
246
+ table = Table.new("ArrayNode")
247
+ id = node_id(node)
248
+
249
+ # flags
250
+ table.field("flags", array_node_flags_inspect(node))
251
+
252
+ # elements
253
+ if node.elements.any?
254
+ table.field("elements", port: true)
255
+
256
+ waypoint = "#{id}_elements"
257
+ digraph.waypoint("#{waypoint};")
258
+
259
+ digraph.edge("#{id}:elements -> #{waypoint};")
260
+ node.elements.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
261
+ else
262
+ table.field("elements", "[]")
263
+ end
264
+
265
+ # opening_loc
266
+ unless (opening_loc = node.opening_loc).nil?
267
+ table.field("opening_loc", location_inspect(opening_loc))
268
+ end
269
+
270
+ # closing_loc
271
+ unless (closing_loc = node.closing_loc).nil?
272
+ table.field("closing_loc", location_inspect(closing_loc))
273
+ end
274
+
275
+ digraph.nodes << <<~DOT
276
+ #{id} [
277
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
278
+ ];
279
+ DOT
280
+
281
+ super
282
+ end
283
+
284
+ # Visit a ArrayPatternNode node.
285
+ def visit_array_pattern_node(node)
286
+ table = Table.new("ArrayPatternNode")
287
+ id = node_id(node)
288
+
289
+ # constant
290
+ unless (constant = node.constant).nil?
291
+ table.field("constant", port: true)
292
+ digraph.edge("#{id}:constant -> #{node_id(constant)};")
293
+ end
294
+
295
+ # requireds
296
+ if node.requireds.any?
297
+ table.field("requireds", port: true)
298
+
299
+ waypoint = "#{id}_requireds"
300
+ digraph.waypoint("#{waypoint};")
301
+
302
+ digraph.edge("#{id}:requireds -> #{waypoint};")
303
+ node.requireds.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
304
+ else
305
+ table.field("requireds", "[]")
306
+ end
307
+
308
+ # rest
309
+ unless (rest = node.rest).nil?
310
+ table.field("rest", port: true)
311
+ digraph.edge("#{id}:rest -> #{node_id(rest)};")
312
+ end
313
+
314
+ # posts
315
+ if node.posts.any?
316
+ table.field("posts", port: true)
317
+
318
+ waypoint = "#{id}_posts"
319
+ digraph.waypoint("#{waypoint};")
320
+
321
+ digraph.edge("#{id}:posts -> #{waypoint};")
322
+ node.posts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
323
+ else
324
+ table.field("posts", "[]")
325
+ end
326
+
327
+ # opening_loc
328
+ unless (opening_loc = node.opening_loc).nil?
329
+ table.field("opening_loc", location_inspect(opening_loc))
330
+ end
331
+
332
+ # closing_loc
333
+ unless (closing_loc = node.closing_loc).nil?
334
+ table.field("closing_loc", location_inspect(closing_loc))
335
+ end
336
+
337
+ digraph.nodes << <<~DOT
338
+ #{id} [
339
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
340
+ ];
341
+ DOT
342
+
343
+ super
344
+ end
345
+
346
+ # Visit a AssocNode node.
347
+ def visit_assoc_node(node)
348
+ table = Table.new("AssocNode")
349
+ id = node_id(node)
350
+
351
+ # key
352
+ table.field("key", port: true)
353
+ digraph.edge("#{id}:key -> #{node_id(node.key)};")
354
+
355
+ # value
356
+ table.field("value", port: true)
357
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
358
+
359
+ # operator_loc
360
+ unless (operator_loc = node.operator_loc).nil?
361
+ table.field("operator_loc", location_inspect(operator_loc))
362
+ end
363
+
364
+ digraph.nodes << <<~DOT
365
+ #{id} [
366
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
367
+ ];
368
+ DOT
369
+
370
+ super
371
+ end
372
+
373
+ # Visit a AssocSplatNode node.
374
+ def visit_assoc_splat_node(node)
375
+ table = Table.new("AssocSplatNode")
376
+ id = node_id(node)
377
+
378
+ # value
379
+ unless (value = node.value).nil?
380
+ table.field("value", port: true)
381
+ digraph.edge("#{id}:value -> #{node_id(value)};")
382
+ end
383
+
384
+ # operator_loc
385
+ table.field("operator_loc", location_inspect(node.operator_loc))
386
+
387
+ digraph.nodes << <<~DOT
388
+ #{id} [
389
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
390
+ ];
391
+ DOT
392
+
393
+ super
394
+ end
395
+
396
+ # Visit a BackReferenceReadNode node.
397
+ def visit_back_reference_read_node(node)
398
+ table = Table.new("BackReferenceReadNode")
399
+ id = node_id(node)
400
+
401
+ # name
402
+ table.field("name", node.name.inspect)
403
+
404
+ digraph.nodes << <<~DOT
405
+ #{id} [
406
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
407
+ ];
408
+ DOT
409
+
410
+ super
411
+ end
412
+
413
+ # Visit a BeginNode node.
414
+ def visit_begin_node(node)
415
+ table = Table.new("BeginNode")
416
+ id = node_id(node)
417
+
418
+ # begin_keyword_loc
419
+ unless (begin_keyword_loc = node.begin_keyword_loc).nil?
420
+ table.field("begin_keyword_loc", location_inspect(begin_keyword_loc))
421
+ end
422
+
423
+ # statements
424
+ unless (statements = node.statements).nil?
425
+ table.field("statements", port: true)
426
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
427
+ end
428
+
429
+ # rescue_clause
430
+ unless (rescue_clause = node.rescue_clause).nil?
431
+ table.field("rescue_clause", port: true)
432
+ digraph.edge("#{id}:rescue_clause -> #{node_id(rescue_clause)};")
433
+ end
434
+
435
+ # else_clause
436
+ unless (else_clause = node.else_clause).nil?
437
+ table.field("else_clause", port: true)
438
+ digraph.edge("#{id}:else_clause -> #{node_id(else_clause)};")
439
+ end
440
+
441
+ # ensure_clause
442
+ unless (ensure_clause = node.ensure_clause).nil?
443
+ table.field("ensure_clause", port: true)
444
+ digraph.edge("#{id}:ensure_clause -> #{node_id(ensure_clause)};")
445
+ end
446
+
447
+ # end_keyword_loc
448
+ unless (end_keyword_loc = node.end_keyword_loc).nil?
449
+ table.field("end_keyword_loc", location_inspect(end_keyword_loc))
450
+ end
451
+
452
+ digraph.nodes << <<~DOT
453
+ #{id} [
454
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
455
+ ];
456
+ DOT
457
+
458
+ super
459
+ end
460
+
461
+ # Visit a BlockArgumentNode node.
462
+ def visit_block_argument_node(node)
463
+ table = Table.new("BlockArgumentNode")
464
+ id = node_id(node)
465
+
466
+ # expression
467
+ unless (expression = node.expression).nil?
468
+ table.field("expression", port: true)
469
+ digraph.edge("#{id}:expression -> #{node_id(expression)};")
470
+ end
471
+
472
+ # operator_loc
473
+ table.field("operator_loc", location_inspect(node.operator_loc))
474
+
475
+ digraph.nodes << <<~DOT
476
+ #{id} [
477
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
478
+ ];
479
+ DOT
480
+
481
+ super
482
+ end
483
+
484
+ # Visit a BlockLocalVariableNode node.
485
+ def visit_block_local_variable_node(node)
486
+ table = Table.new("BlockLocalVariableNode")
487
+ id = node_id(node)
488
+
489
+ # flags
490
+ table.field("flags", parameter_flags_inspect(node))
491
+
492
+ # name
493
+ table.field("name", node.name.inspect)
494
+
495
+ digraph.nodes << <<~DOT
496
+ #{id} [
497
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
498
+ ];
499
+ DOT
500
+
501
+ super
502
+ end
503
+
504
+ # Visit a BlockNode node.
505
+ def visit_block_node(node)
506
+ table = Table.new("BlockNode")
507
+ id = node_id(node)
508
+
509
+ # locals
510
+ table.field("locals", node.locals.inspect)
511
+
512
+ # parameters
513
+ unless (parameters = node.parameters).nil?
514
+ table.field("parameters", port: true)
515
+ digraph.edge("#{id}:parameters -> #{node_id(parameters)};")
516
+ end
517
+
518
+ # body
519
+ unless (body = node.body).nil?
520
+ table.field("body", port: true)
521
+ digraph.edge("#{id}:body -> #{node_id(body)};")
522
+ end
523
+
524
+ # opening_loc
525
+ table.field("opening_loc", location_inspect(node.opening_loc))
526
+
527
+ # closing_loc
528
+ table.field("closing_loc", location_inspect(node.closing_loc))
529
+
530
+ digraph.nodes << <<~DOT
531
+ #{id} [
532
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
533
+ ];
534
+ DOT
535
+
536
+ super
537
+ end
538
+
539
+ # Visit a BlockParameterNode node.
540
+ def visit_block_parameter_node(node)
541
+ table = Table.new("BlockParameterNode")
542
+ id = node_id(node)
543
+
544
+ # flags
545
+ table.field("flags", parameter_flags_inspect(node))
546
+
547
+ # name
548
+ table.field("name", node.name.inspect)
549
+
550
+ # name_loc
551
+ unless (name_loc = node.name_loc).nil?
552
+ table.field("name_loc", location_inspect(name_loc))
553
+ end
554
+
555
+ # operator_loc
556
+ table.field("operator_loc", location_inspect(node.operator_loc))
557
+
558
+ digraph.nodes << <<~DOT
559
+ #{id} [
560
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
561
+ ];
562
+ DOT
563
+
564
+ super
565
+ end
566
+
567
+ # Visit a BlockParametersNode node.
568
+ def visit_block_parameters_node(node)
569
+ table = Table.new("BlockParametersNode")
570
+ id = node_id(node)
571
+
572
+ # parameters
573
+ unless (parameters = node.parameters).nil?
574
+ table.field("parameters", port: true)
575
+ digraph.edge("#{id}:parameters -> #{node_id(parameters)};")
576
+ end
577
+
578
+ # locals
579
+ if node.locals.any?
580
+ table.field("locals", port: true)
581
+
582
+ waypoint = "#{id}_locals"
583
+ digraph.waypoint("#{waypoint};")
584
+
585
+ digraph.edge("#{id}:locals -> #{waypoint};")
586
+ node.locals.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
587
+ else
588
+ table.field("locals", "[]")
589
+ end
590
+
591
+ # opening_loc
592
+ unless (opening_loc = node.opening_loc).nil?
593
+ table.field("opening_loc", location_inspect(opening_loc))
594
+ end
595
+
596
+ # closing_loc
597
+ unless (closing_loc = node.closing_loc).nil?
598
+ table.field("closing_loc", location_inspect(closing_loc))
599
+ end
600
+
601
+ digraph.nodes << <<~DOT
602
+ #{id} [
603
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
604
+ ];
605
+ DOT
606
+
607
+ super
608
+ end
609
+
610
+ # Visit a BreakNode node.
611
+ def visit_break_node(node)
612
+ table = Table.new("BreakNode")
613
+ id = node_id(node)
614
+
615
+ # arguments
616
+ unless (arguments = node.arguments).nil?
617
+ table.field("arguments", port: true)
618
+ digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
619
+ end
620
+
621
+ # keyword_loc
622
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
623
+
624
+ digraph.nodes << <<~DOT
625
+ #{id} [
626
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
627
+ ];
628
+ DOT
629
+
630
+ super
631
+ end
632
+
633
+ # Visit a CallAndWriteNode node.
634
+ def visit_call_and_write_node(node)
635
+ table = Table.new("CallAndWriteNode")
636
+ id = node_id(node)
637
+
638
+ # flags
639
+ table.field("flags", call_node_flags_inspect(node))
640
+
641
+ # receiver
642
+ unless (receiver = node.receiver).nil?
643
+ table.field("receiver", port: true)
644
+ digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
645
+ end
646
+
647
+ # call_operator_loc
648
+ unless (call_operator_loc = node.call_operator_loc).nil?
649
+ table.field("call_operator_loc", location_inspect(call_operator_loc))
650
+ end
651
+
652
+ # message_loc
653
+ unless (message_loc = node.message_loc).nil?
654
+ table.field("message_loc", location_inspect(message_loc))
655
+ end
656
+
657
+ # read_name
658
+ table.field("read_name", node.read_name.inspect)
659
+
660
+ # write_name
661
+ table.field("write_name", node.write_name.inspect)
662
+
663
+ # operator_loc
664
+ table.field("operator_loc", location_inspect(node.operator_loc))
665
+
666
+ # value
667
+ table.field("value", port: true)
668
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
669
+
670
+ digraph.nodes << <<~DOT
671
+ #{id} [
672
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
673
+ ];
674
+ DOT
675
+
676
+ super
677
+ end
678
+
679
+ # Visit a CallNode node.
680
+ def visit_call_node(node)
681
+ table = Table.new("CallNode")
682
+ id = node_id(node)
683
+
684
+ # flags
685
+ table.field("flags", call_node_flags_inspect(node))
686
+
687
+ # receiver
688
+ unless (receiver = node.receiver).nil?
689
+ table.field("receiver", port: true)
690
+ digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
691
+ end
692
+
693
+ # call_operator_loc
694
+ unless (call_operator_loc = node.call_operator_loc).nil?
695
+ table.field("call_operator_loc", location_inspect(call_operator_loc))
696
+ end
697
+
698
+ # name
699
+ table.field("name", node.name.inspect)
700
+
701
+ # message_loc
702
+ unless (message_loc = node.message_loc).nil?
703
+ table.field("message_loc", location_inspect(message_loc))
704
+ end
705
+
706
+ # opening_loc
707
+ unless (opening_loc = node.opening_loc).nil?
708
+ table.field("opening_loc", location_inspect(opening_loc))
709
+ end
710
+
711
+ # arguments
712
+ unless (arguments = node.arguments).nil?
713
+ table.field("arguments", port: true)
714
+ digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
715
+ end
716
+
717
+ # closing_loc
718
+ unless (closing_loc = node.closing_loc).nil?
719
+ table.field("closing_loc", location_inspect(closing_loc))
720
+ end
721
+
722
+ # block
723
+ unless (block = node.block).nil?
724
+ table.field("block", port: true)
725
+ digraph.edge("#{id}:block -> #{node_id(block)};")
726
+ end
727
+
728
+ digraph.nodes << <<~DOT
729
+ #{id} [
730
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
731
+ ];
732
+ DOT
733
+
734
+ super
735
+ end
736
+
737
+ # Visit a CallOperatorWriteNode node.
738
+ def visit_call_operator_write_node(node)
739
+ table = Table.new("CallOperatorWriteNode")
740
+ id = node_id(node)
741
+
742
+ # flags
743
+ table.field("flags", call_node_flags_inspect(node))
744
+
745
+ # receiver
746
+ unless (receiver = node.receiver).nil?
747
+ table.field("receiver", port: true)
748
+ digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
749
+ end
750
+
751
+ # call_operator_loc
752
+ unless (call_operator_loc = node.call_operator_loc).nil?
753
+ table.field("call_operator_loc", location_inspect(call_operator_loc))
754
+ end
755
+
756
+ # message_loc
757
+ unless (message_loc = node.message_loc).nil?
758
+ table.field("message_loc", location_inspect(message_loc))
759
+ end
760
+
761
+ # read_name
762
+ table.field("read_name", node.read_name.inspect)
763
+
764
+ # write_name
765
+ table.field("write_name", node.write_name.inspect)
766
+
767
+ # operator
768
+ table.field("operator", node.operator.inspect)
769
+
770
+ # operator_loc
771
+ table.field("operator_loc", location_inspect(node.operator_loc))
772
+
773
+ # value
774
+ table.field("value", port: true)
775
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
776
+
777
+ digraph.nodes << <<~DOT
778
+ #{id} [
779
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
780
+ ];
781
+ DOT
782
+
783
+ super
784
+ end
785
+
786
+ # Visit a CallOrWriteNode node.
787
+ def visit_call_or_write_node(node)
788
+ table = Table.new("CallOrWriteNode")
789
+ id = node_id(node)
790
+
791
+ # flags
792
+ table.field("flags", call_node_flags_inspect(node))
793
+
794
+ # receiver
795
+ unless (receiver = node.receiver).nil?
796
+ table.field("receiver", port: true)
797
+ digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
798
+ end
799
+
800
+ # call_operator_loc
801
+ unless (call_operator_loc = node.call_operator_loc).nil?
802
+ table.field("call_operator_loc", location_inspect(call_operator_loc))
803
+ end
804
+
805
+ # message_loc
806
+ unless (message_loc = node.message_loc).nil?
807
+ table.field("message_loc", location_inspect(message_loc))
808
+ end
809
+
810
+ # read_name
811
+ table.field("read_name", node.read_name.inspect)
812
+
813
+ # write_name
814
+ table.field("write_name", node.write_name.inspect)
815
+
816
+ # operator_loc
817
+ table.field("operator_loc", location_inspect(node.operator_loc))
818
+
819
+ # value
820
+ table.field("value", port: true)
821
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
822
+
823
+ digraph.nodes << <<~DOT
824
+ #{id} [
825
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
826
+ ];
827
+ DOT
828
+
829
+ super
830
+ end
831
+
832
+ # Visit a CallTargetNode node.
833
+ def visit_call_target_node(node)
834
+ table = Table.new("CallTargetNode")
835
+ id = node_id(node)
836
+
837
+ # flags
838
+ table.field("flags", call_node_flags_inspect(node))
839
+
840
+ # receiver
841
+ table.field("receiver", port: true)
842
+ digraph.edge("#{id}:receiver -> #{node_id(node.receiver)};")
843
+
844
+ # call_operator_loc
845
+ table.field("call_operator_loc", location_inspect(node.call_operator_loc))
846
+
847
+ # name
848
+ table.field("name", node.name.inspect)
849
+
850
+ # message_loc
851
+ table.field("message_loc", location_inspect(node.message_loc))
852
+
853
+ digraph.nodes << <<~DOT
854
+ #{id} [
855
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
856
+ ];
857
+ DOT
858
+
859
+ super
860
+ end
861
+
862
+ # Visit a CapturePatternNode node.
863
+ def visit_capture_pattern_node(node)
864
+ table = Table.new("CapturePatternNode")
865
+ id = node_id(node)
866
+
867
+ # value
868
+ table.field("value", port: true)
869
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
870
+
871
+ # target
872
+ table.field("target", port: true)
873
+ digraph.edge("#{id}:target -> #{node_id(node.target)};")
874
+
875
+ # operator_loc
876
+ table.field("operator_loc", location_inspect(node.operator_loc))
877
+
878
+ digraph.nodes << <<~DOT
879
+ #{id} [
880
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
881
+ ];
882
+ DOT
883
+
884
+ super
885
+ end
886
+
887
+ # Visit a CaseMatchNode node.
888
+ def visit_case_match_node(node)
889
+ table = Table.new("CaseMatchNode")
890
+ id = node_id(node)
891
+
892
+ # predicate
893
+ unless (predicate = node.predicate).nil?
894
+ table.field("predicate", port: true)
895
+ digraph.edge("#{id}:predicate -> #{node_id(predicate)};")
896
+ end
897
+
898
+ # conditions
899
+ if node.conditions.any?
900
+ table.field("conditions", port: true)
901
+
902
+ waypoint = "#{id}_conditions"
903
+ digraph.waypoint("#{waypoint};")
904
+
905
+ digraph.edge("#{id}:conditions -> #{waypoint};")
906
+ node.conditions.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
907
+ else
908
+ table.field("conditions", "[]")
909
+ end
910
+
911
+ # consequent
912
+ unless (consequent = node.consequent).nil?
913
+ table.field("consequent", port: true)
914
+ digraph.edge("#{id}:consequent -> #{node_id(consequent)};")
915
+ end
916
+
917
+ # case_keyword_loc
918
+ table.field("case_keyword_loc", location_inspect(node.case_keyword_loc))
919
+
920
+ # end_keyword_loc
921
+ table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
922
+
923
+ digraph.nodes << <<~DOT
924
+ #{id} [
925
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
926
+ ];
927
+ DOT
928
+
929
+ super
930
+ end
931
+
932
+ # Visit a CaseNode node.
933
+ def visit_case_node(node)
934
+ table = Table.new("CaseNode")
935
+ id = node_id(node)
936
+
937
+ # predicate
938
+ unless (predicate = node.predicate).nil?
939
+ table.field("predicate", port: true)
940
+ digraph.edge("#{id}:predicate -> #{node_id(predicate)};")
941
+ end
942
+
943
+ # conditions
944
+ if node.conditions.any?
945
+ table.field("conditions", port: true)
946
+
947
+ waypoint = "#{id}_conditions"
948
+ digraph.waypoint("#{waypoint};")
949
+
950
+ digraph.edge("#{id}:conditions -> #{waypoint};")
951
+ node.conditions.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
952
+ else
953
+ table.field("conditions", "[]")
954
+ end
955
+
956
+ # consequent
957
+ unless (consequent = node.consequent).nil?
958
+ table.field("consequent", port: true)
959
+ digraph.edge("#{id}:consequent -> #{node_id(consequent)};")
960
+ end
961
+
962
+ # case_keyword_loc
963
+ table.field("case_keyword_loc", location_inspect(node.case_keyword_loc))
964
+
965
+ # end_keyword_loc
966
+ table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
967
+
968
+ digraph.nodes << <<~DOT
969
+ #{id} [
970
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
971
+ ];
972
+ DOT
973
+
974
+ super
975
+ end
976
+
977
+ # Visit a ClassNode node.
978
+ def visit_class_node(node)
979
+ table = Table.new("ClassNode")
980
+ id = node_id(node)
981
+
982
+ # locals
983
+ table.field("locals", node.locals.inspect)
984
+
985
+ # class_keyword_loc
986
+ table.field("class_keyword_loc", location_inspect(node.class_keyword_loc))
987
+
988
+ # constant_path
989
+ table.field("constant_path", port: true)
990
+ digraph.edge("#{id}:constant_path -> #{node_id(node.constant_path)};")
991
+
992
+ # inheritance_operator_loc
993
+ unless (inheritance_operator_loc = node.inheritance_operator_loc).nil?
994
+ table.field("inheritance_operator_loc", location_inspect(inheritance_operator_loc))
995
+ end
996
+
997
+ # superclass
998
+ unless (superclass = node.superclass).nil?
999
+ table.field("superclass", port: true)
1000
+ digraph.edge("#{id}:superclass -> #{node_id(superclass)};")
1001
+ end
1002
+
1003
+ # body
1004
+ unless (body = node.body).nil?
1005
+ table.field("body", port: true)
1006
+ digraph.edge("#{id}:body -> #{node_id(body)};")
1007
+ end
1008
+
1009
+ # end_keyword_loc
1010
+ table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
1011
+
1012
+ # name
1013
+ table.field("name", node.name.inspect)
1014
+
1015
+ digraph.nodes << <<~DOT
1016
+ #{id} [
1017
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1018
+ ];
1019
+ DOT
1020
+
1021
+ super
1022
+ end
1023
+
1024
+ # Visit a ClassVariableAndWriteNode node.
1025
+ def visit_class_variable_and_write_node(node)
1026
+ table = Table.new("ClassVariableAndWriteNode")
1027
+ id = node_id(node)
1028
+
1029
+ # name
1030
+ table.field("name", node.name.inspect)
1031
+
1032
+ # name_loc
1033
+ table.field("name_loc", location_inspect(node.name_loc))
1034
+
1035
+ # operator_loc
1036
+ table.field("operator_loc", location_inspect(node.operator_loc))
1037
+
1038
+ # value
1039
+ table.field("value", port: true)
1040
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1041
+
1042
+ digraph.nodes << <<~DOT
1043
+ #{id} [
1044
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1045
+ ];
1046
+ DOT
1047
+
1048
+ super
1049
+ end
1050
+
1051
+ # Visit a ClassVariableOperatorWriteNode node.
1052
+ def visit_class_variable_operator_write_node(node)
1053
+ table = Table.new("ClassVariableOperatorWriteNode")
1054
+ id = node_id(node)
1055
+
1056
+ # name
1057
+ table.field("name", node.name.inspect)
1058
+
1059
+ # name_loc
1060
+ table.field("name_loc", location_inspect(node.name_loc))
1061
+
1062
+ # operator_loc
1063
+ table.field("operator_loc", location_inspect(node.operator_loc))
1064
+
1065
+ # value
1066
+ table.field("value", port: true)
1067
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1068
+
1069
+ # operator
1070
+ table.field("operator", node.operator.inspect)
1071
+
1072
+ digraph.nodes << <<~DOT
1073
+ #{id} [
1074
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1075
+ ];
1076
+ DOT
1077
+
1078
+ super
1079
+ end
1080
+
1081
+ # Visit a ClassVariableOrWriteNode node.
1082
+ def visit_class_variable_or_write_node(node)
1083
+ table = Table.new("ClassVariableOrWriteNode")
1084
+ id = node_id(node)
1085
+
1086
+ # name
1087
+ table.field("name", node.name.inspect)
1088
+
1089
+ # name_loc
1090
+ table.field("name_loc", location_inspect(node.name_loc))
1091
+
1092
+ # operator_loc
1093
+ table.field("operator_loc", location_inspect(node.operator_loc))
1094
+
1095
+ # value
1096
+ table.field("value", port: true)
1097
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1098
+
1099
+ digraph.nodes << <<~DOT
1100
+ #{id} [
1101
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1102
+ ];
1103
+ DOT
1104
+
1105
+ super
1106
+ end
1107
+
1108
+ # Visit a ClassVariableReadNode node.
1109
+ def visit_class_variable_read_node(node)
1110
+ table = Table.new("ClassVariableReadNode")
1111
+ id = node_id(node)
1112
+
1113
+ # name
1114
+ table.field("name", node.name.inspect)
1115
+
1116
+ digraph.nodes << <<~DOT
1117
+ #{id} [
1118
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1119
+ ];
1120
+ DOT
1121
+
1122
+ super
1123
+ end
1124
+
1125
+ # Visit a ClassVariableTargetNode node.
1126
+ def visit_class_variable_target_node(node)
1127
+ table = Table.new("ClassVariableTargetNode")
1128
+ id = node_id(node)
1129
+
1130
+ # name
1131
+ table.field("name", node.name.inspect)
1132
+
1133
+ digraph.nodes << <<~DOT
1134
+ #{id} [
1135
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1136
+ ];
1137
+ DOT
1138
+
1139
+ super
1140
+ end
1141
+
1142
+ # Visit a ClassVariableWriteNode node.
1143
+ def visit_class_variable_write_node(node)
1144
+ table = Table.new("ClassVariableWriteNode")
1145
+ id = node_id(node)
1146
+
1147
+ # name
1148
+ table.field("name", node.name.inspect)
1149
+
1150
+ # name_loc
1151
+ table.field("name_loc", location_inspect(node.name_loc))
1152
+
1153
+ # value
1154
+ table.field("value", port: true)
1155
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1156
+
1157
+ # operator_loc
1158
+ unless (operator_loc = node.operator_loc).nil?
1159
+ table.field("operator_loc", location_inspect(operator_loc))
1160
+ end
1161
+
1162
+ digraph.nodes << <<~DOT
1163
+ #{id} [
1164
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1165
+ ];
1166
+ DOT
1167
+
1168
+ super
1169
+ end
1170
+
1171
+ # Visit a ConstantAndWriteNode node.
1172
+ def visit_constant_and_write_node(node)
1173
+ table = Table.new("ConstantAndWriteNode")
1174
+ id = node_id(node)
1175
+
1176
+ # name
1177
+ table.field("name", node.name.inspect)
1178
+
1179
+ # name_loc
1180
+ table.field("name_loc", location_inspect(node.name_loc))
1181
+
1182
+ # operator_loc
1183
+ table.field("operator_loc", location_inspect(node.operator_loc))
1184
+
1185
+ # value
1186
+ table.field("value", port: true)
1187
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1188
+
1189
+ digraph.nodes << <<~DOT
1190
+ #{id} [
1191
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1192
+ ];
1193
+ DOT
1194
+
1195
+ super
1196
+ end
1197
+
1198
+ # Visit a ConstantOperatorWriteNode node.
1199
+ def visit_constant_operator_write_node(node)
1200
+ table = Table.new("ConstantOperatorWriteNode")
1201
+ id = node_id(node)
1202
+
1203
+ # name
1204
+ table.field("name", node.name.inspect)
1205
+
1206
+ # name_loc
1207
+ table.field("name_loc", location_inspect(node.name_loc))
1208
+
1209
+ # operator_loc
1210
+ table.field("operator_loc", location_inspect(node.operator_loc))
1211
+
1212
+ # value
1213
+ table.field("value", port: true)
1214
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1215
+
1216
+ # operator
1217
+ table.field("operator", node.operator.inspect)
1218
+
1219
+ digraph.nodes << <<~DOT
1220
+ #{id} [
1221
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1222
+ ];
1223
+ DOT
1224
+
1225
+ super
1226
+ end
1227
+
1228
+ # Visit a ConstantOrWriteNode node.
1229
+ def visit_constant_or_write_node(node)
1230
+ table = Table.new("ConstantOrWriteNode")
1231
+ id = node_id(node)
1232
+
1233
+ # name
1234
+ table.field("name", node.name.inspect)
1235
+
1236
+ # name_loc
1237
+ table.field("name_loc", location_inspect(node.name_loc))
1238
+
1239
+ # operator_loc
1240
+ table.field("operator_loc", location_inspect(node.operator_loc))
1241
+
1242
+ # value
1243
+ table.field("value", port: true)
1244
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1245
+
1246
+ digraph.nodes << <<~DOT
1247
+ #{id} [
1248
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1249
+ ];
1250
+ DOT
1251
+
1252
+ super
1253
+ end
1254
+
1255
+ # Visit a ConstantPathAndWriteNode node.
1256
+ def visit_constant_path_and_write_node(node)
1257
+ table = Table.new("ConstantPathAndWriteNode")
1258
+ id = node_id(node)
1259
+
1260
+ # target
1261
+ table.field("target", port: true)
1262
+ digraph.edge("#{id}:target -> #{node_id(node.target)};")
1263
+
1264
+ # operator_loc
1265
+ table.field("operator_loc", location_inspect(node.operator_loc))
1266
+
1267
+ # value
1268
+ table.field("value", port: true)
1269
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1270
+
1271
+ digraph.nodes << <<~DOT
1272
+ #{id} [
1273
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1274
+ ];
1275
+ DOT
1276
+
1277
+ super
1278
+ end
1279
+
1280
+ # Visit a ConstantPathNode node.
1281
+ def visit_constant_path_node(node)
1282
+ table = Table.new("ConstantPathNode")
1283
+ id = node_id(node)
1284
+
1285
+ # parent
1286
+ unless (parent = node.parent).nil?
1287
+ table.field("parent", port: true)
1288
+ digraph.edge("#{id}:parent -> #{node_id(parent)};")
1289
+ end
1290
+
1291
+ # child
1292
+ table.field("child", port: true)
1293
+ digraph.edge("#{id}:child -> #{node_id(node.child)};")
1294
+
1295
+ # delimiter_loc
1296
+ table.field("delimiter_loc", location_inspect(node.delimiter_loc))
1297
+
1298
+ digraph.nodes << <<~DOT
1299
+ #{id} [
1300
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1301
+ ];
1302
+ DOT
1303
+
1304
+ super
1305
+ end
1306
+
1307
+ # Visit a ConstantPathOperatorWriteNode node.
1308
+ def visit_constant_path_operator_write_node(node)
1309
+ table = Table.new("ConstantPathOperatorWriteNode")
1310
+ id = node_id(node)
1311
+
1312
+ # target
1313
+ table.field("target", port: true)
1314
+ digraph.edge("#{id}:target -> #{node_id(node.target)};")
1315
+
1316
+ # operator_loc
1317
+ table.field("operator_loc", location_inspect(node.operator_loc))
1318
+
1319
+ # value
1320
+ table.field("value", port: true)
1321
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1322
+
1323
+ # operator
1324
+ table.field("operator", node.operator.inspect)
1325
+
1326
+ digraph.nodes << <<~DOT
1327
+ #{id} [
1328
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1329
+ ];
1330
+ DOT
1331
+
1332
+ super
1333
+ end
1334
+
1335
+ # Visit a ConstantPathOrWriteNode node.
1336
+ def visit_constant_path_or_write_node(node)
1337
+ table = Table.new("ConstantPathOrWriteNode")
1338
+ id = node_id(node)
1339
+
1340
+ # target
1341
+ table.field("target", port: true)
1342
+ digraph.edge("#{id}:target -> #{node_id(node.target)};")
1343
+
1344
+ # operator_loc
1345
+ table.field("operator_loc", location_inspect(node.operator_loc))
1346
+
1347
+ # value
1348
+ table.field("value", port: true)
1349
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1350
+
1351
+ digraph.nodes << <<~DOT
1352
+ #{id} [
1353
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1354
+ ];
1355
+ DOT
1356
+
1357
+ super
1358
+ end
1359
+
1360
+ # Visit a ConstantPathTargetNode node.
1361
+ def visit_constant_path_target_node(node)
1362
+ table = Table.new("ConstantPathTargetNode")
1363
+ id = node_id(node)
1364
+
1365
+ # parent
1366
+ unless (parent = node.parent).nil?
1367
+ table.field("parent", port: true)
1368
+ digraph.edge("#{id}:parent -> #{node_id(parent)};")
1369
+ end
1370
+
1371
+ # child
1372
+ table.field("child", port: true)
1373
+ digraph.edge("#{id}:child -> #{node_id(node.child)};")
1374
+
1375
+ # delimiter_loc
1376
+ table.field("delimiter_loc", location_inspect(node.delimiter_loc))
1377
+
1378
+ digraph.nodes << <<~DOT
1379
+ #{id} [
1380
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1381
+ ];
1382
+ DOT
1383
+
1384
+ super
1385
+ end
1386
+
1387
+ # Visit a ConstantPathWriteNode node.
1388
+ def visit_constant_path_write_node(node)
1389
+ table = Table.new("ConstantPathWriteNode")
1390
+ id = node_id(node)
1391
+
1392
+ # target
1393
+ table.field("target", port: true)
1394
+ digraph.edge("#{id}:target -> #{node_id(node.target)};")
1395
+
1396
+ # operator_loc
1397
+ table.field("operator_loc", location_inspect(node.operator_loc))
1398
+
1399
+ # value
1400
+ table.field("value", port: true)
1401
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1402
+
1403
+ digraph.nodes << <<~DOT
1404
+ #{id} [
1405
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1406
+ ];
1407
+ DOT
1408
+
1409
+ super
1410
+ end
1411
+
1412
+ # Visit a ConstantReadNode node.
1413
+ def visit_constant_read_node(node)
1414
+ table = Table.new("ConstantReadNode")
1415
+ id = node_id(node)
1416
+
1417
+ # name
1418
+ table.field("name", node.name.inspect)
1419
+
1420
+ digraph.nodes << <<~DOT
1421
+ #{id} [
1422
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1423
+ ];
1424
+ DOT
1425
+
1426
+ super
1427
+ end
1428
+
1429
+ # Visit a ConstantTargetNode node.
1430
+ def visit_constant_target_node(node)
1431
+ table = Table.new("ConstantTargetNode")
1432
+ id = node_id(node)
1433
+
1434
+ # name
1435
+ table.field("name", node.name.inspect)
1436
+
1437
+ digraph.nodes << <<~DOT
1438
+ #{id} [
1439
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1440
+ ];
1441
+ DOT
1442
+
1443
+ super
1444
+ end
1445
+
1446
+ # Visit a ConstantWriteNode node.
1447
+ def visit_constant_write_node(node)
1448
+ table = Table.new("ConstantWriteNode")
1449
+ id = node_id(node)
1450
+
1451
+ # name
1452
+ table.field("name", node.name.inspect)
1453
+
1454
+ # name_loc
1455
+ table.field("name_loc", location_inspect(node.name_loc))
1456
+
1457
+ # value
1458
+ table.field("value", port: true)
1459
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1460
+
1461
+ # operator_loc
1462
+ table.field("operator_loc", location_inspect(node.operator_loc))
1463
+
1464
+ digraph.nodes << <<~DOT
1465
+ #{id} [
1466
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1467
+ ];
1468
+ DOT
1469
+
1470
+ super
1471
+ end
1472
+
1473
+ # Visit a DefNode node.
1474
+ def visit_def_node(node)
1475
+ table = Table.new("DefNode")
1476
+ id = node_id(node)
1477
+
1478
+ # name
1479
+ table.field("name", node.name.inspect)
1480
+
1481
+ # name_loc
1482
+ table.field("name_loc", location_inspect(node.name_loc))
1483
+
1484
+ # receiver
1485
+ unless (receiver = node.receiver).nil?
1486
+ table.field("receiver", port: true)
1487
+ digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
1488
+ end
1489
+
1490
+ # parameters
1491
+ unless (parameters = node.parameters).nil?
1492
+ table.field("parameters", port: true)
1493
+ digraph.edge("#{id}:parameters -> #{node_id(parameters)};")
1494
+ end
1495
+
1496
+ # body
1497
+ unless (body = node.body).nil?
1498
+ table.field("body", port: true)
1499
+ digraph.edge("#{id}:body -> #{node_id(body)};")
1500
+ end
1501
+
1502
+ # locals
1503
+ table.field("locals", node.locals.inspect)
1504
+
1505
+ # def_keyword_loc
1506
+ table.field("def_keyword_loc", location_inspect(node.def_keyword_loc))
1507
+
1508
+ # operator_loc
1509
+ unless (operator_loc = node.operator_loc).nil?
1510
+ table.field("operator_loc", location_inspect(operator_loc))
1511
+ end
1512
+
1513
+ # lparen_loc
1514
+ unless (lparen_loc = node.lparen_loc).nil?
1515
+ table.field("lparen_loc", location_inspect(lparen_loc))
1516
+ end
1517
+
1518
+ # rparen_loc
1519
+ unless (rparen_loc = node.rparen_loc).nil?
1520
+ table.field("rparen_loc", location_inspect(rparen_loc))
1521
+ end
1522
+
1523
+ # equal_loc
1524
+ unless (equal_loc = node.equal_loc).nil?
1525
+ table.field("equal_loc", location_inspect(equal_loc))
1526
+ end
1527
+
1528
+ # end_keyword_loc
1529
+ unless (end_keyword_loc = node.end_keyword_loc).nil?
1530
+ table.field("end_keyword_loc", location_inspect(end_keyword_loc))
1531
+ end
1532
+
1533
+ digraph.nodes << <<~DOT
1534
+ #{id} [
1535
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1536
+ ];
1537
+ DOT
1538
+
1539
+ super
1540
+ end
1541
+
1542
+ # Visit a DefinedNode node.
1543
+ def visit_defined_node(node)
1544
+ table = Table.new("DefinedNode")
1545
+ id = node_id(node)
1546
+
1547
+ # lparen_loc
1548
+ unless (lparen_loc = node.lparen_loc).nil?
1549
+ table.field("lparen_loc", location_inspect(lparen_loc))
1550
+ end
1551
+
1552
+ # value
1553
+ table.field("value", port: true)
1554
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1555
+
1556
+ # rparen_loc
1557
+ unless (rparen_loc = node.rparen_loc).nil?
1558
+ table.field("rparen_loc", location_inspect(rparen_loc))
1559
+ end
1560
+
1561
+ # keyword_loc
1562
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
1563
+
1564
+ digraph.nodes << <<~DOT
1565
+ #{id} [
1566
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1567
+ ];
1568
+ DOT
1569
+
1570
+ super
1571
+ end
1572
+
1573
+ # Visit a ElseNode node.
1574
+ def visit_else_node(node)
1575
+ table = Table.new("ElseNode")
1576
+ id = node_id(node)
1577
+
1578
+ # else_keyword_loc
1579
+ table.field("else_keyword_loc", location_inspect(node.else_keyword_loc))
1580
+
1581
+ # statements
1582
+ unless (statements = node.statements).nil?
1583
+ table.field("statements", port: true)
1584
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
1585
+ end
1586
+
1587
+ # end_keyword_loc
1588
+ unless (end_keyword_loc = node.end_keyword_loc).nil?
1589
+ table.field("end_keyword_loc", location_inspect(end_keyword_loc))
1590
+ end
1591
+
1592
+ digraph.nodes << <<~DOT
1593
+ #{id} [
1594
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1595
+ ];
1596
+ DOT
1597
+
1598
+ super
1599
+ end
1600
+
1601
+ # Visit a EmbeddedStatementsNode node.
1602
+ def visit_embedded_statements_node(node)
1603
+ table = Table.new("EmbeddedStatementsNode")
1604
+ id = node_id(node)
1605
+
1606
+ # opening_loc
1607
+ table.field("opening_loc", location_inspect(node.opening_loc))
1608
+
1609
+ # statements
1610
+ unless (statements = node.statements).nil?
1611
+ table.field("statements", port: true)
1612
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
1613
+ end
1614
+
1615
+ # closing_loc
1616
+ table.field("closing_loc", location_inspect(node.closing_loc))
1617
+
1618
+ digraph.nodes << <<~DOT
1619
+ #{id} [
1620
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1621
+ ];
1622
+ DOT
1623
+
1624
+ super
1625
+ end
1626
+
1627
+ # Visit a EmbeddedVariableNode node.
1628
+ def visit_embedded_variable_node(node)
1629
+ table = Table.new("EmbeddedVariableNode")
1630
+ id = node_id(node)
1631
+
1632
+ # operator_loc
1633
+ table.field("operator_loc", location_inspect(node.operator_loc))
1634
+
1635
+ # variable
1636
+ table.field("variable", port: true)
1637
+ digraph.edge("#{id}:variable -> #{node_id(node.variable)};")
1638
+
1639
+ digraph.nodes << <<~DOT
1640
+ #{id} [
1641
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1642
+ ];
1643
+ DOT
1644
+
1645
+ super
1646
+ end
1647
+
1648
+ # Visit a EnsureNode node.
1649
+ def visit_ensure_node(node)
1650
+ table = Table.new("EnsureNode")
1651
+ id = node_id(node)
1652
+
1653
+ # ensure_keyword_loc
1654
+ table.field("ensure_keyword_loc", location_inspect(node.ensure_keyword_loc))
1655
+
1656
+ # statements
1657
+ unless (statements = node.statements).nil?
1658
+ table.field("statements", port: true)
1659
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
1660
+ end
1661
+
1662
+ # end_keyword_loc
1663
+ table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
1664
+
1665
+ digraph.nodes << <<~DOT
1666
+ #{id} [
1667
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1668
+ ];
1669
+ DOT
1670
+
1671
+ super
1672
+ end
1673
+
1674
+ # Visit a FalseNode node.
1675
+ def visit_false_node(node)
1676
+ table = Table.new("FalseNode")
1677
+ id = node_id(node)
1678
+
1679
+ digraph.nodes << <<~DOT
1680
+ #{id} [
1681
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1682
+ ];
1683
+ DOT
1684
+
1685
+ super
1686
+ end
1687
+
1688
+ # Visit a FindPatternNode node.
1689
+ def visit_find_pattern_node(node)
1690
+ table = Table.new("FindPatternNode")
1691
+ id = node_id(node)
1692
+
1693
+ # constant
1694
+ unless (constant = node.constant).nil?
1695
+ table.field("constant", port: true)
1696
+ digraph.edge("#{id}:constant -> #{node_id(constant)};")
1697
+ end
1698
+
1699
+ # left
1700
+ table.field("left", port: true)
1701
+ digraph.edge("#{id}:left -> #{node_id(node.left)};")
1702
+
1703
+ # requireds
1704
+ if node.requireds.any?
1705
+ table.field("requireds", port: true)
1706
+
1707
+ waypoint = "#{id}_requireds"
1708
+ digraph.waypoint("#{waypoint};")
1709
+
1710
+ digraph.edge("#{id}:requireds -> #{waypoint};")
1711
+ node.requireds.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
1712
+ else
1713
+ table.field("requireds", "[]")
1714
+ end
1715
+
1716
+ # right
1717
+ table.field("right", port: true)
1718
+ digraph.edge("#{id}:right -> #{node_id(node.right)};")
1719
+
1720
+ # opening_loc
1721
+ unless (opening_loc = node.opening_loc).nil?
1722
+ table.field("opening_loc", location_inspect(opening_loc))
1723
+ end
1724
+
1725
+ # closing_loc
1726
+ unless (closing_loc = node.closing_loc).nil?
1727
+ table.field("closing_loc", location_inspect(closing_loc))
1728
+ end
1729
+
1730
+ digraph.nodes << <<~DOT
1731
+ #{id} [
1732
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1733
+ ];
1734
+ DOT
1735
+
1736
+ super
1737
+ end
1738
+
1739
+ # Visit a FlipFlopNode node.
1740
+ def visit_flip_flop_node(node)
1741
+ table = Table.new("FlipFlopNode")
1742
+ id = node_id(node)
1743
+
1744
+ # flags
1745
+ table.field("flags", range_flags_inspect(node))
1746
+
1747
+ # left
1748
+ unless (left = node.left).nil?
1749
+ table.field("left", port: true)
1750
+ digraph.edge("#{id}:left -> #{node_id(left)};")
1751
+ end
1752
+
1753
+ # right
1754
+ unless (right = node.right).nil?
1755
+ table.field("right", port: true)
1756
+ digraph.edge("#{id}:right -> #{node_id(right)};")
1757
+ end
1758
+
1759
+ # operator_loc
1760
+ table.field("operator_loc", location_inspect(node.operator_loc))
1761
+
1762
+ digraph.nodes << <<~DOT
1763
+ #{id} [
1764
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1765
+ ];
1766
+ DOT
1767
+
1768
+ super
1769
+ end
1770
+
1771
+ # Visit a FloatNode node.
1772
+ def visit_float_node(node)
1773
+ table = Table.new("FloatNode")
1774
+ id = node_id(node)
1775
+
1776
+ digraph.nodes << <<~DOT
1777
+ #{id} [
1778
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1779
+ ];
1780
+ DOT
1781
+
1782
+ super
1783
+ end
1784
+
1785
+ # Visit a ForNode node.
1786
+ def visit_for_node(node)
1787
+ table = Table.new("ForNode")
1788
+ id = node_id(node)
1789
+
1790
+ # index
1791
+ table.field("index", port: true)
1792
+ digraph.edge("#{id}:index -> #{node_id(node.index)};")
1793
+
1794
+ # collection
1795
+ table.field("collection", port: true)
1796
+ digraph.edge("#{id}:collection -> #{node_id(node.collection)};")
1797
+
1798
+ # statements
1799
+ unless (statements = node.statements).nil?
1800
+ table.field("statements", port: true)
1801
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
1802
+ end
1803
+
1804
+ # for_keyword_loc
1805
+ table.field("for_keyword_loc", location_inspect(node.for_keyword_loc))
1806
+
1807
+ # in_keyword_loc
1808
+ table.field("in_keyword_loc", location_inspect(node.in_keyword_loc))
1809
+
1810
+ # do_keyword_loc
1811
+ unless (do_keyword_loc = node.do_keyword_loc).nil?
1812
+ table.field("do_keyword_loc", location_inspect(do_keyword_loc))
1813
+ end
1814
+
1815
+ # end_keyword_loc
1816
+ table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
1817
+
1818
+ digraph.nodes << <<~DOT
1819
+ #{id} [
1820
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1821
+ ];
1822
+ DOT
1823
+
1824
+ super
1825
+ end
1826
+
1827
+ # Visit a ForwardingArgumentsNode node.
1828
+ def visit_forwarding_arguments_node(node)
1829
+ table = Table.new("ForwardingArgumentsNode")
1830
+ id = node_id(node)
1831
+
1832
+ digraph.nodes << <<~DOT
1833
+ #{id} [
1834
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1835
+ ];
1836
+ DOT
1837
+
1838
+ super
1839
+ end
1840
+
1841
+ # Visit a ForwardingParameterNode node.
1842
+ def visit_forwarding_parameter_node(node)
1843
+ table = Table.new("ForwardingParameterNode")
1844
+ id = node_id(node)
1845
+
1846
+ digraph.nodes << <<~DOT
1847
+ #{id} [
1848
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1849
+ ];
1850
+ DOT
1851
+
1852
+ super
1853
+ end
1854
+
1855
+ # Visit a ForwardingSuperNode node.
1856
+ def visit_forwarding_super_node(node)
1857
+ table = Table.new("ForwardingSuperNode")
1858
+ id = node_id(node)
1859
+
1860
+ # block
1861
+ unless (block = node.block).nil?
1862
+ table.field("block", port: true)
1863
+ digraph.edge("#{id}:block -> #{node_id(block)};")
1864
+ end
1865
+
1866
+ digraph.nodes << <<~DOT
1867
+ #{id} [
1868
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1869
+ ];
1870
+ DOT
1871
+
1872
+ super
1873
+ end
1874
+
1875
+ # Visit a GlobalVariableAndWriteNode node.
1876
+ def visit_global_variable_and_write_node(node)
1877
+ table = Table.new("GlobalVariableAndWriteNode")
1878
+ id = node_id(node)
1879
+
1880
+ # name
1881
+ table.field("name", node.name.inspect)
1882
+
1883
+ # name_loc
1884
+ table.field("name_loc", location_inspect(node.name_loc))
1885
+
1886
+ # operator_loc
1887
+ table.field("operator_loc", location_inspect(node.operator_loc))
1888
+
1889
+ # value
1890
+ table.field("value", port: true)
1891
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1892
+
1893
+ digraph.nodes << <<~DOT
1894
+ #{id} [
1895
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1896
+ ];
1897
+ DOT
1898
+
1899
+ super
1900
+ end
1901
+
1902
+ # Visit a GlobalVariableOperatorWriteNode node.
1903
+ def visit_global_variable_operator_write_node(node)
1904
+ table = Table.new("GlobalVariableOperatorWriteNode")
1905
+ id = node_id(node)
1906
+
1907
+ # name
1908
+ table.field("name", node.name.inspect)
1909
+
1910
+ # name_loc
1911
+ table.field("name_loc", location_inspect(node.name_loc))
1912
+
1913
+ # operator_loc
1914
+ table.field("operator_loc", location_inspect(node.operator_loc))
1915
+
1916
+ # value
1917
+ table.field("value", port: true)
1918
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1919
+
1920
+ # operator
1921
+ table.field("operator", node.operator.inspect)
1922
+
1923
+ digraph.nodes << <<~DOT
1924
+ #{id} [
1925
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1926
+ ];
1927
+ DOT
1928
+
1929
+ super
1930
+ end
1931
+
1932
+ # Visit a GlobalVariableOrWriteNode node.
1933
+ def visit_global_variable_or_write_node(node)
1934
+ table = Table.new("GlobalVariableOrWriteNode")
1935
+ id = node_id(node)
1936
+
1937
+ # name
1938
+ table.field("name", node.name.inspect)
1939
+
1940
+ # name_loc
1941
+ table.field("name_loc", location_inspect(node.name_loc))
1942
+
1943
+ # operator_loc
1944
+ table.field("operator_loc", location_inspect(node.operator_loc))
1945
+
1946
+ # value
1947
+ table.field("value", port: true)
1948
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
1949
+
1950
+ digraph.nodes << <<~DOT
1951
+ #{id} [
1952
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1953
+ ];
1954
+ DOT
1955
+
1956
+ super
1957
+ end
1958
+
1959
+ # Visit a GlobalVariableReadNode node.
1960
+ def visit_global_variable_read_node(node)
1961
+ table = Table.new("GlobalVariableReadNode")
1962
+ id = node_id(node)
1963
+
1964
+ # name
1965
+ table.field("name", node.name.inspect)
1966
+
1967
+ digraph.nodes << <<~DOT
1968
+ #{id} [
1969
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1970
+ ];
1971
+ DOT
1972
+
1973
+ super
1974
+ end
1975
+
1976
+ # Visit a GlobalVariableTargetNode node.
1977
+ def visit_global_variable_target_node(node)
1978
+ table = Table.new("GlobalVariableTargetNode")
1979
+ id = node_id(node)
1980
+
1981
+ # name
1982
+ table.field("name", node.name.inspect)
1983
+
1984
+ digraph.nodes << <<~DOT
1985
+ #{id} [
1986
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1987
+ ];
1988
+ DOT
1989
+
1990
+ super
1991
+ end
1992
+
1993
+ # Visit a GlobalVariableWriteNode node.
1994
+ def visit_global_variable_write_node(node)
1995
+ table = Table.new("GlobalVariableWriteNode")
1996
+ id = node_id(node)
1997
+
1998
+ # name
1999
+ table.field("name", node.name.inspect)
2000
+
2001
+ # name_loc
2002
+ table.field("name_loc", location_inspect(node.name_loc))
2003
+
2004
+ # value
2005
+ table.field("value", port: true)
2006
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
2007
+
2008
+ # operator_loc
2009
+ table.field("operator_loc", location_inspect(node.operator_loc))
2010
+
2011
+ digraph.nodes << <<~DOT
2012
+ #{id} [
2013
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2014
+ ];
2015
+ DOT
2016
+
2017
+ super
2018
+ end
2019
+
2020
+ # Visit a HashNode node.
2021
+ def visit_hash_node(node)
2022
+ table = Table.new("HashNode")
2023
+ id = node_id(node)
2024
+
2025
+ # opening_loc
2026
+ table.field("opening_loc", location_inspect(node.opening_loc))
2027
+
2028
+ # elements
2029
+ if node.elements.any?
2030
+ table.field("elements", port: true)
2031
+
2032
+ waypoint = "#{id}_elements"
2033
+ digraph.waypoint("#{waypoint};")
2034
+
2035
+ digraph.edge("#{id}:elements -> #{waypoint};")
2036
+ node.elements.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2037
+ else
2038
+ table.field("elements", "[]")
2039
+ end
2040
+
2041
+ # closing_loc
2042
+ table.field("closing_loc", location_inspect(node.closing_loc))
2043
+
2044
+ digraph.nodes << <<~DOT
2045
+ #{id} [
2046
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2047
+ ];
2048
+ DOT
2049
+
2050
+ super
2051
+ end
2052
+
2053
+ # Visit a HashPatternNode node.
2054
+ def visit_hash_pattern_node(node)
2055
+ table = Table.new("HashPatternNode")
2056
+ id = node_id(node)
2057
+
2058
+ # constant
2059
+ unless (constant = node.constant).nil?
2060
+ table.field("constant", port: true)
2061
+ digraph.edge("#{id}:constant -> #{node_id(constant)};")
2062
+ end
2063
+
2064
+ # elements
2065
+ if node.elements.any?
2066
+ table.field("elements", port: true)
2067
+
2068
+ waypoint = "#{id}_elements"
2069
+ digraph.waypoint("#{waypoint};")
2070
+
2071
+ digraph.edge("#{id}:elements -> #{waypoint};")
2072
+ node.elements.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2073
+ else
2074
+ table.field("elements", "[]")
2075
+ end
2076
+
2077
+ # rest
2078
+ unless (rest = node.rest).nil?
2079
+ table.field("rest", port: true)
2080
+ digraph.edge("#{id}:rest -> #{node_id(rest)};")
2081
+ end
2082
+
2083
+ # opening_loc
2084
+ unless (opening_loc = node.opening_loc).nil?
2085
+ table.field("opening_loc", location_inspect(opening_loc))
2086
+ end
2087
+
2088
+ # closing_loc
2089
+ unless (closing_loc = node.closing_loc).nil?
2090
+ table.field("closing_loc", location_inspect(closing_loc))
2091
+ end
2092
+
2093
+ digraph.nodes << <<~DOT
2094
+ #{id} [
2095
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2096
+ ];
2097
+ DOT
2098
+
2099
+ super
2100
+ end
2101
+
2102
+ # Visit a IfNode node.
2103
+ def visit_if_node(node)
2104
+ table = Table.new("IfNode")
2105
+ id = node_id(node)
2106
+
2107
+ # if_keyword_loc
2108
+ unless (if_keyword_loc = node.if_keyword_loc).nil?
2109
+ table.field("if_keyword_loc", location_inspect(if_keyword_loc))
2110
+ end
2111
+
2112
+ # predicate
2113
+ table.field("predicate", port: true)
2114
+ digraph.edge("#{id}:predicate -> #{node_id(node.predicate)};")
2115
+
2116
+ # then_keyword_loc
2117
+ unless (then_keyword_loc = node.then_keyword_loc).nil?
2118
+ table.field("then_keyword_loc", location_inspect(then_keyword_loc))
2119
+ end
2120
+
2121
+ # statements
2122
+ unless (statements = node.statements).nil?
2123
+ table.field("statements", port: true)
2124
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
2125
+ end
2126
+
2127
+ # consequent
2128
+ unless (consequent = node.consequent).nil?
2129
+ table.field("consequent", port: true)
2130
+ digraph.edge("#{id}:consequent -> #{node_id(consequent)};")
2131
+ end
2132
+
2133
+ # end_keyword_loc
2134
+ unless (end_keyword_loc = node.end_keyword_loc).nil?
2135
+ table.field("end_keyword_loc", location_inspect(end_keyword_loc))
2136
+ end
2137
+
2138
+ digraph.nodes << <<~DOT
2139
+ #{id} [
2140
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2141
+ ];
2142
+ DOT
2143
+
2144
+ super
2145
+ end
2146
+
2147
+ # Visit a ImaginaryNode node.
2148
+ def visit_imaginary_node(node)
2149
+ table = Table.new("ImaginaryNode")
2150
+ id = node_id(node)
2151
+
2152
+ # numeric
2153
+ table.field("numeric", port: true)
2154
+ digraph.edge("#{id}:numeric -> #{node_id(node.numeric)};")
2155
+
2156
+ digraph.nodes << <<~DOT
2157
+ #{id} [
2158
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2159
+ ];
2160
+ DOT
2161
+
2162
+ super
2163
+ end
2164
+
2165
+ # Visit a ImplicitNode node.
2166
+ def visit_implicit_node(node)
2167
+ table = Table.new("ImplicitNode")
2168
+ id = node_id(node)
2169
+
2170
+ # value
2171
+ table.field("value", port: true)
2172
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
2173
+
2174
+ digraph.nodes << <<~DOT
2175
+ #{id} [
2176
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2177
+ ];
2178
+ DOT
2179
+
2180
+ super
2181
+ end
2182
+
2183
+ # Visit a ImplicitRestNode node.
2184
+ def visit_implicit_rest_node(node)
2185
+ table = Table.new("ImplicitRestNode")
2186
+ id = node_id(node)
2187
+
2188
+ digraph.nodes << <<~DOT
2189
+ #{id} [
2190
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2191
+ ];
2192
+ DOT
2193
+
2194
+ super
2195
+ end
2196
+
2197
+ # Visit a InNode node.
2198
+ def visit_in_node(node)
2199
+ table = Table.new("InNode")
2200
+ id = node_id(node)
2201
+
2202
+ # pattern
2203
+ table.field("pattern", port: true)
2204
+ digraph.edge("#{id}:pattern -> #{node_id(node.pattern)};")
2205
+
2206
+ # statements
2207
+ unless (statements = node.statements).nil?
2208
+ table.field("statements", port: true)
2209
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
2210
+ end
2211
+
2212
+ # in_loc
2213
+ table.field("in_loc", location_inspect(node.in_loc))
2214
+
2215
+ # then_loc
2216
+ unless (then_loc = node.then_loc).nil?
2217
+ table.field("then_loc", location_inspect(then_loc))
2218
+ end
2219
+
2220
+ digraph.nodes << <<~DOT
2221
+ #{id} [
2222
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2223
+ ];
2224
+ DOT
2225
+
2226
+ super
2227
+ end
2228
+
2229
+ # Visit a IndexAndWriteNode node.
2230
+ def visit_index_and_write_node(node)
2231
+ table = Table.new("IndexAndWriteNode")
2232
+ id = node_id(node)
2233
+
2234
+ # flags
2235
+ table.field("flags", call_node_flags_inspect(node))
2236
+
2237
+ # receiver
2238
+ unless (receiver = node.receiver).nil?
2239
+ table.field("receiver", port: true)
2240
+ digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
2241
+ end
2242
+
2243
+ # call_operator_loc
2244
+ unless (call_operator_loc = node.call_operator_loc).nil?
2245
+ table.field("call_operator_loc", location_inspect(call_operator_loc))
2246
+ end
2247
+
2248
+ # opening_loc
2249
+ table.field("opening_loc", location_inspect(node.opening_loc))
2250
+
2251
+ # arguments
2252
+ unless (arguments = node.arguments).nil?
2253
+ table.field("arguments", port: true)
2254
+ digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
2255
+ end
2256
+
2257
+ # closing_loc
2258
+ table.field("closing_loc", location_inspect(node.closing_loc))
2259
+
2260
+ # block
2261
+ unless (block = node.block).nil?
2262
+ table.field("block", port: true)
2263
+ digraph.edge("#{id}:block -> #{node_id(block)};")
2264
+ end
2265
+
2266
+ # operator_loc
2267
+ table.field("operator_loc", location_inspect(node.operator_loc))
2268
+
2269
+ # value
2270
+ table.field("value", port: true)
2271
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
2272
+
2273
+ digraph.nodes << <<~DOT
2274
+ #{id} [
2275
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2276
+ ];
2277
+ DOT
2278
+
2279
+ super
2280
+ end
2281
+
2282
+ # Visit a IndexOperatorWriteNode node.
2283
+ def visit_index_operator_write_node(node)
2284
+ table = Table.new("IndexOperatorWriteNode")
2285
+ id = node_id(node)
2286
+
2287
+ # flags
2288
+ table.field("flags", call_node_flags_inspect(node))
2289
+
2290
+ # receiver
2291
+ unless (receiver = node.receiver).nil?
2292
+ table.field("receiver", port: true)
2293
+ digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
2294
+ end
2295
+
2296
+ # call_operator_loc
2297
+ unless (call_operator_loc = node.call_operator_loc).nil?
2298
+ table.field("call_operator_loc", location_inspect(call_operator_loc))
2299
+ end
2300
+
2301
+ # opening_loc
2302
+ table.field("opening_loc", location_inspect(node.opening_loc))
2303
+
2304
+ # arguments
2305
+ unless (arguments = node.arguments).nil?
2306
+ table.field("arguments", port: true)
2307
+ digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
2308
+ end
2309
+
2310
+ # closing_loc
2311
+ table.field("closing_loc", location_inspect(node.closing_loc))
2312
+
2313
+ # block
2314
+ unless (block = node.block).nil?
2315
+ table.field("block", port: true)
2316
+ digraph.edge("#{id}:block -> #{node_id(block)};")
2317
+ end
2318
+
2319
+ # operator
2320
+ table.field("operator", node.operator.inspect)
2321
+
2322
+ # operator_loc
2323
+ table.field("operator_loc", location_inspect(node.operator_loc))
2324
+
2325
+ # value
2326
+ table.field("value", port: true)
2327
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
2328
+
2329
+ digraph.nodes << <<~DOT
2330
+ #{id} [
2331
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2332
+ ];
2333
+ DOT
2334
+
2335
+ super
2336
+ end
2337
+
2338
+ # Visit a IndexOrWriteNode node.
2339
+ def visit_index_or_write_node(node)
2340
+ table = Table.new("IndexOrWriteNode")
2341
+ id = node_id(node)
2342
+
2343
+ # flags
2344
+ table.field("flags", call_node_flags_inspect(node))
2345
+
2346
+ # receiver
2347
+ unless (receiver = node.receiver).nil?
2348
+ table.field("receiver", port: true)
2349
+ digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
2350
+ end
2351
+
2352
+ # call_operator_loc
2353
+ unless (call_operator_loc = node.call_operator_loc).nil?
2354
+ table.field("call_operator_loc", location_inspect(call_operator_loc))
2355
+ end
2356
+
2357
+ # opening_loc
2358
+ table.field("opening_loc", location_inspect(node.opening_loc))
2359
+
2360
+ # arguments
2361
+ unless (arguments = node.arguments).nil?
2362
+ table.field("arguments", port: true)
2363
+ digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
2364
+ end
2365
+
2366
+ # closing_loc
2367
+ table.field("closing_loc", location_inspect(node.closing_loc))
2368
+
2369
+ # block
2370
+ unless (block = node.block).nil?
2371
+ table.field("block", port: true)
2372
+ digraph.edge("#{id}:block -> #{node_id(block)};")
2373
+ end
2374
+
2375
+ # operator_loc
2376
+ table.field("operator_loc", location_inspect(node.operator_loc))
2377
+
2378
+ # value
2379
+ table.field("value", port: true)
2380
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
2381
+
2382
+ digraph.nodes << <<~DOT
2383
+ #{id} [
2384
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2385
+ ];
2386
+ DOT
2387
+
2388
+ super
2389
+ end
2390
+
2391
+ # Visit a IndexTargetNode node.
2392
+ def visit_index_target_node(node)
2393
+ table = Table.new("IndexTargetNode")
2394
+ id = node_id(node)
2395
+
2396
+ # flags
2397
+ table.field("flags", call_node_flags_inspect(node))
2398
+
2399
+ # receiver
2400
+ table.field("receiver", port: true)
2401
+ digraph.edge("#{id}:receiver -> #{node_id(node.receiver)};")
2402
+
2403
+ # opening_loc
2404
+ table.field("opening_loc", location_inspect(node.opening_loc))
2405
+
2406
+ # arguments
2407
+ unless (arguments = node.arguments).nil?
2408
+ table.field("arguments", port: true)
2409
+ digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
2410
+ end
2411
+
2412
+ # closing_loc
2413
+ table.field("closing_loc", location_inspect(node.closing_loc))
2414
+
2415
+ # block
2416
+ unless (block = node.block).nil?
2417
+ table.field("block", port: true)
2418
+ digraph.edge("#{id}:block -> #{node_id(block)};")
2419
+ end
2420
+
2421
+ digraph.nodes << <<~DOT
2422
+ #{id} [
2423
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2424
+ ];
2425
+ DOT
2426
+
2427
+ super
2428
+ end
2429
+
2430
+ # Visit a InstanceVariableAndWriteNode node.
2431
+ def visit_instance_variable_and_write_node(node)
2432
+ table = Table.new("InstanceVariableAndWriteNode")
2433
+ id = node_id(node)
2434
+
2435
+ # name
2436
+ table.field("name", node.name.inspect)
2437
+
2438
+ # name_loc
2439
+ table.field("name_loc", location_inspect(node.name_loc))
2440
+
2441
+ # operator_loc
2442
+ table.field("operator_loc", location_inspect(node.operator_loc))
2443
+
2444
+ # value
2445
+ table.field("value", port: true)
2446
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
2447
+
2448
+ digraph.nodes << <<~DOT
2449
+ #{id} [
2450
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2451
+ ];
2452
+ DOT
2453
+
2454
+ super
2455
+ end
2456
+
2457
+ # Visit a InstanceVariableOperatorWriteNode node.
2458
+ def visit_instance_variable_operator_write_node(node)
2459
+ table = Table.new("InstanceVariableOperatorWriteNode")
2460
+ id = node_id(node)
2461
+
2462
+ # name
2463
+ table.field("name", node.name.inspect)
2464
+
2465
+ # name_loc
2466
+ table.field("name_loc", location_inspect(node.name_loc))
2467
+
2468
+ # operator_loc
2469
+ table.field("operator_loc", location_inspect(node.operator_loc))
2470
+
2471
+ # value
2472
+ table.field("value", port: true)
2473
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
2474
+
2475
+ # operator
2476
+ table.field("operator", node.operator.inspect)
2477
+
2478
+ digraph.nodes << <<~DOT
2479
+ #{id} [
2480
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2481
+ ];
2482
+ DOT
2483
+
2484
+ super
2485
+ end
2486
+
2487
+ # Visit a InstanceVariableOrWriteNode node.
2488
+ def visit_instance_variable_or_write_node(node)
2489
+ table = Table.new("InstanceVariableOrWriteNode")
2490
+ id = node_id(node)
2491
+
2492
+ # name
2493
+ table.field("name", node.name.inspect)
2494
+
2495
+ # name_loc
2496
+ table.field("name_loc", location_inspect(node.name_loc))
2497
+
2498
+ # operator_loc
2499
+ table.field("operator_loc", location_inspect(node.operator_loc))
2500
+
2501
+ # value
2502
+ table.field("value", port: true)
2503
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
2504
+
2505
+ digraph.nodes << <<~DOT
2506
+ #{id} [
2507
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2508
+ ];
2509
+ DOT
2510
+
2511
+ super
2512
+ end
2513
+
2514
+ # Visit a InstanceVariableReadNode node.
2515
+ def visit_instance_variable_read_node(node)
2516
+ table = Table.new("InstanceVariableReadNode")
2517
+ id = node_id(node)
2518
+
2519
+ # name
2520
+ table.field("name", node.name.inspect)
2521
+
2522
+ digraph.nodes << <<~DOT
2523
+ #{id} [
2524
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2525
+ ];
2526
+ DOT
2527
+
2528
+ super
2529
+ end
2530
+
2531
+ # Visit a InstanceVariableTargetNode node.
2532
+ def visit_instance_variable_target_node(node)
2533
+ table = Table.new("InstanceVariableTargetNode")
2534
+ id = node_id(node)
2535
+
2536
+ # name
2537
+ table.field("name", node.name.inspect)
2538
+
2539
+ digraph.nodes << <<~DOT
2540
+ #{id} [
2541
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2542
+ ];
2543
+ DOT
2544
+
2545
+ super
2546
+ end
2547
+
2548
+ # Visit a InstanceVariableWriteNode node.
2549
+ def visit_instance_variable_write_node(node)
2550
+ table = Table.new("InstanceVariableWriteNode")
2551
+ id = node_id(node)
2552
+
2553
+ # name
2554
+ table.field("name", node.name.inspect)
2555
+
2556
+ # name_loc
2557
+ table.field("name_loc", location_inspect(node.name_loc))
2558
+
2559
+ # value
2560
+ table.field("value", port: true)
2561
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
2562
+
2563
+ # operator_loc
2564
+ table.field("operator_loc", location_inspect(node.operator_loc))
2565
+
2566
+ digraph.nodes << <<~DOT
2567
+ #{id} [
2568
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2569
+ ];
2570
+ DOT
2571
+
2572
+ super
2573
+ end
2574
+
2575
+ # Visit a IntegerNode node.
2576
+ def visit_integer_node(node)
2577
+ table = Table.new("IntegerNode")
2578
+ id = node_id(node)
2579
+
2580
+ # flags
2581
+ table.field("flags", integer_base_flags_inspect(node))
2582
+
2583
+ digraph.nodes << <<~DOT
2584
+ #{id} [
2585
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2586
+ ];
2587
+ DOT
2588
+
2589
+ super
2590
+ end
2591
+
2592
+ # Visit a InterpolatedMatchLastLineNode node.
2593
+ def visit_interpolated_match_last_line_node(node)
2594
+ table = Table.new("InterpolatedMatchLastLineNode")
2595
+ id = node_id(node)
2596
+
2597
+ # flags
2598
+ table.field("flags", regular_expression_flags_inspect(node))
2599
+
2600
+ # opening_loc
2601
+ table.field("opening_loc", location_inspect(node.opening_loc))
2602
+
2603
+ # parts
2604
+ if node.parts.any?
2605
+ table.field("parts", port: true)
2606
+
2607
+ waypoint = "#{id}_parts"
2608
+ digraph.waypoint("#{waypoint};")
2609
+
2610
+ digraph.edge("#{id}:parts -> #{waypoint};")
2611
+ node.parts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2612
+ else
2613
+ table.field("parts", "[]")
2614
+ end
2615
+
2616
+ # closing_loc
2617
+ table.field("closing_loc", location_inspect(node.closing_loc))
2618
+
2619
+ digraph.nodes << <<~DOT
2620
+ #{id} [
2621
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2622
+ ];
2623
+ DOT
2624
+
2625
+ super
2626
+ end
2627
+
2628
+ # Visit a InterpolatedRegularExpressionNode node.
2629
+ def visit_interpolated_regular_expression_node(node)
2630
+ table = Table.new("InterpolatedRegularExpressionNode")
2631
+ id = node_id(node)
2632
+
2633
+ # flags
2634
+ table.field("flags", regular_expression_flags_inspect(node))
2635
+
2636
+ # opening_loc
2637
+ table.field("opening_loc", location_inspect(node.opening_loc))
2638
+
2639
+ # parts
2640
+ if node.parts.any?
2641
+ table.field("parts", port: true)
2642
+
2643
+ waypoint = "#{id}_parts"
2644
+ digraph.waypoint("#{waypoint};")
2645
+
2646
+ digraph.edge("#{id}:parts -> #{waypoint};")
2647
+ node.parts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2648
+ else
2649
+ table.field("parts", "[]")
2650
+ end
2651
+
2652
+ # closing_loc
2653
+ table.field("closing_loc", location_inspect(node.closing_loc))
2654
+
2655
+ digraph.nodes << <<~DOT
2656
+ #{id} [
2657
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2658
+ ];
2659
+ DOT
2660
+
2661
+ super
2662
+ end
2663
+
2664
+ # Visit a InterpolatedStringNode node.
2665
+ def visit_interpolated_string_node(node)
2666
+ table = Table.new("InterpolatedStringNode")
2667
+ id = node_id(node)
2668
+
2669
+ # opening_loc
2670
+ unless (opening_loc = node.opening_loc).nil?
2671
+ table.field("opening_loc", location_inspect(opening_loc))
2672
+ end
2673
+
2674
+ # parts
2675
+ if node.parts.any?
2676
+ table.field("parts", port: true)
2677
+
2678
+ waypoint = "#{id}_parts"
2679
+ digraph.waypoint("#{waypoint};")
2680
+
2681
+ digraph.edge("#{id}:parts -> #{waypoint};")
2682
+ node.parts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2683
+ else
2684
+ table.field("parts", "[]")
2685
+ end
2686
+
2687
+ # closing_loc
2688
+ unless (closing_loc = node.closing_loc).nil?
2689
+ table.field("closing_loc", location_inspect(closing_loc))
2690
+ end
2691
+
2692
+ digraph.nodes << <<~DOT
2693
+ #{id} [
2694
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2695
+ ];
2696
+ DOT
2697
+
2698
+ super
2699
+ end
2700
+
2701
+ # Visit a InterpolatedSymbolNode node.
2702
+ def visit_interpolated_symbol_node(node)
2703
+ table = Table.new("InterpolatedSymbolNode")
2704
+ id = node_id(node)
2705
+
2706
+ # opening_loc
2707
+ unless (opening_loc = node.opening_loc).nil?
2708
+ table.field("opening_loc", location_inspect(opening_loc))
2709
+ end
2710
+
2711
+ # parts
2712
+ if node.parts.any?
2713
+ table.field("parts", port: true)
2714
+
2715
+ waypoint = "#{id}_parts"
2716
+ digraph.waypoint("#{waypoint};")
2717
+
2718
+ digraph.edge("#{id}:parts -> #{waypoint};")
2719
+ node.parts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2720
+ else
2721
+ table.field("parts", "[]")
2722
+ end
2723
+
2724
+ # closing_loc
2725
+ unless (closing_loc = node.closing_loc).nil?
2726
+ table.field("closing_loc", location_inspect(closing_loc))
2727
+ end
2728
+
2729
+ digraph.nodes << <<~DOT
2730
+ #{id} [
2731
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2732
+ ];
2733
+ DOT
2734
+
2735
+ super
2736
+ end
2737
+
2738
+ # Visit a InterpolatedXStringNode node.
2739
+ def visit_interpolated_x_string_node(node)
2740
+ table = Table.new("InterpolatedXStringNode")
2741
+ id = node_id(node)
2742
+
2743
+ # opening_loc
2744
+ table.field("opening_loc", location_inspect(node.opening_loc))
2745
+
2746
+ # parts
2747
+ if node.parts.any?
2748
+ table.field("parts", port: true)
2749
+
2750
+ waypoint = "#{id}_parts"
2751
+ digraph.waypoint("#{waypoint};")
2752
+
2753
+ digraph.edge("#{id}:parts -> #{waypoint};")
2754
+ node.parts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2755
+ else
2756
+ table.field("parts", "[]")
2757
+ end
2758
+
2759
+ # closing_loc
2760
+ table.field("closing_loc", location_inspect(node.closing_loc))
2761
+
2762
+ digraph.nodes << <<~DOT
2763
+ #{id} [
2764
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2765
+ ];
2766
+ DOT
2767
+
2768
+ super
2769
+ end
2770
+
2771
+ # Visit a KeywordHashNode node.
2772
+ def visit_keyword_hash_node(node)
2773
+ table = Table.new("KeywordHashNode")
2774
+ id = node_id(node)
2775
+
2776
+ # flags
2777
+ table.field("flags", keyword_hash_node_flags_inspect(node))
2778
+
2779
+ # elements
2780
+ if node.elements.any?
2781
+ table.field("elements", port: true)
2782
+
2783
+ waypoint = "#{id}_elements"
2784
+ digraph.waypoint("#{waypoint};")
2785
+
2786
+ digraph.edge("#{id}:elements -> #{waypoint};")
2787
+ node.elements.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2788
+ else
2789
+ table.field("elements", "[]")
2790
+ end
2791
+
2792
+ digraph.nodes << <<~DOT
2793
+ #{id} [
2794
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2795
+ ];
2796
+ DOT
2797
+
2798
+ super
2799
+ end
2800
+
2801
+ # Visit a KeywordRestParameterNode node.
2802
+ def visit_keyword_rest_parameter_node(node)
2803
+ table = Table.new("KeywordRestParameterNode")
2804
+ id = node_id(node)
2805
+
2806
+ # flags
2807
+ table.field("flags", parameter_flags_inspect(node))
2808
+
2809
+ # name
2810
+ table.field("name", node.name.inspect)
2811
+
2812
+ # name_loc
2813
+ unless (name_loc = node.name_loc).nil?
2814
+ table.field("name_loc", location_inspect(name_loc))
2815
+ end
2816
+
2817
+ # operator_loc
2818
+ table.field("operator_loc", location_inspect(node.operator_loc))
2819
+
2820
+ digraph.nodes << <<~DOT
2821
+ #{id} [
2822
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2823
+ ];
2824
+ DOT
2825
+
2826
+ super
2827
+ end
2828
+
2829
+ # Visit a LambdaNode node.
2830
+ def visit_lambda_node(node)
2831
+ table = Table.new("LambdaNode")
2832
+ id = node_id(node)
2833
+
2834
+ # locals
2835
+ table.field("locals", node.locals.inspect)
2836
+
2837
+ # operator_loc
2838
+ table.field("operator_loc", location_inspect(node.operator_loc))
2839
+
2840
+ # opening_loc
2841
+ table.field("opening_loc", location_inspect(node.opening_loc))
2842
+
2843
+ # closing_loc
2844
+ table.field("closing_loc", location_inspect(node.closing_loc))
2845
+
2846
+ # parameters
2847
+ unless (parameters = node.parameters).nil?
2848
+ table.field("parameters", port: true)
2849
+ digraph.edge("#{id}:parameters -> #{node_id(parameters)};")
2850
+ end
2851
+
2852
+ # body
2853
+ unless (body = node.body).nil?
2854
+ table.field("body", port: true)
2855
+ digraph.edge("#{id}:body -> #{node_id(body)};")
2856
+ end
2857
+
2858
+ digraph.nodes << <<~DOT
2859
+ #{id} [
2860
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2861
+ ];
2862
+ DOT
2863
+
2864
+ super
2865
+ end
2866
+
2867
+ # Visit a LocalVariableAndWriteNode node.
2868
+ def visit_local_variable_and_write_node(node)
2869
+ table = Table.new("LocalVariableAndWriteNode")
2870
+ id = node_id(node)
2871
+
2872
+ # name_loc
2873
+ table.field("name_loc", location_inspect(node.name_loc))
2874
+
2875
+ # operator_loc
2876
+ table.field("operator_loc", location_inspect(node.operator_loc))
2877
+
2878
+ # value
2879
+ table.field("value", port: true)
2880
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
2881
+
2882
+ # name
2883
+ table.field("name", node.name.inspect)
2884
+
2885
+ # depth
2886
+ table.field("depth", node.depth.inspect)
2887
+
2888
+ digraph.nodes << <<~DOT
2889
+ #{id} [
2890
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2891
+ ];
2892
+ DOT
2893
+
2894
+ super
2895
+ end
2896
+
2897
+ # Visit a LocalVariableOperatorWriteNode node.
2898
+ def visit_local_variable_operator_write_node(node)
2899
+ table = Table.new("LocalVariableOperatorWriteNode")
2900
+ id = node_id(node)
2901
+
2902
+ # name_loc
2903
+ table.field("name_loc", location_inspect(node.name_loc))
2904
+
2905
+ # operator_loc
2906
+ table.field("operator_loc", location_inspect(node.operator_loc))
2907
+
2908
+ # value
2909
+ table.field("value", port: true)
2910
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
2911
+
2912
+ # name
2913
+ table.field("name", node.name.inspect)
2914
+
2915
+ # operator
2916
+ table.field("operator", node.operator.inspect)
2917
+
2918
+ # depth
2919
+ table.field("depth", node.depth.inspect)
2920
+
2921
+ digraph.nodes << <<~DOT
2922
+ #{id} [
2923
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2924
+ ];
2925
+ DOT
2926
+
2927
+ super
2928
+ end
2929
+
2930
+ # Visit a LocalVariableOrWriteNode node.
2931
+ def visit_local_variable_or_write_node(node)
2932
+ table = Table.new("LocalVariableOrWriteNode")
2933
+ id = node_id(node)
2934
+
2935
+ # name_loc
2936
+ table.field("name_loc", location_inspect(node.name_loc))
2937
+
2938
+ # operator_loc
2939
+ table.field("operator_loc", location_inspect(node.operator_loc))
2940
+
2941
+ # value
2942
+ table.field("value", port: true)
2943
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
2944
+
2945
+ # name
2946
+ table.field("name", node.name.inspect)
2947
+
2948
+ # depth
2949
+ table.field("depth", node.depth.inspect)
2950
+
2951
+ digraph.nodes << <<~DOT
2952
+ #{id} [
2953
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2954
+ ];
2955
+ DOT
2956
+
2957
+ super
2958
+ end
2959
+
2960
+ # Visit a LocalVariableReadNode node.
2961
+ def visit_local_variable_read_node(node)
2962
+ table = Table.new("LocalVariableReadNode")
2963
+ id = node_id(node)
2964
+
2965
+ # name
2966
+ table.field("name", node.name.inspect)
2967
+
2968
+ # depth
2969
+ table.field("depth", node.depth.inspect)
2970
+
2971
+ digraph.nodes << <<~DOT
2972
+ #{id} [
2973
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2974
+ ];
2975
+ DOT
2976
+
2977
+ super
2978
+ end
2979
+
2980
+ # Visit a LocalVariableTargetNode node.
2981
+ def visit_local_variable_target_node(node)
2982
+ table = Table.new("LocalVariableTargetNode")
2983
+ id = node_id(node)
2984
+
2985
+ # name
2986
+ table.field("name", node.name.inspect)
2987
+
2988
+ # depth
2989
+ table.field("depth", node.depth.inspect)
2990
+
2991
+ digraph.nodes << <<~DOT
2992
+ #{id} [
2993
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2994
+ ];
2995
+ DOT
2996
+
2997
+ super
2998
+ end
2999
+
3000
+ # Visit a LocalVariableWriteNode node.
3001
+ def visit_local_variable_write_node(node)
3002
+ table = Table.new("LocalVariableWriteNode")
3003
+ id = node_id(node)
3004
+
3005
+ # name
3006
+ table.field("name", node.name.inspect)
3007
+
3008
+ # depth
3009
+ table.field("depth", node.depth.inspect)
3010
+
3011
+ # name_loc
3012
+ table.field("name_loc", location_inspect(node.name_loc))
3013
+
3014
+ # value
3015
+ table.field("value", port: true)
3016
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
3017
+
3018
+ # operator_loc
3019
+ table.field("operator_loc", location_inspect(node.operator_loc))
3020
+
3021
+ digraph.nodes << <<~DOT
3022
+ #{id} [
3023
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3024
+ ];
3025
+ DOT
3026
+
3027
+ super
3028
+ end
3029
+
3030
+ # Visit a MatchLastLineNode node.
3031
+ def visit_match_last_line_node(node)
3032
+ table = Table.new("MatchLastLineNode")
3033
+ id = node_id(node)
3034
+
3035
+ # flags
3036
+ table.field("flags", regular_expression_flags_inspect(node))
3037
+
3038
+ # opening_loc
3039
+ table.field("opening_loc", location_inspect(node.opening_loc))
3040
+
3041
+ # content_loc
3042
+ table.field("content_loc", location_inspect(node.content_loc))
3043
+
3044
+ # closing_loc
3045
+ table.field("closing_loc", location_inspect(node.closing_loc))
3046
+
3047
+ # unescaped
3048
+ table.field("unescaped", node.unescaped.inspect)
3049
+
3050
+ digraph.nodes << <<~DOT
3051
+ #{id} [
3052
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3053
+ ];
3054
+ DOT
3055
+
3056
+ super
3057
+ end
3058
+
3059
+ # Visit a MatchPredicateNode node.
3060
+ def visit_match_predicate_node(node)
3061
+ table = Table.new("MatchPredicateNode")
3062
+ id = node_id(node)
3063
+
3064
+ # value
3065
+ table.field("value", port: true)
3066
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
3067
+
3068
+ # pattern
3069
+ table.field("pattern", port: true)
3070
+ digraph.edge("#{id}:pattern -> #{node_id(node.pattern)};")
3071
+
3072
+ # operator_loc
3073
+ table.field("operator_loc", location_inspect(node.operator_loc))
3074
+
3075
+ digraph.nodes << <<~DOT
3076
+ #{id} [
3077
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3078
+ ];
3079
+ DOT
3080
+
3081
+ super
3082
+ end
3083
+
3084
+ # Visit a MatchRequiredNode node.
3085
+ def visit_match_required_node(node)
3086
+ table = Table.new("MatchRequiredNode")
3087
+ id = node_id(node)
3088
+
3089
+ # value
3090
+ table.field("value", port: true)
3091
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
3092
+
3093
+ # pattern
3094
+ table.field("pattern", port: true)
3095
+ digraph.edge("#{id}:pattern -> #{node_id(node.pattern)};")
3096
+
3097
+ # operator_loc
3098
+ table.field("operator_loc", location_inspect(node.operator_loc))
3099
+
3100
+ digraph.nodes << <<~DOT
3101
+ #{id} [
3102
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3103
+ ];
3104
+ DOT
3105
+
3106
+ super
3107
+ end
3108
+
3109
+ # Visit a MatchWriteNode node.
3110
+ def visit_match_write_node(node)
3111
+ table = Table.new("MatchWriteNode")
3112
+ id = node_id(node)
3113
+
3114
+ # call
3115
+ table.field("call", port: true)
3116
+ digraph.edge("#{id}:call -> #{node_id(node.call)};")
3117
+
3118
+ # targets
3119
+ if node.targets.any?
3120
+ table.field("targets", port: true)
3121
+
3122
+ waypoint = "#{id}_targets"
3123
+ digraph.waypoint("#{waypoint};")
3124
+
3125
+ digraph.edge("#{id}:targets -> #{waypoint};")
3126
+ node.targets.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3127
+ else
3128
+ table.field("targets", "[]")
3129
+ end
3130
+
3131
+ digraph.nodes << <<~DOT
3132
+ #{id} [
3133
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3134
+ ];
3135
+ DOT
3136
+
3137
+ super
3138
+ end
3139
+
3140
+ # Visit a MissingNode node.
3141
+ def visit_missing_node(node)
3142
+ table = Table.new("MissingNode")
3143
+ id = node_id(node)
3144
+
3145
+ digraph.nodes << <<~DOT
3146
+ #{id} [
3147
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3148
+ ];
3149
+ DOT
3150
+
3151
+ super
3152
+ end
3153
+
3154
+ # Visit a ModuleNode node.
3155
+ def visit_module_node(node)
3156
+ table = Table.new("ModuleNode")
3157
+ id = node_id(node)
3158
+
3159
+ # locals
3160
+ table.field("locals", node.locals.inspect)
3161
+
3162
+ # module_keyword_loc
3163
+ table.field("module_keyword_loc", location_inspect(node.module_keyword_loc))
3164
+
3165
+ # constant_path
3166
+ table.field("constant_path", port: true)
3167
+ digraph.edge("#{id}:constant_path -> #{node_id(node.constant_path)};")
3168
+
3169
+ # body
3170
+ unless (body = node.body).nil?
3171
+ table.field("body", port: true)
3172
+ digraph.edge("#{id}:body -> #{node_id(body)};")
3173
+ end
3174
+
3175
+ # end_keyword_loc
3176
+ table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
3177
+
3178
+ # name
3179
+ table.field("name", node.name.inspect)
3180
+
3181
+ digraph.nodes << <<~DOT
3182
+ #{id} [
3183
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3184
+ ];
3185
+ DOT
3186
+
3187
+ super
3188
+ end
3189
+
3190
+ # Visit a MultiTargetNode node.
3191
+ def visit_multi_target_node(node)
3192
+ table = Table.new("MultiTargetNode")
3193
+ id = node_id(node)
3194
+
3195
+ # lefts
3196
+ if node.lefts.any?
3197
+ table.field("lefts", port: true)
3198
+
3199
+ waypoint = "#{id}_lefts"
3200
+ digraph.waypoint("#{waypoint};")
3201
+
3202
+ digraph.edge("#{id}:lefts -> #{waypoint};")
3203
+ node.lefts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3204
+ else
3205
+ table.field("lefts", "[]")
3206
+ end
3207
+
3208
+ # rest
3209
+ unless (rest = node.rest).nil?
3210
+ table.field("rest", port: true)
3211
+ digraph.edge("#{id}:rest -> #{node_id(rest)};")
3212
+ end
3213
+
3214
+ # rights
3215
+ if node.rights.any?
3216
+ table.field("rights", port: true)
3217
+
3218
+ waypoint = "#{id}_rights"
3219
+ digraph.waypoint("#{waypoint};")
3220
+
3221
+ digraph.edge("#{id}:rights -> #{waypoint};")
3222
+ node.rights.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3223
+ else
3224
+ table.field("rights", "[]")
3225
+ end
3226
+
3227
+ # lparen_loc
3228
+ unless (lparen_loc = node.lparen_loc).nil?
3229
+ table.field("lparen_loc", location_inspect(lparen_loc))
3230
+ end
3231
+
3232
+ # rparen_loc
3233
+ unless (rparen_loc = node.rparen_loc).nil?
3234
+ table.field("rparen_loc", location_inspect(rparen_loc))
3235
+ end
3236
+
3237
+ digraph.nodes << <<~DOT
3238
+ #{id} [
3239
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3240
+ ];
3241
+ DOT
3242
+
3243
+ super
3244
+ end
3245
+
3246
+ # Visit a MultiWriteNode node.
3247
+ def visit_multi_write_node(node)
3248
+ table = Table.new("MultiWriteNode")
3249
+ id = node_id(node)
3250
+
3251
+ # lefts
3252
+ if node.lefts.any?
3253
+ table.field("lefts", port: true)
3254
+
3255
+ waypoint = "#{id}_lefts"
3256
+ digraph.waypoint("#{waypoint};")
3257
+
3258
+ digraph.edge("#{id}:lefts -> #{waypoint};")
3259
+ node.lefts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3260
+ else
3261
+ table.field("lefts", "[]")
3262
+ end
3263
+
3264
+ # rest
3265
+ unless (rest = node.rest).nil?
3266
+ table.field("rest", port: true)
3267
+ digraph.edge("#{id}:rest -> #{node_id(rest)};")
3268
+ end
3269
+
3270
+ # rights
3271
+ if node.rights.any?
3272
+ table.field("rights", port: true)
3273
+
3274
+ waypoint = "#{id}_rights"
3275
+ digraph.waypoint("#{waypoint};")
3276
+
3277
+ digraph.edge("#{id}:rights -> #{waypoint};")
3278
+ node.rights.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3279
+ else
3280
+ table.field("rights", "[]")
3281
+ end
3282
+
3283
+ # lparen_loc
3284
+ unless (lparen_loc = node.lparen_loc).nil?
3285
+ table.field("lparen_loc", location_inspect(lparen_loc))
3286
+ end
3287
+
3288
+ # rparen_loc
3289
+ unless (rparen_loc = node.rparen_loc).nil?
3290
+ table.field("rparen_loc", location_inspect(rparen_loc))
3291
+ end
3292
+
3293
+ # operator_loc
3294
+ table.field("operator_loc", location_inspect(node.operator_loc))
3295
+
3296
+ # value
3297
+ table.field("value", port: true)
3298
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
3299
+
3300
+ digraph.nodes << <<~DOT
3301
+ #{id} [
3302
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3303
+ ];
3304
+ DOT
3305
+
3306
+ super
3307
+ end
3308
+
3309
+ # Visit a NextNode node.
3310
+ def visit_next_node(node)
3311
+ table = Table.new("NextNode")
3312
+ id = node_id(node)
3313
+
3314
+ # arguments
3315
+ unless (arguments = node.arguments).nil?
3316
+ table.field("arguments", port: true)
3317
+ digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
3318
+ end
3319
+
3320
+ # keyword_loc
3321
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
3322
+
3323
+ digraph.nodes << <<~DOT
3324
+ #{id} [
3325
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3326
+ ];
3327
+ DOT
3328
+
3329
+ super
3330
+ end
3331
+
3332
+ # Visit a NilNode node.
3333
+ def visit_nil_node(node)
3334
+ table = Table.new("NilNode")
3335
+ id = node_id(node)
3336
+
3337
+ digraph.nodes << <<~DOT
3338
+ #{id} [
3339
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3340
+ ];
3341
+ DOT
3342
+
3343
+ super
3344
+ end
3345
+
3346
+ # Visit a NoKeywordsParameterNode node.
3347
+ def visit_no_keywords_parameter_node(node)
3348
+ table = Table.new("NoKeywordsParameterNode")
3349
+ id = node_id(node)
3350
+
3351
+ # operator_loc
3352
+ table.field("operator_loc", location_inspect(node.operator_loc))
3353
+
3354
+ # keyword_loc
3355
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
3356
+
3357
+ digraph.nodes << <<~DOT
3358
+ #{id} [
3359
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3360
+ ];
3361
+ DOT
3362
+
3363
+ super
3364
+ end
3365
+
3366
+ # Visit a NumberedParametersNode node.
3367
+ def visit_numbered_parameters_node(node)
3368
+ table = Table.new("NumberedParametersNode")
3369
+ id = node_id(node)
3370
+
3371
+ # maximum
3372
+ table.field("maximum", node.maximum.inspect)
3373
+
3374
+ digraph.nodes << <<~DOT
3375
+ #{id} [
3376
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3377
+ ];
3378
+ DOT
3379
+
3380
+ super
3381
+ end
3382
+
3383
+ # Visit a NumberedReferenceReadNode node.
3384
+ def visit_numbered_reference_read_node(node)
3385
+ table = Table.new("NumberedReferenceReadNode")
3386
+ id = node_id(node)
3387
+
3388
+ # number
3389
+ table.field("number", node.number.inspect)
3390
+
3391
+ digraph.nodes << <<~DOT
3392
+ #{id} [
3393
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3394
+ ];
3395
+ DOT
3396
+
3397
+ super
3398
+ end
3399
+
3400
+ # Visit a OptionalKeywordParameterNode node.
3401
+ def visit_optional_keyword_parameter_node(node)
3402
+ table = Table.new("OptionalKeywordParameterNode")
3403
+ id = node_id(node)
3404
+
3405
+ # flags
3406
+ table.field("flags", parameter_flags_inspect(node))
3407
+
3408
+ # name
3409
+ table.field("name", node.name.inspect)
3410
+
3411
+ # name_loc
3412
+ table.field("name_loc", location_inspect(node.name_loc))
3413
+
3414
+ # value
3415
+ table.field("value", port: true)
3416
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
3417
+
3418
+ digraph.nodes << <<~DOT
3419
+ #{id} [
3420
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3421
+ ];
3422
+ DOT
3423
+
3424
+ super
3425
+ end
3426
+
3427
+ # Visit a OptionalParameterNode node.
3428
+ def visit_optional_parameter_node(node)
3429
+ table = Table.new("OptionalParameterNode")
3430
+ id = node_id(node)
3431
+
3432
+ # flags
3433
+ table.field("flags", parameter_flags_inspect(node))
3434
+
3435
+ # name
3436
+ table.field("name", node.name.inspect)
3437
+
3438
+ # name_loc
3439
+ table.field("name_loc", location_inspect(node.name_loc))
3440
+
3441
+ # operator_loc
3442
+ table.field("operator_loc", location_inspect(node.operator_loc))
3443
+
3444
+ # value
3445
+ table.field("value", port: true)
3446
+ digraph.edge("#{id}:value -> #{node_id(node.value)};")
3447
+
3448
+ digraph.nodes << <<~DOT
3449
+ #{id} [
3450
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3451
+ ];
3452
+ DOT
3453
+
3454
+ super
3455
+ end
3456
+
3457
+ # Visit a OrNode node.
3458
+ def visit_or_node(node)
3459
+ table = Table.new("OrNode")
3460
+ id = node_id(node)
3461
+
3462
+ # left
3463
+ table.field("left", port: true)
3464
+ digraph.edge("#{id}:left -> #{node_id(node.left)};")
3465
+
3466
+ # right
3467
+ table.field("right", port: true)
3468
+ digraph.edge("#{id}:right -> #{node_id(node.right)};")
3469
+
3470
+ # operator_loc
3471
+ table.field("operator_loc", location_inspect(node.operator_loc))
3472
+
3473
+ digraph.nodes << <<~DOT
3474
+ #{id} [
3475
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3476
+ ];
3477
+ DOT
3478
+
3479
+ super
3480
+ end
3481
+
3482
+ # Visit a ParametersNode node.
3483
+ def visit_parameters_node(node)
3484
+ table = Table.new("ParametersNode")
3485
+ id = node_id(node)
3486
+
3487
+ # requireds
3488
+ if node.requireds.any?
3489
+ table.field("requireds", port: true)
3490
+
3491
+ waypoint = "#{id}_requireds"
3492
+ digraph.waypoint("#{waypoint};")
3493
+
3494
+ digraph.edge("#{id}:requireds -> #{waypoint};")
3495
+ node.requireds.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3496
+ else
3497
+ table.field("requireds", "[]")
3498
+ end
3499
+
3500
+ # optionals
3501
+ if node.optionals.any?
3502
+ table.field("optionals", port: true)
3503
+
3504
+ waypoint = "#{id}_optionals"
3505
+ digraph.waypoint("#{waypoint};")
3506
+
3507
+ digraph.edge("#{id}:optionals -> #{waypoint};")
3508
+ node.optionals.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3509
+ else
3510
+ table.field("optionals", "[]")
3511
+ end
3512
+
3513
+ # rest
3514
+ unless (rest = node.rest).nil?
3515
+ table.field("rest", port: true)
3516
+ digraph.edge("#{id}:rest -> #{node_id(rest)};")
3517
+ end
3518
+
3519
+ # posts
3520
+ if node.posts.any?
3521
+ table.field("posts", port: true)
3522
+
3523
+ waypoint = "#{id}_posts"
3524
+ digraph.waypoint("#{waypoint};")
3525
+
3526
+ digraph.edge("#{id}:posts -> #{waypoint};")
3527
+ node.posts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3528
+ else
3529
+ table.field("posts", "[]")
3530
+ end
3531
+
3532
+ # keywords
3533
+ if node.keywords.any?
3534
+ table.field("keywords", port: true)
3535
+
3536
+ waypoint = "#{id}_keywords"
3537
+ digraph.waypoint("#{waypoint};")
3538
+
3539
+ digraph.edge("#{id}:keywords -> #{waypoint};")
3540
+ node.keywords.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3541
+ else
3542
+ table.field("keywords", "[]")
3543
+ end
3544
+
3545
+ # keyword_rest
3546
+ unless (keyword_rest = node.keyword_rest).nil?
3547
+ table.field("keyword_rest", port: true)
3548
+ digraph.edge("#{id}:keyword_rest -> #{node_id(keyword_rest)};")
3549
+ end
3550
+
3551
+ # block
3552
+ unless (block = node.block).nil?
3553
+ table.field("block", port: true)
3554
+ digraph.edge("#{id}:block -> #{node_id(block)};")
3555
+ end
3556
+
3557
+ digraph.nodes << <<~DOT
3558
+ #{id} [
3559
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3560
+ ];
3561
+ DOT
3562
+
3563
+ super
3564
+ end
3565
+
3566
+ # Visit a ParenthesesNode node.
3567
+ def visit_parentheses_node(node)
3568
+ table = Table.new("ParenthesesNode")
3569
+ id = node_id(node)
3570
+
3571
+ # body
3572
+ unless (body = node.body).nil?
3573
+ table.field("body", port: true)
3574
+ digraph.edge("#{id}:body -> #{node_id(body)};")
3575
+ end
3576
+
3577
+ # opening_loc
3578
+ table.field("opening_loc", location_inspect(node.opening_loc))
3579
+
3580
+ # closing_loc
3581
+ table.field("closing_loc", location_inspect(node.closing_loc))
3582
+
3583
+ digraph.nodes << <<~DOT
3584
+ #{id} [
3585
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3586
+ ];
3587
+ DOT
3588
+
3589
+ super
3590
+ end
3591
+
3592
+ # Visit a PinnedExpressionNode node.
3593
+ def visit_pinned_expression_node(node)
3594
+ table = Table.new("PinnedExpressionNode")
3595
+ id = node_id(node)
3596
+
3597
+ # expression
3598
+ table.field("expression", port: true)
3599
+ digraph.edge("#{id}:expression -> #{node_id(node.expression)};")
3600
+
3601
+ # operator_loc
3602
+ table.field("operator_loc", location_inspect(node.operator_loc))
3603
+
3604
+ # lparen_loc
3605
+ table.field("lparen_loc", location_inspect(node.lparen_loc))
3606
+
3607
+ # rparen_loc
3608
+ table.field("rparen_loc", location_inspect(node.rparen_loc))
3609
+
3610
+ digraph.nodes << <<~DOT
3611
+ #{id} [
3612
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3613
+ ];
3614
+ DOT
3615
+
3616
+ super
3617
+ end
3618
+
3619
+ # Visit a PinnedVariableNode node.
3620
+ def visit_pinned_variable_node(node)
3621
+ table = Table.new("PinnedVariableNode")
3622
+ id = node_id(node)
3623
+
3624
+ # variable
3625
+ table.field("variable", port: true)
3626
+ digraph.edge("#{id}:variable -> #{node_id(node.variable)};")
3627
+
3628
+ # operator_loc
3629
+ table.field("operator_loc", location_inspect(node.operator_loc))
3630
+
3631
+ digraph.nodes << <<~DOT
3632
+ #{id} [
3633
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3634
+ ];
3635
+ DOT
3636
+
3637
+ super
3638
+ end
3639
+
3640
+ # Visit a PostExecutionNode node.
3641
+ def visit_post_execution_node(node)
3642
+ table = Table.new("PostExecutionNode")
3643
+ id = node_id(node)
3644
+
3645
+ # statements
3646
+ unless (statements = node.statements).nil?
3647
+ table.field("statements", port: true)
3648
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
3649
+ end
3650
+
3651
+ # keyword_loc
3652
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
3653
+
3654
+ # opening_loc
3655
+ table.field("opening_loc", location_inspect(node.opening_loc))
3656
+
3657
+ # closing_loc
3658
+ table.field("closing_loc", location_inspect(node.closing_loc))
3659
+
3660
+ digraph.nodes << <<~DOT
3661
+ #{id} [
3662
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3663
+ ];
3664
+ DOT
3665
+
3666
+ super
3667
+ end
3668
+
3669
+ # Visit a PreExecutionNode node.
3670
+ def visit_pre_execution_node(node)
3671
+ table = Table.new("PreExecutionNode")
3672
+ id = node_id(node)
3673
+
3674
+ # statements
3675
+ unless (statements = node.statements).nil?
3676
+ table.field("statements", port: true)
3677
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
3678
+ end
3679
+
3680
+ # keyword_loc
3681
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
3682
+
3683
+ # opening_loc
3684
+ table.field("opening_loc", location_inspect(node.opening_loc))
3685
+
3686
+ # closing_loc
3687
+ table.field("closing_loc", location_inspect(node.closing_loc))
3688
+
3689
+ digraph.nodes << <<~DOT
3690
+ #{id} [
3691
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3692
+ ];
3693
+ DOT
3694
+
3695
+ super
3696
+ end
3697
+
3698
+ # Visit a ProgramNode node.
3699
+ def visit_program_node(node)
3700
+ table = Table.new("ProgramNode")
3701
+ id = node_id(node)
3702
+
3703
+ # locals
3704
+ table.field("locals", node.locals.inspect)
3705
+
3706
+ # statements
3707
+ table.field("statements", port: true)
3708
+ digraph.edge("#{id}:statements -> #{node_id(node.statements)};")
3709
+
3710
+ digraph.nodes << <<~DOT
3711
+ #{id} [
3712
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3713
+ ];
3714
+ DOT
3715
+
3716
+ super
3717
+ end
3718
+
3719
+ # Visit a RangeNode node.
3720
+ def visit_range_node(node)
3721
+ table = Table.new("RangeNode")
3722
+ id = node_id(node)
3723
+
3724
+ # flags
3725
+ table.field("flags", range_flags_inspect(node))
3726
+
3727
+ # left
3728
+ unless (left = node.left).nil?
3729
+ table.field("left", port: true)
3730
+ digraph.edge("#{id}:left -> #{node_id(left)};")
3731
+ end
3732
+
3733
+ # right
3734
+ unless (right = node.right).nil?
3735
+ table.field("right", port: true)
3736
+ digraph.edge("#{id}:right -> #{node_id(right)};")
3737
+ end
3738
+
3739
+ # operator_loc
3740
+ table.field("operator_loc", location_inspect(node.operator_loc))
3741
+
3742
+ digraph.nodes << <<~DOT
3743
+ #{id} [
3744
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3745
+ ];
3746
+ DOT
3747
+
3748
+ super
3749
+ end
3750
+
3751
+ # Visit a RationalNode node.
3752
+ def visit_rational_node(node)
3753
+ table = Table.new("RationalNode")
3754
+ id = node_id(node)
3755
+
3756
+ # numeric
3757
+ table.field("numeric", port: true)
3758
+ digraph.edge("#{id}:numeric -> #{node_id(node.numeric)};")
3759
+
3760
+ digraph.nodes << <<~DOT
3761
+ #{id} [
3762
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3763
+ ];
3764
+ DOT
3765
+
3766
+ super
3767
+ end
3768
+
3769
+ # Visit a RedoNode node.
3770
+ def visit_redo_node(node)
3771
+ table = Table.new("RedoNode")
3772
+ id = node_id(node)
3773
+
3774
+ digraph.nodes << <<~DOT
3775
+ #{id} [
3776
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3777
+ ];
3778
+ DOT
3779
+
3780
+ super
3781
+ end
3782
+
3783
+ # Visit a RegularExpressionNode node.
3784
+ def visit_regular_expression_node(node)
3785
+ table = Table.new("RegularExpressionNode")
3786
+ id = node_id(node)
3787
+
3788
+ # flags
3789
+ table.field("flags", regular_expression_flags_inspect(node))
3790
+
3791
+ # opening_loc
3792
+ table.field("opening_loc", location_inspect(node.opening_loc))
3793
+
3794
+ # content_loc
3795
+ table.field("content_loc", location_inspect(node.content_loc))
3796
+
3797
+ # closing_loc
3798
+ table.field("closing_loc", location_inspect(node.closing_loc))
3799
+
3800
+ # unescaped
3801
+ table.field("unescaped", node.unescaped.inspect)
3802
+
3803
+ digraph.nodes << <<~DOT
3804
+ #{id} [
3805
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3806
+ ];
3807
+ DOT
3808
+
3809
+ super
3810
+ end
3811
+
3812
+ # Visit a RequiredKeywordParameterNode node.
3813
+ def visit_required_keyword_parameter_node(node)
3814
+ table = Table.new("RequiredKeywordParameterNode")
3815
+ id = node_id(node)
3816
+
3817
+ # flags
3818
+ table.field("flags", parameter_flags_inspect(node))
3819
+
3820
+ # name
3821
+ table.field("name", node.name.inspect)
3822
+
3823
+ # name_loc
3824
+ table.field("name_loc", location_inspect(node.name_loc))
3825
+
3826
+ digraph.nodes << <<~DOT
3827
+ #{id} [
3828
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3829
+ ];
3830
+ DOT
3831
+
3832
+ super
3833
+ end
3834
+
3835
+ # Visit a RequiredParameterNode node.
3836
+ def visit_required_parameter_node(node)
3837
+ table = Table.new("RequiredParameterNode")
3838
+ id = node_id(node)
3839
+
3840
+ # flags
3841
+ table.field("flags", parameter_flags_inspect(node))
3842
+
3843
+ # name
3844
+ table.field("name", node.name.inspect)
3845
+
3846
+ digraph.nodes << <<~DOT
3847
+ #{id} [
3848
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3849
+ ];
3850
+ DOT
3851
+
3852
+ super
3853
+ end
3854
+
3855
+ # Visit a RescueModifierNode node.
3856
+ def visit_rescue_modifier_node(node)
3857
+ table = Table.new("RescueModifierNode")
3858
+ id = node_id(node)
3859
+
3860
+ # expression
3861
+ table.field("expression", port: true)
3862
+ digraph.edge("#{id}:expression -> #{node_id(node.expression)};")
3863
+
3864
+ # keyword_loc
3865
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
3866
+
3867
+ # rescue_expression
3868
+ table.field("rescue_expression", port: true)
3869
+ digraph.edge("#{id}:rescue_expression -> #{node_id(node.rescue_expression)};")
3870
+
3871
+ digraph.nodes << <<~DOT
3872
+ #{id} [
3873
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3874
+ ];
3875
+ DOT
3876
+
3877
+ super
3878
+ end
3879
+
3880
+ # Visit a RescueNode node.
3881
+ def visit_rescue_node(node)
3882
+ table = Table.new("RescueNode")
3883
+ id = node_id(node)
3884
+
3885
+ # keyword_loc
3886
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
3887
+
3888
+ # exceptions
3889
+ if node.exceptions.any?
3890
+ table.field("exceptions", port: true)
3891
+
3892
+ waypoint = "#{id}_exceptions"
3893
+ digraph.waypoint("#{waypoint};")
3894
+
3895
+ digraph.edge("#{id}:exceptions -> #{waypoint};")
3896
+ node.exceptions.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3897
+ else
3898
+ table.field("exceptions", "[]")
3899
+ end
3900
+
3901
+ # operator_loc
3902
+ unless (operator_loc = node.operator_loc).nil?
3903
+ table.field("operator_loc", location_inspect(operator_loc))
3904
+ end
3905
+
3906
+ # reference
3907
+ unless (reference = node.reference).nil?
3908
+ table.field("reference", port: true)
3909
+ digraph.edge("#{id}:reference -> #{node_id(reference)};")
3910
+ end
3911
+
3912
+ # statements
3913
+ unless (statements = node.statements).nil?
3914
+ table.field("statements", port: true)
3915
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
3916
+ end
3917
+
3918
+ # consequent
3919
+ unless (consequent = node.consequent).nil?
3920
+ table.field("consequent", port: true)
3921
+ digraph.edge("#{id}:consequent -> #{node_id(consequent)};")
3922
+ end
3923
+
3924
+ digraph.nodes << <<~DOT
3925
+ #{id} [
3926
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3927
+ ];
3928
+ DOT
3929
+
3930
+ super
3931
+ end
3932
+
3933
+ # Visit a RestParameterNode node.
3934
+ def visit_rest_parameter_node(node)
3935
+ table = Table.new("RestParameterNode")
3936
+ id = node_id(node)
3937
+
3938
+ # flags
3939
+ table.field("flags", parameter_flags_inspect(node))
3940
+
3941
+ # name
3942
+ table.field("name", node.name.inspect)
3943
+
3944
+ # name_loc
3945
+ unless (name_loc = node.name_loc).nil?
3946
+ table.field("name_loc", location_inspect(name_loc))
3947
+ end
3948
+
3949
+ # operator_loc
3950
+ table.field("operator_loc", location_inspect(node.operator_loc))
3951
+
3952
+ digraph.nodes << <<~DOT
3953
+ #{id} [
3954
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3955
+ ];
3956
+ DOT
3957
+
3958
+ super
3959
+ end
3960
+
3961
+ # Visit a RetryNode node.
3962
+ def visit_retry_node(node)
3963
+ table = Table.new("RetryNode")
3964
+ id = node_id(node)
3965
+
3966
+ digraph.nodes << <<~DOT
3967
+ #{id} [
3968
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3969
+ ];
3970
+ DOT
3971
+
3972
+ super
3973
+ end
3974
+
3975
+ # Visit a ReturnNode node.
3976
+ def visit_return_node(node)
3977
+ table = Table.new("ReturnNode")
3978
+ id = node_id(node)
3979
+
3980
+ # keyword_loc
3981
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
3982
+
3983
+ # arguments
3984
+ unless (arguments = node.arguments).nil?
3985
+ table.field("arguments", port: true)
3986
+ digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
3987
+ end
3988
+
3989
+ digraph.nodes << <<~DOT
3990
+ #{id} [
3991
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3992
+ ];
3993
+ DOT
3994
+
3995
+ super
3996
+ end
3997
+
3998
+ # Visit a SelfNode node.
3999
+ def visit_self_node(node)
4000
+ table = Table.new("SelfNode")
4001
+ id = node_id(node)
4002
+
4003
+ digraph.nodes << <<~DOT
4004
+ #{id} [
4005
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4006
+ ];
4007
+ DOT
4008
+
4009
+ super
4010
+ end
4011
+
4012
+ # Visit a SingletonClassNode node.
4013
+ def visit_singleton_class_node(node)
4014
+ table = Table.new("SingletonClassNode")
4015
+ id = node_id(node)
4016
+
4017
+ # locals
4018
+ table.field("locals", node.locals.inspect)
4019
+
4020
+ # class_keyword_loc
4021
+ table.field("class_keyword_loc", location_inspect(node.class_keyword_loc))
4022
+
4023
+ # operator_loc
4024
+ table.field("operator_loc", location_inspect(node.operator_loc))
4025
+
4026
+ # expression
4027
+ table.field("expression", port: true)
4028
+ digraph.edge("#{id}:expression -> #{node_id(node.expression)};")
4029
+
4030
+ # body
4031
+ unless (body = node.body).nil?
4032
+ table.field("body", port: true)
4033
+ digraph.edge("#{id}:body -> #{node_id(body)};")
4034
+ end
4035
+
4036
+ # end_keyword_loc
4037
+ table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
4038
+
4039
+ digraph.nodes << <<~DOT
4040
+ #{id} [
4041
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4042
+ ];
4043
+ DOT
4044
+
4045
+ super
4046
+ end
4047
+
4048
+ # Visit a SourceEncodingNode node.
4049
+ def visit_source_encoding_node(node)
4050
+ table = Table.new("SourceEncodingNode")
4051
+ id = node_id(node)
4052
+
4053
+ digraph.nodes << <<~DOT
4054
+ #{id} [
4055
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4056
+ ];
4057
+ DOT
4058
+
4059
+ super
4060
+ end
4061
+
4062
+ # Visit a SourceFileNode node.
4063
+ def visit_source_file_node(node)
4064
+ table = Table.new("SourceFileNode")
4065
+ id = node_id(node)
4066
+
4067
+ # filepath
4068
+ table.field("filepath", node.filepath.inspect)
4069
+
4070
+ digraph.nodes << <<~DOT
4071
+ #{id} [
4072
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4073
+ ];
4074
+ DOT
4075
+
4076
+ super
4077
+ end
4078
+
4079
+ # Visit a SourceLineNode node.
4080
+ def visit_source_line_node(node)
4081
+ table = Table.new("SourceLineNode")
4082
+ id = node_id(node)
4083
+
4084
+ digraph.nodes << <<~DOT
4085
+ #{id} [
4086
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4087
+ ];
4088
+ DOT
4089
+
4090
+ super
4091
+ end
4092
+
4093
+ # Visit a SplatNode node.
4094
+ def visit_splat_node(node)
4095
+ table = Table.new("SplatNode")
4096
+ id = node_id(node)
4097
+
4098
+ # operator_loc
4099
+ table.field("operator_loc", location_inspect(node.operator_loc))
4100
+
4101
+ # expression
4102
+ unless (expression = node.expression).nil?
4103
+ table.field("expression", port: true)
4104
+ digraph.edge("#{id}:expression -> #{node_id(expression)};")
4105
+ end
4106
+
4107
+ digraph.nodes << <<~DOT
4108
+ #{id} [
4109
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4110
+ ];
4111
+ DOT
4112
+
4113
+ super
4114
+ end
4115
+
4116
+ # Visit a StatementsNode node.
4117
+ def visit_statements_node(node)
4118
+ table = Table.new("StatementsNode")
4119
+ id = node_id(node)
4120
+
4121
+ # body
4122
+ if node.body.any?
4123
+ table.field("body", port: true)
4124
+
4125
+ waypoint = "#{id}_body"
4126
+ digraph.waypoint("#{waypoint};")
4127
+
4128
+ digraph.edge("#{id}:body -> #{waypoint};")
4129
+ node.body.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
4130
+ else
4131
+ table.field("body", "[]")
4132
+ end
4133
+
4134
+ digraph.nodes << <<~DOT
4135
+ #{id} [
4136
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4137
+ ];
4138
+ DOT
4139
+
4140
+ super
4141
+ end
4142
+
4143
+ # Visit a StringNode node.
4144
+ def visit_string_node(node)
4145
+ table = Table.new("StringNode")
4146
+ id = node_id(node)
4147
+
4148
+ # flags
4149
+ table.field("flags", string_flags_inspect(node))
4150
+
4151
+ # opening_loc
4152
+ unless (opening_loc = node.opening_loc).nil?
4153
+ table.field("opening_loc", location_inspect(opening_loc))
4154
+ end
4155
+
4156
+ # content_loc
4157
+ table.field("content_loc", location_inspect(node.content_loc))
4158
+
4159
+ # closing_loc
4160
+ unless (closing_loc = node.closing_loc).nil?
4161
+ table.field("closing_loc", location_inspect(closing_loc))
4162
+ end
4163
+
4164
+ # unescaped
4165
+ table.field("unescaped", node.unescaped.inspect)
4166
+
4167
+ digraph.nodes << <<~DOT
4168
+ #{id} [
4169
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4170
+ ];
4171
+ DOT
4172
+
4173
+ super
4174
+ end
4175
+
4176
+ # Visit a SuperNode node.
4177
+ def visit_super_node(node)
4178
+ table = Table.new("SuperNode")
4179
+ id = node_id(node)
4180
+
4181
+ # keyword_loc
4182
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
4183
+
4184
+ # lparen_loc
4185
+ unless (lparen_loc = node.lparen_loc).nil?
4186
+ table.field("lparen_loc", location_inspect(lparen_loc))
4187
+ end
4188
+
4189
+ # arguments
4190
+ unless (arguments = node.arguments).nil?
4191
+ table.field("arguments", port: true)
4192
+ digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
4193
+ end
4194
+
4195
+ # rparen_loc
4196
+ unless (rparen_loc = node.rparen_loc).nil?
4197
+ table.field("rparen_loc", location_inspect(rparen_loc))
4198
+ end
4199
+
4200
+ # block
4201
+ unless (block = node.block).nil?
4202
+ table.field("block", port: true)
4203
+ digraph.edge("#{id}:block -> #{node_id(block)};")
4204
+ end
4205
+
4206
+ digraph.nodes << <<~DOT
4207
+ #{id} [
4208
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4209
+ ];
4210
+ DOT
4211
+
4212
+ super
4213
+ end
4214
+
4215
+ # Visit a SymbolNode node.
4216
+ def visit_symbol_node(node)
4217
+ table = Table.new("SymbolNode")
4218
+ id = node_id(node)
4219
+
4220
+ # flags
4221
+ table.field("flags", symbol_flags_inspect(node))
4222
+
4223
+ # opening_loc
4224
+ unless (opening_loc = node.opening_loc).nil?
4225
+ table.field("opening_loc", location_inspect(opening_loc))
4226
+ end
4227
+
4228
+ # value_loc
4229
+ unless (value_loc = node.value_loc).nil?
4230
+ table.field("value_loc", location_inspect(value_loc))
4231
+ end
4232
+
4233
+ # closing_loc
4234
+ unless (closing_loc = node.closing_loc).nil?
4235
+ table.field("closing_loc", location_inspect(closing_loc))
4236
+ end
4237
+
4238
+ # unescaped
4239
+ table.field("unescaped", node.unescaped.inspect)
4240
+
4241
+ digraph.nodes << <<~DOT
4242
+ #{id} [
4243
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4244
+ ];
4245
+ DOT
4246
+
4247
+ super
4248
+ end
4249
+
4250
+ # Visit a TrueNode node.
4251
+ def visit_true_node(node)
4252
+ table = Table.new("TrueNode")
4253
+ id = node_id(node)
4254
+
4255
+ digraph.nodes << <<~DOT
4256
+ #{id} [
4257
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4258
+ ];
4259
+ DOT
4260
+
4261
+ super
4262
+ end
4263
+
4264
+ # Visit a UndefNode node.
4265
+ def visit_undef_node(node)
4266
+ table = Table.new("UndefNode")
4267
+ id = node_id(node)
4268
+
4269
+ # names
4270
+ if node.names.any?
4271
+ table.field("names", port: true)
4272
+
4273
+ waypoint = "#{id}_names"
4274
+ digraph.waypoint("#{waypoint};")
4275
+
4276
+ digraph.edge("#{id}:names -> #{waypoint};")
4277
+ node.names.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
4278
+ else
4279
+ table.field("names", "[]")
4280
+ end
4281
+
4282
+ # keyword_loc
4283
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
4284
+
4285
+ digraph.nodes << <<~DOT
4286
+ #{id} [
4287
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4288
+ ];
4289
+ DOT
4290
+
4291
+ super
4292
+ end
4293
+
4294
+ # Visit a UnlessNode node.
4295
+ def visit_unless_node(node)
4296
+ table = Table.new("UnlessNode")
4297
+ id = node_id(node)
4298
+
4299
+ # keyword_loc
4300
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
4301
+
4302
+ # predicate
4303
+ table.field("predicate", port: true)
4304
+ digraph.edge("#{id}:predicate -> #{node_id(node.predicate)};")
4305
+
4306
+ # then_keyword_loc
4307
+ unless (then_keyword_loc = node.then_keyword_loc).nil?
4308
+ table.field("then_keyword_loc", location_inspect(then_keyword_loc))
4309
+ end
4310
+
4311
+ # statements
4312
+ unless (statements = node.statements).nil?
4313
+ table.field("statements", port: true)
4314
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
4315
+ end
4316
+
4317
+ # consequent
4318
+ unless (consequent = node.consequent).nil?
4319
+ table.field("consequent", port: true)
4320
+ digraph.edge("#{id}:consequent -> #{node_id(consequent)};")
4321
+ end
4322
+
4323
+ # end_keyword_loc
4324
+ unless (end_keyword_loc = node.end_keyword_loc).nil?
4325
+ table.field("end_keyword_loc", location_inspect(end_keyword_loc))
4326
+ end
4327
+
4328
+ digraph.nodes << <<~DOT
4329
+ #{id} [
4330
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4331
+ ];
4332
+ DOT
4333
+
4334
+ super
4335
+ end
4336
+
4337
+ # Visit a UntilNode node.
4338
+ def visit_until_node(node)
4339
+ table = Table.new("UntilNode")
4340
+ id = node_id(node)
4341
+
4342
+ # flags
4343
+ table.field("flags", loop_flags_inspect(node))
4344
+
4345
+ # keyword_loc
4346
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
4347
+
4348
+ # closing_loc
4349
+ unless (closing_loc = node.closing_loc).nil?
4350
+ table.field("closing_loc", location_inspect(closing_loc))
4351
+ end
4352
+
4353
+ # predicate
4354
+ table.field("predicate", port: true)
4355
+ digraph.edge("#{id}:predicate -> #{node_id(node.predicate)};")
4356
+
4357
+ # statements
4358
+ unless (statements = node.statements).nil?
4359
+ table.field("statements", port: true)
4360
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
4361
+ end
4362
+
4363
+ digraph.nodes << <<~DOT
4364
+ #{id} [
4365
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4366
+ ];
4367
+ DOT
4368
+
4369
+ super
4370
+ end
4371
+
4372
+ # Visit a WhenNode node.
4373
+ def visit_when_node(node)
4374
+ table = Table.new("WhenNode")
4375
+ id = node_id(node)
4376
+
4377
+ # keyword_loc
4378
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
4379
+
4380
+ # conditions
4381
+ if node.conditions.any?
4382
+ table.field("conditions", port: true)
4383
+
4384
+ waypoint = "#{id}_conditions"
4385
+ digraph.waypoint("#{waypoint};")
4386
+
4387
+ digraph.edge("#{id}:conditions -> #{waypoint};")
4388
+ node.conditions.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
4389
+ else
4390
+ table.field("conditions", "[]")
4391
+ end
4392
+
4393
+ # statements
4394
+ unless (statements = node.statements).nil?
4395
+ table.field("statements", port: true)
4396
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
4397
+ end
4398
+
4399
+ digraph.nodes << <<~DOT
4400
+ #{id} [
4401
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4402
+ ];
4403
+ DOT
4404
+
4405
+ super
4406
+ end
4407
+
4408
+ # Visit a WhileNode node.
4409
+ def visit_while_node(node)
4410
+ table = Table.new("WhileNode")
4411
+ id = node_id(node)
4412
+
4413
+ # flags
4414
+ table.field("flags", loop_flags_inspect(node))
4415
+
4416
+ # keyword_loc
4417
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
4418
+
4419
+ # closing_loc
4420
+ unless (closing_loc = node.closing_loc).nil?
4421
+ table.field("closing_loc", location_inspect(closing_loc))
4422
+ end
4423
+
4424
+ # predicate
4425
+ table.field("predicate", port: true)
4426
+ digraph.edge("#{id}:predicate -> #{node_id(node.predicate)};")
4427
+
4428
+ # statements
4429
+ unless (statements = node.statements).nil?
4430
+ table.field("statements", port: true)
4431
+ digraph.edge("#{id}:statements -> #{node_id(statements)};")
4432
+ end
4433
+
4434
+ digraph.nodes << <<~DOT
4435
+ #{id} [
4436
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4437
+ ];
4438
+ DOT
4439
+
4440
+ super
4441
+ end
4442
+
4443
+ # Visit a XStringNode node.
4444
+ def visit_x_string_node(node)
4445
+ table = Table.new("XStringNode")
4446
+ id = node_id(node)
4447
+
4448
+ # flags
4449
+ table.field("flags", encoding_flags_inspect(node))
4450
+
4451
+ # opening_loc
4452
+ table.field("opening_loc", location_inspect(node.opening_loc))
4453
+
4454
+ # content_loc
4455
+ table.field("content_loc", location_inspect(node.content_loc))
4456
+
4457
+ # closing_loc
4458
+ table.field("closing_loc", location_inspect(node.closing_loc))
4459
+
4460
+ # unescaped
4461
+ table.field("unescaped", node.unescaped.inspect)
4462
+
4463
+ digraph.nodes << <<~DOT
4464
+ #{id} [
4465
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4466
+ ];
4467
+ DOT
4468
+
4469
+ super
4470
+ end
4471
+
4472
+ # Visit a YieldNode node.
4473
+ def visit_yield_node(node)
4474
+ table = Table.new("YieldNode")
4475
+ id = node_id(node)
4476
+
4477
+ # keyword_loc
4478
+ table.field("keyword_loc", location_inspect(node.keyword_loc))
4479
+
4480
+ # lparen_loc
4481
+ unless (lparen_loc = node.lparen_loc).nil?
4482
+ table.field("lparen_loc", location_inspect(lparen_loc))
4483
+ end
4484
+
4485
+ # arguments
4486
+ unless (arguments = node.arguments).nil?
4487
+ table.field("arguments", port: true)
4488
+ digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
4489
+ end
4490
+
4491
+ # rparen_loc
4492
+ unless (rparen_loc = node.rparen_loc).nil?
4493
+ table.field("rparen_loc", location_inspect(rparen_loc))
4494
+ end
4495
+
4496
+ digraph.nodes << <<~DOT
4497
+ #{id} [
4498
+ label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4499
+ ];
4500
+ DOT
4501
+
4502
+ super
4503
+ end
4504
+
4505
+ private
4506
+
4507
+ # Generate a unique node ID for a node throughout the digraph.
4508
+ def node_id(node)
4509
+ "Node_#{node.object_id}"
4510
+ end
4511
+
4512
+ # Inspect a location to display the start and end line and column numbers.
4513
+ def location_inspect(location)
4514
+ "(#{location.start_line},#{location.start_column})-(#{location.end_line},#{location.end_column})"
4515
+ end
4516
+
4517
+ # Inspect a node that has arguments_node_flags flags to display the flags as a
4518
+ # comma-separated list.
4519
+ def arguments_node_flags_inspect(node)
4520
+ flags = []
4521
+ flags << "contains_keyword_splat" if node.contains_keyword_splat?
4522
+ flags.join(", ")
4523
+ end
4524
+
4525
+ # Inspect a node that has array_node_flags flags to display the flags as a
4526
+ # comma-separated list.
4527
+ def array_node_flags_inspect(node)
4528
+ flags = []
4529
+ flags << "contains_splat" if node.contains_splat?
4530
+ flags.join(", ")
4531
+ end
4532
+
4533
+ # Inspect a node that has call_node_flags flags to display the flags as a
4534
+ # comma-separated list.
4535
+ def call_node_flags_inspect(node)
4536
+ flags = []
4537
+ flags << "safe_navigation" if node.safe_navigation?
4538
+ flags << "variable_call" if node.variable_call?
4539
+ flags << "attribute_write" if node.attribute_write?
4540
+ flags << "ignore_visibility" if node.ignore_visibility?
4541
+ flags.join(", ")
4542
+ end
4543
+
4544
+ # Inspect a node that has encoding_flags flags to display the flags as a
4545
+ # comma-separated list.
4546
+ def encoding_flags_inspect(node)
4547
+ flags = []
4548
+ flags << "forced_utf8_encoding" if node.forced_utf8_encoding?
4549
+ flags << "forced_binary_encoding" if node.forced_binary_encoding?
4550
+ flags.join(", ")
4551
+ end
4552
+
4553
+ # Inspect a node that has integer_base_flags flags to display the flags as a
4554
+ # comma-separated list.
4555
+ def integer_base_flags_inspect(node)
4556
+ flags = []
4557
+ flags << "binary" if node.binary?
4558
+ flags << "decimal" if node.decimal?
4559
+ flags << "octal" if node.octal?
4560
+ flags << "hexadecimal" if node.hexadecimal?
4561
+ flags.join(", ")
4562
+ end
4563
+
4564
+ # Inspect a node that has keyword_hash_node_flags flags to display the flags as a
4565
+ # comma-separated list.
4566
+ def keyword_hash_node_flags_inspect(node)
4567
+ flags = []
4568
+ flags << "symbol_keys" if node.symbol_keys?
4569
+ flags.join(", ")
4570
+ end
4571
+
4572
+ # Inspect a node that has loop_flags flags to display the flags as a
4573
+ # comma-separated list.
4574
+ def loop_flags_inspect(node)
4575
+ flags = []
4576
+ flags << "begin_modifier" if node.begin_modifier?
4577
+ flags.join(", ")
4578
+ end
4579
+
4580
+ # Inspect a node that has parameter_flags flags to display the flags as a
4581
+ # comma-separated list.
4582
+ def parameter_flags_inspect(node)
4583
+ flags = []
4584
+ flags << "repeated_parameter" if node.repeated_parameter?
4585
+ flags.join(", ")
4586
+ end
4587
+
4588
+ # Inspect a node that has range_flags flags to display the flags as a
4589
+ # comma-separated list.
4590
+ def range_flags_inspect(node)
4591
+ flags = []
4592
+ flags << "exclude_end" if node.exclude_end?
4593
+ flags.join(", ")
4594
+ end
4595
+
4596
+ # Inspect a node that has regular_expression_flags flags to display the flags as a
4597
+ # comma-separated list.
4598
+ def regular_expression_flags_inspect(node)
4599
+ flags = []
4600
+ flags << "ignore_case" if node.ignore_case?
4601
+ flags << "extended" if node.extended?
4602
+ flags << "multi_line" if node.multi_line?
4603
+ flags << "once" if node.once?
4604
+ flags << "euc_jp" if node.euc_jp?
4605
+ flags << "ascii_8bit" if node.ascii_8bit?
4606
+ flags << "windows_31j" if node.windows_31j?
4607
+ flags << "utf_8" if node.utf_8?
4608
+ flags << "forced_utf8_encoding" if node.forced_utf8_encoding?
4609
+ flags << "forced_binary_encoding" if node.forced_binary_encoding?
4610
+ flags << "forced_us_ascii_encoding" if node.forced_us_ascii_encoding?
4611
+ flags.join(", ")
4612
+ end
4613
+
4614
+ # Inspect a node that has string_flags flags to display the flags as a
4615
+ # comma-separated list.
4616
+ def string_flags_inspect(node)
4617
+ flags = []
4618
+ flags << "forced_utf8_encoding" if node.forced_utf8_encoding?
4619
+ flags << "forced_binary_encoding" if node.forced_binary_encoding?
4620
+ flags << "frozen" if node.frozen?
4621
+ flags.join(", ")
4622
+ end
4623
+
4624
+ # Inspect a node that has symbol_flags flags to display the flags as a
4625
+ # comma-separated list.
4626
+ def symbol_flags_inspect(node)
4627
+ flags = []
4628
+ flags << "forced_utf8_encoding" if node.forced_utf8_encoding?
4629
+ flags << "forced_binary_encoding" if node.forced_binary_encoding?
4630
+ flags << "forced_us_ascii_encoding" if node.forced_us_ascii_encoding?
4631
+ flags.join(", ")
4632
+ end
4633
+ end
4634
+ end