Class: Vinter::Parser

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

Instance Method Summary collapse

Constructor Details

#initialize(tokens, source_text = nil) ⇒ Parser

Returns a new instance of Parser.



4
5
6
7
8
9
10
# File 'lib/vinter/parser.rb', line 4

def initialize(tokens, source_text = nil)
  @tokens = tokens
  @position = 0
  @errors = []
  @warnings = []
  @source_text = source_text
end

Instance Method Details

#parseObject



12
13
14
15
16
17
18
19
# File 'lib/vinter/parser.rb', line 12

def parse
  result = parse_program
  {
    ast: result,
    errors: @errors,
    warnings: @warnings
  }
end