class RDoc::Parser::RipperStateLex
Ripper 词法状态的包装器
公共类方法
end?(token) 点击切换源代码
如果词法状态在 token 之后变为 END,则返回 true。
# File rdoc/parser/ripper_state_lex.rb, line 299 def self.end?(token) (token[:state] & EXPR_END) end
new(code) 点击切换源代码
为 code 创建新的词法分析器。
# File rdoc/parser/ripper_state_lex.rb, line 278 def initialize(code) @buf = [] @heredoc_queue = [] @inner_lex = InnerStateLex.new(code) @tokens = @inner_lex.parse([]) end
parse(code) 点击切换源代码
返回从 code 解析的标记。
# File rdoc/parser/ripper_state_lex.rb, line 286 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