Class: RDoc::Parser::RipperStateLex (Ruby 2.7.3)
Description: Class : RDoc::Parser::RipperStateLex - Ruby 2.7.3

### Home Classes Methods

### In Files

- rdoc/parser/ripper_state_lex.rb
- rdoc/parser/ruby.rb

### Parent

Object

### Namespace

- CLASS RDoc::Parser::RipperStateLex::InnerStateLex

### Methods

- ::end?
- ::new
- ::parse
- #get_squashed_tk

### Class/Module Index

Quicksearch

- RDoc
- RDoc::Alias
- RDoc::AnonClass
- RDoc::AnyMethod
- RDoc::Attr
- RDoc::ClassModule
- RDoc::CodeObject
- RDoc::Comment
- RDoc::Constant
- RDoc::Context
- RDoc::Context::Section
- RDoc::CrossReference
- RDoc::ERBIO
- RDoc::ERBPartial
- RDoc::Encoding
- RDoc::Error
- RDoc::Extend
- RDoc::Generator
- RDoc::Generator::Darkfish
- RDoc::Generator::JsonIndex
- RDoc::Generator::Markup
- RDoc::Generator::POT
- RDoc::Generator::POT::MessageExtractor
- RDoc::Generator::POT::PO
- RDoc::Generator::POT::POEntry
- RDoc::Generator::RI
- RDoc::GhostMethod
- RDoc::I18n
- RDoc::I18n::Locale
- RDoc::I18n::Text
- RDoc::Include
- RDoc::Markdown
- RDoc::Markdown::Literals
- RDoc::Markup
- RDoc::Markup::AttrChanger
- RDoc::Markup::AttrSpan
- RDoc::Markup::AttributeManager
- RDoc::Markup::Attributes
- RDoc::Markup::BlankLine
- RDoc::Markup::BlockQuote
- RDoc::Markup::Document
- RDoc::Markup::Formatter
- RDoc::Markup::HardBreak
- RDoc::Markup::Include
- RDoc::Markup::IndentedParagraph
- RDoc::Markup::List
- RDoc::Markup::ListItem
- RDoc::Markup::Paragraph
- RDoc::Markup::Parser
- RDoc::Markup::Parser::Error
- RDoc::Markup::Parser::MyStringScanner
- RDoc::Markup::Parser::ParseError
- RDoc::Markup::PreProcess
- RDoc::Markup::Raw
- RDoc::Markup::RegexpHandling
- RDoc::Markup::Rule
- RDoc::Markup::ToAnsi
- RDoc::Markup::ToBs
- RDoc::Markup::ToHtml
- RDoc::Markup::ToHtmlCrossref
- RDoc::Markup::ToHtmlSnippet
- RDoc::Markup::ToJoinedParagraph
- RDoc::Markup::ToLabel
- RDoc::Markup::ToMarkdown
- RDoc::Markup::ToRdoc
- RDoc::Markup::ToTableOfContents
- RDoc::Markup::ToTest
- RDoc::Markup::ToTtOnly
- RDoc::Markup::Verbatim
- RDoc::MetaMethod
- RDoc::MethodAttr
- RDoc::Mixin
- RDoc::NormalClass
- RDoc::NormalModule
- RDoc::Options
- RDoc::Parser
- RDoc::Parser::C
- RDoc::Parser::ChangeLog
- RDoc::Parser::Markdown
- RDoc::Parser::RD
- RDoc::Parser::RipperStateLex
- RDoc::Parser::RipperStateLex::InnerStateLex
- RDoc::Parser::Ruby
- RDoc::Parser::RubyTools
- RDoc::Parser::Simple
- RDoc::Parser::Text
- RDoc::RD
- RDoc::RD::BlockParser
- RDoc::RD::Inline
- RDoc::RD::InlineParser
- RDoc::RDoc
- RDoc::RI
- RDoc::RI::Driver
- RDoc::RI::Driver::Error
- RDoc::RI::Driver::NotFoundError
- RDoc::RI::Error
- RDoc::RI::Paths
- RDoc::RI::Task
- RDoc::Require
- RDoc::RubygemsHook
- RDoc::Servlet
- RDoc::SingleClass
- RDoc::Stats
- RDoc::Stats::Normal
- RDoc::Stats::Quiet
- RDoc::Stats::Verbose
- RDoc::Store
- RDoc::Store::Error
- RDoc::Store::MissingFileError
- RDoc::Task
- RDoc::Text
- RDoc::TokenStream
- RDoc::TomDoc
- RDoc::TopLevel
- RDocTask

No matching classes.

# RDoc::Parser::RipperStateLex

### Constants

EXPR_ARG
EXPR_ARG_ANY
EXPR_BEG
EXPR_BEG_ANY
EXPR_CLASS
EXPR_CMDARG
EXPR_DOT
EXPR_END
EXPR_ENDARG
EXPR_ENDFN
EXPR_END_ANY
EXPR_FITEM
EXPR_FNAME
EXPR_LABEL
EXPR_LABELED
EXPR_MID
EXPR_NONE
EXPR_VALUE
RIPPER_HAS_LEX_STATE

  TODO: Remove this constants after Ruby 2.4 EOL

Token

### Public Class Methods

end?(token) click to toggle source

                   # File rdoc/parser/ripper_state_lex.rb, line 587
    def self.end?(token)
      (token[:state] & EXPR_END)
    end

new(code) click to toggle source

                   # File rdoc/parser/ripper_state_lex.rb, line 568
    def initialize(code)
      @buf = []
      @heredoc_queue = []
      @inner_lex = InnerStateLex.new(code)
      @tokens = @inner_lex.parse([])
    end

parse(code) click to toggle source

                   # File rdoc/parser/ripper_state_lex.rb, line 575
    def self.parse(code)
      lex = self.new(code)
      tokens = []
      begin
        while tk = lex.get_squashed_tk
          tokens.push tk
        end
      rescue StopIteration
      end
      tokens
    end

### Public Instance Methods

get_squashed_tk() click to toggle source

                   # File rdoc/parser/ripper_state_lex.rb, line 317
    def get_squashed_tk
      if @buf.empty?
        tk = @tokens.shift
      else
        tk = @buf.shift
      end
      return nil if tk.nil?
      case tk[:kind]
      when :on_symbeg then
        tk = get_symbol_tk(tk)
      when :on_tstring_beg then
        tk = get_string_tk(tk)
      when :on_backtick then
        if (tk[:state] & (EXPR_FNAME | EXPR_ENDFN)) != 0
          @inner_lex.lex_state = EXPR_ARG unless RIPPER_HAS_LEX_STATE
          tk[:kind] = :on_ident
          tk[:state] = Ripper::Lexer.const_defined?(:State) ? Ripper::Lexer::State.new(EXPR_ARG) : EXPR_ARG
        else
          tk = get_string_tk(tk)
        end
      when :on_regexp_beg then
        tk = get_regexp_tk(tk)
      when :on_embdoc_beg then
        tk = get_embdoc_tk(tk)
      when :on_heredoc_beg then
        @heredoc_queue << retrieve_heredoc_info(tk)
        @inner_lex.lex_state = EXPR_END unless RIPPER_HAS_LEX_STATE
      when :on_nl, :on_ignored_nl, :on_comment, :on_heredoc_end then
        if !@heredoc_queue.empty?
          get_heredoc_tk(*@heredoc_queue.shift)
        elsif tk[:text].nil? # :on_ignored_nl sometimes gives nil
          tk[:text] = ''
        end
      when :on_words_beg then
        tk = get_words_tk(tk)
      when :on_qwords_beg then
        tk = get_words_tk(tk)
      when :on_symbols_beg then
        tk = get_words_tk(tk)
      when :on_qsymbols_beg then
        tk = get_words_tk(tk)
      when :on_op then
        if '&.' == tk[:text]
          tk[:kind] = :on_period
        else
          tk = get_op_tk(tk)
        end
      end
      tk
    end