Class: Idl::BinaryExpressionRightSyntaxNode
- Inherits:
-
SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- SyntaxNode
- Idl::BinaryExpressionRightSyntaxNode
- Defined in:
- lib/idlc/ast.rb
Instance Method Summary collapse
-
#to_ast ⇒ Object
fix up left recursion i.e., xlen() - 1 - i => (xlen() - 1) - i.
- #type_check(_symtab, strict:) ⇒ Object
Methods inherited from Treetop::Runtime::SyntaxNode
#set_input_file, #set_input_file_unless_already_set, #space?
Instance Method Details
#to_ast ⇒ Object
fix up left recursion i.e., xlen() - 1 - i => (xlen() - 1) - i
4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 |
# File 'lib/idlc/ast.rb', line 4055 def to_ast first = BinaryExpressionAst.new( input, (interval.begin...send(:r).elements[0].r.interval.end), send(:l).to_ast, send(:r).elements[0].op.text_value, send(:r).elements[0].r.to_ast ) if send(:r).elements.size == 1 first else send(: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, strict:) ⇒ Object
4072 4073 4074 |
# File 'lib/idlc/ast.rb', line 4072 def type_check(_symtab, strict:) raise "you must have forgotten the to_ast pass" end |