class Rucc::TokenGen
Attributes
pos[RW]
Public Class Methods
new(files)
click to toggle source
@param [FileIOList] files
# File lib/rucc/token_gen.rb, line 6 def initialize(files) @files = files @pos = nil end
Public Instance Methods
make_char(c, enc)
click to toggle source
@param [Integer] c @param [ENC] enc @return [Token]
# File lib/rucc/token_gen.rb, line 45 def make_char(c, enc) make_token(T::CHAR, c: c, enc: enc) end
make_ident(p)
click to toggle source
@param [String] p @return [Token]
# File lib/rucc/token_gen.rb, line 38 def make_ident(p) make_token(T::IDENT, sval: p) end
make_invalid(c)
click to toggle source
@param [Integer] c @return [Token]
# File lib/rucc/token_gen.rb, line 64 def make_invalid(c) make_token(T::INVALID, c: c) end
make_keyword(id)
click to toggle source
@param [Char] id @return [Token]
# File lib/rucc/token_gen.rb, line 58 def make_keyword(id) make_token(T::KEYWORD, id: id) end
make_number(s)
click to toggle source
@param [String] s @return [Token]
# File lib/rucc/token_gen.rb, line 32 def make_number(s) make_token(T::NUMBER, sval: s) end
make_strtok(s, enc)
click to toggle source
@param [String] s @param [ENC] enc @return [Token]
# File lib/rucc/token_gen.rb, line 52 def make_strtok(s, enc) make_token(T::STRING, sval: s, enc: enc) end
make_token(kind, value = {})
click to toggle source
@param [T] kind @param [Hash] value @return [Token]
# File lib/rucc/token_gen.rb, line 16 def make_token(kind, value = {}) f = @files.current Util.assert!{ !pos.nil? } params = { file: f, count: f.ntok, hideset: Set.new, line: pos.line, column: pos.column, } f.incr_ntok! Token.new(kind, value.merge(params)) end