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.



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

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

Instance Method Details

#parseObject



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

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