class Yard2steep::Type

Constants

S_RE
TOKENS

Public Class Methods

new(text) click to toggle source

@param [String] text

# File lib/yard2steep/type.rb, line 14
def initialize(text)
  @text = text
end
translate(text) click to toggle source

@param [String] text @return [String]

# File lib/yard2steep/type.rb, line 9
def self.translate(text)
  Type.new(text).translate
end

Public Instance Methods

tokens(str) click to toggle source

@param [String] str @return [Array<String>]

# File lib/yard2steep/type.rb, line 32
def tokens(str)
  r = []
  s = StringScanner.new(str)
  while true
    s.scan(S_RE)
    break if s.eos?
    if t = s.scan(TOKENS)
      r.push(t)
    else
      raise "token must exist!"
    end
  end
  r
end
translate() click to toggle source

@return [String]

# File lib/yard2steep/type.rb, line 19
def translate
  tokens = tokens(@text)
  ast = Parser.parse(tokens)
  ast.to_s
end