@@ -202,27 +202,6 @@ def inspect
202
202
end
203
203
end
204
204
205
- # A class that knows how to walk down the tree. None of the individual visit
206
- # methods are implemented on this visitor, so it forces the consumer to
207
- # implement each one that they need. For a default implementation that
208
- # continues walking the tree, see the Visitor class.
209
- class BasicVisitor
210
- def visit ( node )
211
- node &.accept ( self )
212
- end
213
-
214
- def visit_all ( nodes )
215
- nodes . map { |node | visit ( node ) }
216
- end
217
-
218
- def visit_child_nodes ( node )
219
- visit_all ( node . child_nodes )
220
- end
221
- end
222
-
223
- class Visitor < BasicVisitor
224
- end
225
-
226
205
# This represents the result of a call to ::parse or ::parse_file. It contains
227
206
# the AST, any comments that were encounters, and any errors that were
228
207
# encountered.
@@ -250,6 +229,24 @@ def failure?
250
229
end
251
230
end
252
231
232
+ # A class that knows how to walk down the tree. None of the individual visit
233
+ # methods are implemented on this visitor, so it forces the consumer to
234
+ # implement each one that they need. For a default implementation that
235
+ # continues walking the tree, see the Visitor class.
236
+ class BasicVisitor
237
+ def visit ( node )
238
+ node &.accept ( self )
239
+ end
240
+
241
+ def visit_all ( nodes )
242
+ nodes . map { |node | visit ( node ) }
243
+ end
244
+
245
+ def visit_child_nodes ( node )
246
+ visit_all ( node . child_nodes )
247
+ end
248
+ end
249
+
253
250
# This represents a token from the Ruby source.
254
251
class Token
255
252
attr_reader :type , :value , :location
@@ -379,11 +376,6 @@ def to_str
379
376
end
380
377
end
381
378
382
- # Load the serialized AST using the source as a reference into a tree.
383
- def self . load ( source , serialized )
384
- Serialize . load ( source , serialized )
385
- end
386
-
387
379
# This module is used for testing and debugging and is not meant to be used by
388
380
# consumers of this library.
389
381
module Debug
@@ -554,6 +546,11 @@ def self.parse_serialize_file(filepath)
554
546
autoload :Pack , "yarp/pack"
555
547
autoload :Pattern , "yarp/pattern"
556
548
autoload :Serialize , "yarp/serialize"
549
+
550
+ # Load the serialized AST using the source as a reference into a tree.
551
+ def self . load ( source , serialized )
552
+ Serialize . load ( source , serialized )
553
+ end
557
554
end
558
555
559
556
require_relative "yarp/lex_compat"
0 commit comments