Class: Keisan::AST::LineBuilder
- Inherits:
-
Object
- Object
- Keisan::AST::LineBuilder
- Defined in:
- lib/keisan/ast/line_builder.rb
Instance Method Summary collapse
- #ast ⇒ Object
-
#initialize(components) ⇒ LineBuilder
constructor
Build from parser.
- #node ⇒ Object
Constructor Details
#initialize(components) ⇒ LineBuilder
Build from parser
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/keisan/ast/line_builder.rb', line 5 def initialize(components) @components = components @nodes = components_to_basic_nodes(@components) # Negative means not an operator @priorities = @nodes.map {|node| node.is_a?(Keisan::Parsing::Operator) ? node.priority : -1} consume_operators! case @nodes.count when 0 # Empty string, set to just Null @nodes = [Keisan::AST::Null.new] when 1 # Good else raise Keisan::Exceptions::ASTError.new("Should end up with a single node") end end |
Instance Method Details
#ast ⇒ Object
29 30 31 |
# File 'lib/keisan/ast/line_builder.rb', line 29 def ast node end |
#node ⇒ Object
25 26 27 |
# File 'lib/keisan/ast/line_builder.rb', line 25 def node @nodes.first end |