Class: Logicality::Parser::SimpleParser
- Inherits:
-
Object
- Object
- Logicality::Parser::SimpleParser
- Defined in:
- lib/logicality/parser/simple_parser.rb
Overview
Parser that takes in a lexer and can take its parsed grammar and turn it into an abstract syntax tree.
Instance Attribute Summary collapse
-
#lexer ⇒ Object
readonly
Returns the value of attribute lexer.
Instance Method Summary collapse
-
#initialize(lexer) ⇒ SimpleParser
constructor
A new instance of SimpleParser.
- #parse ⇒ Object
Constructor Details
#initialize(lexer) ⇒ SimpleParser
Returns a new instance of SimpleParser.
17 18 19 20 21 22 23 |
# File 'lib/logicality/parser/simple_parser.rb', line 17 def initialize(lexer) @lexer = lexer @current_token = lexer.next_token raise ArgumentError, 'Lexer must contain at least one token' if @current_token.nil? end |
Instance Attribute Details
#lexer ⇒ Object (readonly)
Returns the value of attribute lexer.
15 16 17 |
# File 'lib/logicality/parser/simple_parser.rb', line 15 def lexer @lexer end |
Instance Method Details
#parse ⇒ Object
25 26 27 |
# File 'lib/logicality/parser/simple_parser.rb', line 25 def parse expr end |