Class: AbiCoderRb::AbiTokenizer

Inherits:
Object
  • Object
show all
Defined in:
lib/abi_coder_rb/parser/abi_tokenizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(abi) ⇒ AbiTokenizer

Returns a new instance of AbiTokenizer.



3
4
5
6
# File 'lib/abi_coder_rb/parser/abi_tokenizer.rb', line 3

def initialize(abi)
  @abi = abi
  @index = 0
end

Instance Method Details

#next_tokenObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/abi_coder_rb/parser/abi_tokenizer.rb', line 8

def next_token
  skip_whitespace

  return nil if @index >= @abi.length

  char = @abi[@index]

  case char
  when '(', ')', ',', '[', ']'
    @index += 1
    char
  else
    read_identifier
  end
end

#peek_tokenObject



24
25
26
27
28
29
# File 'lib/abi_coder_rb/parser/abi_tokenizer.rb', line 24

def peek_token
  original_index = @index
  token = next_token
  @index = original_index
  token
end