Class: Prism::LexRipper
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/prism/lex_compat.rb |
Overview
This is a class that wraps the Ripper lexer to produce almost exactly the same tokens.
Class Method Summary
- .new(source) ⇒ LexRipper constructor
Instance Attribute Summary
- #source readonly
Instance Method Summary
- #result
-
#lex(source)
private
See additional method definition at line 913.
Constructor Details
.new(source) ⇒ LexRipper
Instance Attribute Details
#source (readonly)
[ GitHub ]# File 'lib/prism/lex_compat.rb', line 873
attr_reader :source
Instance Method Details
#lex(source) (private)
See additional method definition at line 913.
#result
[ GitHub ]# File 'lib/prism/lex_compat.rb', line 879
def result previous = [] #: [[Integer, Integer], Symbol, String, untyped] | [] results = [] #: Array[[[Integer, Integer], Symbol, String, untyped]] lex(source).each do |token| case token[1] when :on_sp # skip when :on_tstring_content if previous[1] == :on_tstring_content && (token[2].start_with?("\#$") || token[2].start_with?("\#@")) previous[2] << token[2] else results << token previous = token end when :on_words_sep if previous[1] == :on_words_sep previous[2] << token[2] else results << token previous = token end else results << token previous = token end end results end