Class: Deadfire::FrontEnd::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/deadfire/front_end/scanner.rb

Instance Method Summary collapse

Constructor Details

#initialize(source, error_reporter) ⇒ Scanner

Returns a new instance of Scanner.



6
7
8
9
10
11
12
13
14
# File 'lib/deadfire/front_end/scanner.rb', line 6

def initialize(source, error_reporter)
  @source = source
  @total_chars = @source.length
  @tokens = []
  @start = 0
  @current = 0
  @line = 1
  @error_reporter = error_reporter
end

Instance Method Details

#tokenizeObject



16
17
18
19
20
21
22
23
# File 'lib/deadfire/front_end/scanner.rb', line 16

def tokenize
  until at_end?
    reset_counter
    scan_token
  end

  @tokens << Token.new(:eof, "", nil, @line)
end