Class: Unparser::Preprocessor
- Inherits:
-
Object
- Object
- Unparser::Preprocessor
- Includes:
- AbstractType, Adamantium::Flat, NodeHelpers
- Defined in:
- lib/unparser/preprocessor.rb
Overview
Preprocessor to normalize AST generated by parser
Direct Known Subclasses
Defined Under Namespace
Classes: Begin, CollapseStrChildren, CompactDSTR, Infinity, Noop
Constant Summary collapse
- EMPTY =
Parser::AST::Node.new(:empty)
- REGISTRY =
Hash.new { |hash, key| hash[key] = [] }
Class Method Summary collapse
-
.run(node) ⇒ Parser::AST::Node?
private
Run preprocessor for node.
Instance Method Summary collapse
-
#result ⇒ Parser::AST::Node
private
Return preprocessor result.
Methods included from NodeHelpers
Class Method Details
.run(node) ⇒ Parser::AST::Node?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run preprocessor for node
26 27 28 29 30 31 |
# File 'lib/unparser/preprocessor.rb', line 26 def self.run(node) return EMPTY if node.nil? REGISTRY.fetch(node.type, [Noop]).reduce(node) do |current, processor| processor.call(current) end end |
Instance Method Details
#result ⇒ Parser::AST::Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return preprocessor result
14 |
# File 'lib/unparser/preprocessor.rb', line 14 abstract_method :result |