class Highway::Compiler::Parse::Tree::Root

This class represents a root node of a parse tree. It contains other nodes, such as variables and steps.

Attributes

steps[R]

Steps in the tree.

@return [Array<Highway::Compiler::Parse::Tree::Step>]

variables[R]

Variables in the tree.

@return [Array<Highway::Compiler::Parse::Tree::Variable>]

version[R]

Version of the parse tree.

@return [Integer]

Public Class Methods

new(version:) click to toggle source

Initialize an instance.

@param version [Integer] Version of the parse tree.

# File lib/highway/compiler/parse/tree/root.rb, line 23
def initialize(version:)
  @version = version
  @variables = Array.new()
  @steps = Array.new()
end

Public Instance Methods

add_step(name:, parameters:, preset:, stage:, index:) click to toggle source

Add a step to the tree.

@param index [Integer] Index of step in its scope. @param name [String] Name of the step. @param parameters [Hash] Parameters of the step. @param preset [String] Parent preset of the step. @param stage [String] Parent stage of the step.

@return [Void]

# File lib/highway/compiler/parse/tree/root.rb, line 64
def add_step(name:, parameters:, preset:, stage:, index:)
  @steps << Step.new(index: index, name: name, parameters: parameters, preset: preset, stage: stage)
end
add_variable(name:, value:, preset:) click to toggle source

Add a variable to the tree.

@param name [String] Name of the variable. @param value [String] Raw value of the variable. @param preset [String] Parent preset of the variable.

@return [Void]

# File lib/highway/compiler/parse/tree/root.rb, line 51
def add_variable(name:, value:, preset:)
  @variables << Variable.new(name: name, value: value, preset: preset)
end