Class: RuboCop::AST::NodePattern::Parser
- Inherits:
-
Racc::Parser
- Object
- Racc::Parser
- RuboCop::AST::NodePattern::Parser
- Extended by:
- SimpleForwardable
- Defined in:
- lib/rubocop/ast/node_pattern/parser.rb,
lib/rubocop/ast/node_pattern/with_meta.rb
Overview
Parser for NodePattern Note: class reopened in ‘parser.racc`
Doc on how this fits in the compiling process:
/docs/modules/ROOT/pages/node_pattern.adoc
Direct Known Subclasses
Defined Under Namespace
Classes: WithMeta
Constant Summary collapse
- Builder =
NodePattern::Builder
- Lexer =
NodePattern::Lexer
Instance Method Summary collapse
-
#initialize(builder = self.class::Builder.new) ⇒ Parser
constructor
A new instance of Parser.
- #inspect ⇒ Object
-
#parse(source) ⇒ NodePattern::Node
(Similar API to ‘parser` gem) Parses a source and returns the AST.
Methods included from SimpleForwardable
Constructor Details
#initialize(builder = self.class::Builder.new) ⇒ Parser
Returns a new instance of Parser.
19 20 21 22 |
# File 'lib/rubocop/ast/node_pattern/parser.rb', line 19 def initialize(builder = self.class::Builder.new) super() @builder = builder end |
Instance Method Details
#inspect ⇒ Object
40 41 42 |
# File 'lib/rubocop/ast/node_pattern/parser.rb', line 40 def inspect "<##{self.class}>" end |
#parse(source) ⇒ NodePattern::Node
(Similar API to ‘parser` gem) Parses a source and returns the AST.
31 32 33 34 35 36 37 38 |
# File 'lib/rubocop/ast/node_pattern/parser.rb', line 31 def parse(source) @lexer = self.class::Lexer.new(source) do_parse rescue Lexer::Error => e raise NodePattern::Invalid, e. ensure @lexer = nil # Don't keep references end |