Class: Rucc::TokenGen
- Inherits:
-
Object
- Object
- Rucc::TokenGen
- Defined in:
- lib/rucc/token_gen.rb
Instance Attribute Summary collapse
-
#pos ⇒ Object
Returns the value of attribute pos.
Instance Method Summary collapse
-
#initialize(files) ⇒ TokenGen
constructor
A new instance of TokenGen.
- #make_char(c, enc) ⇒ Token
- #make_ident(p) ⇒ Token
- #make_invalid(c) ⇒ Token
- #make_keyword(id) ⇒ Token
- #make_number(s) ⇒ Token
- #make_strtok(s, enc) ⇒ Token
- #make_token(kind, value = {}) ⇒ Token
Constructor Details
#initialize(files) ⇒ TokenGen
Returns a new instance of TokenGen.
6 7 8 9 |
# File 'lib/rucc/token_gen.rb', line 6 def initialize(files) @files = files @pos = nil end |
Instance Attribute Details
#pos ⇒ Object
Returns the value of attribute pos.
10 11 12 |
# File 'lib/rucc/token_gen.rb', line 10 def pos @pos end |
Instance Method Details
#make_char(c, enc) ⇒ Token
45 46 47 |
# 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) ⇒ Token
38 39 40 |
# File 'lib/rucc/token_gen.rb', line 38 def make_ident(p) make_token(T::IDENT, sval: p) end |
#make_invalid(c) ⇒ Token
64 65 66 |
# File 'lib/rucc/token_gen.rb', line 64 def make_invalid(c) make_token(T::INVALID, c: c) end |
#make_keyword(id) ⇒ Token
58 59 60 |
# File 'lib/rucc/token_gen.rb', line 58 def make_keyword(id) make_token(T::KEYWORD, id: id) end |
#make_number(s) ⇒ Token
32 33 34 |
# File 'lib/rucc/token_gen.rb', line 32 def make_number(s) make_token(T::NUMBER, sval: s) end |
#make_strtok(s, enc) ⇒ Token
52 53 54 |
# 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 = {}) ⇒ Token
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# 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 |