class RuboCop::AST::NodePattern::Lexer
Lexer
class for `NodePattern`
Doc on how this fits in the compiling process:
/docs/modules/ROOT/pages/node_pattern.adoc
Constants
- Error
- REGEXP_OPTIONS
Attributes
comments[R]
source_buffer[R]
tokens[R]
Public Class Methods
new(source)
click to toggle source
Calls superclass method
# File lib/rubocop/ast/node_pattern/lexer.rb, line 31 def initialize(source) @tokens = [] super() parse(source) end
Private Instance Methods
do_parse()
click to toggle source
# 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) { |value| ... }
click to toggle source
@return [token]
# File lib/rubocop/ast/node_pattern/lexer.rb, line 40 def emit(type) value = ss[1] || ss.matched value = yield value if block_given? token = token(type, value) @tokens << token token end
emit_comment()
click to toggle source
# File lib/rubocop/ast/node_pattern/lexer.rb, line 48 def emit_comment nil end
emit_regexp()
click to toggle source
# File lib/rubocop/ast/node_pattern/lexer.rb, line 52 def emit_regexp body = ss[1] options = ss[2] flag = options.each_char.sum { |c| REGEXP_OPTIONS[c] } emit(:tREGEXP) { Regexp.new(body, flag) } end
token(type, value)
click to toggle source
# File lib/rubocop/ast/node_pattern/lexer.rb, line 64 def token(type, value) [type, value] end