Class: Logicality::Parser::SimpleParser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lexer) ⇒ SimpleParser

Returns a new instance of SimpleParser.



14
15
16
17
18
19
20
21
22
23
# File 'lib/logicality/parser/simple_parser.rb', line 14

def initialize(lexer)
  @lexer = lexer

  @current_token = lexer.next_token

  if @current_token.nil?
    raise ArgumentError, 'Lexer must contain at least one token'
  end

end

Instance Attribute Details

#lexerObject (readonly)

Returns the value of attribute lexer.



12
13
14
# File 'lib/logicality/parser/simple_parser.rb', line 12

def lexer
  @lexer
end

Instance Method Details

#parseObject



25
26
27
# File 'lib/logicality/parser/simple_parser.rb', line 25

def parse
  expr
end