prism 0.17.1 → 0.18.0

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