Class: Idl::BinaryExpressionRightSyntaxNode
- Inherits:
-
Treetop::Runtime::SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- Idl::BinaryExpressionRightSyntaxNode
- Defined in:
- lib/idl/ast.rb
Instance Method Summary collapse
-
#to_ast ⇒ Object
fix up left recursion i.e., xlen() - 1 - i => (xlen() - 1) - i.
- #type_check(_symtab) ⇒ Object
Instance Method Details
#to_ast ⇒ Object
fix up left recursion i.e., xlen() - 1 - i => (xlen() - 1) - i
2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 |
# File 'lib/idl/ast.rb', line 2491 def to_ast first = BinaryExpressionAst.new( input, (interval.begin...r.elements[0].r.interval.end), l.to_ast, r.elements[0].op.text_value, r.elements[0].r.to_ast ) if r.elements.size == 1 first else r.elements[1..].inject(first) do |lhs, el| BinaryExpressionAst.new(input, (lhs.interval.begin...el.r.interval.end), lhs, el.op.text_value, el.r.to_ast) end end end |
#type_check(_symtab) ⇒ Object
2508 2509 2510 |
# File 'lib/idl/ast.rb', line 2508 def type_check(_symtab) raise "you must have forgotten the to_ast pass" end |