Class: Idl::AryAccessSyntaxNode

Inherits:
SyntaxNode show all
Defined in:
lib/idlc/ast.rb

Overview

this is not used as an AST node; we use it split chained array accesses

For example, it helps us represent

X[rs1][31:0]

Instance Method Summary collapse

Methods inherited from Treetop::Runtime::SyntaxNode

#set_input_file, #set_input_file_unless_already_set, #space?

Instance Method Details

#to_astAstNode

fix up left recursion

Returns:

  • (AstNode)

    New tree rooted at the array access



2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
# File 'lib/idlc/ast.rb', line 2514

def to_ast
  var = send(:a).to_ast
  send(:brackets).elements.each do |bracket|
    var =
      if bracket.msb.empty?
        AryElementAccessAst.new(input, interval, var, bracket.lsb.to_ast)
      else
        AryRangeAccessAst.new(input, interval, var,
                              bracket.msb.expression.to_ast, bracket.lsb.to_ast)
      end
  end

  var
end