Skip to Content Skip to Search

Wrapper for Ripper lex states

Namespace
Methods
E
N
P

Class Public methods

end?(token)

Returns true if lex state will be END after token.

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

new(code)

New lexer for code.

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

parse(code)

Returns tokens parsed from code.

# File ruby/lib/rdoc/parser/ripper_state_lex.rb, line 584
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