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
Constructor Details
.new(source) ⇒ LexRipper
Instance Attribute Details
#source (readonly)
[ GitHub ]# File 'lib/prism/lex_compat.rb', line 853
attr_reader :source
Instance Method Details
#result
[ GitHub ]# File 'lib/prism/lex_compat.rb', line 859
def result previous = [] results = [] Ripper.lex(source, raise_errors: true).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