Class: RuboCop::AST::NodePattern::Lexer
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
LexerRex
|
|
Instance Chain:
self,
LexerRex
|
|
Inherits: |
LexerRex
|
Defined in: | lib/rubocop/ast/node_pattern/lexer.rb |
Overview
Lexer class for ::RuboCop::AST::NodePattern
Doc on how this fits in the compiling process: /docs/modules/ROOT/pages/node_pattern.adoc
Constant Summary
-
Error =
# File 'lib/rubocop/ast/node_pattern/lexer.rb', line 19ScanError
-
REGEXP_OPTIONS =
private
# File 'lib/rubocop/ast/node_pattern/lexer.rb', line 21{ 'i' => ::Regexp::IGNORECASE, 'm' => ::Regexp::MULTILINE, 'x' => ::Regexp::EXTENDED, 'o' => 0 }.freeze
Class Method Summary
- .new(source) ⇒ Lexer constructor
Instance Attribute Summary
- #comments readonly
- #source_buffer readonly
- #tokens readonly
Instance Method Summary
- #do_parse private
- #emit(type) ⇒ token private
- #emit_comment private
- #emit_regexp private
- #token(type, value) private
Constructor Details
.new(source) ⇒ Lexer
# File 'lib/rubocop/ast/node_pattern/lexer.rb', line 31
def initialize(source) @tokens = [] super() parse(source) end
Instance Attribute Details
#comments (readonly)
[ GitHub ]# File 'lib/rubocop/ast/node_pattern/lexer.rb', line 29
attr_reader :source_buffer, :comments, :tokens
#source_buffer (readonly)
[ GitHub ]#tokens (readonly)
[ GitHub ]# File 'lib/rubocop/ast/node_pattern/lexer.rb', line 29
attr_reader :source_buffer, :comments, :tokens
Instance Method Details
#do_parse (private)
[ GitHub ]# File 'lib/rubocop/ast/node_pattern/lexer.rb', line 60
def do_parse # Called by the generated `parse` method, do nothing here. end
#emit(type) ⇒ token (private)
#emit_comment (private)
[ GitHub ]# File 'lib/rubocop/ast/node_pattern/lexer.rb', line 48
def emit_comment nil end
#emit_regexp (private)
[ GitHub ]# File 'lib/rubocop/ast/node_pattern/lexer.rb', line 52
def emit_regexp body = ss[1] = ss[2] flag = .each_char.sum { |c| REGEXP_OPTIONS[c] } emit(:tREGEXP) { Regexp.new(body, flag) } end
#token(type, value) (private)
[ GitHub ]# File 'lib/rubocop/ast/node_pattern/lexer.rb', line 64
def token(type, value) [type, value] end