Class: Stupidedi::Parser::InstructionTable

Inherits:
Object
  • Object
show all
Includes:
Inspect
Defined in:
lib/stupidedi/parser/instruction_table.rb

Direct Known Subclasses

NonEmpty

Defined Under Namespace

Classes: NonEmpty

Constant Summary collapse

Empty =
Class.new(InstructionTable) do
  # @return [Empty]
  def copy(changes = {})
    self
  end

  # @return [Integer]
  def length
    0
  end

  def empty?
    true
  end

  # @return nil
  def at(segment_use)
    nil
  end

  # @return [NonEmpty]
  def push(instructions)
    InstructionTable::NonEmpty.new(instructions, self)
  end

  def matches(segment_tok, strict = false, mode = :insert)
    raise Exceptions::ParseError,
      "empty stack"
  end

  # @return [Empty]
  def pop(count)
    if count.zero?
      self
    else
      "empty stack"
    end
  end

  # @return [Empty]
  def drop(count)
    self
  end

  # @return [void]
  # :nocov:
  def pretty_print(q)
    q.text "InstructionTable.empty"
  end
  # :nocov:
end.new

Constructors collapse

Methods included from Inspect

#inspect

Class Method Details

.build(instructions) ⇒ InstructionTable::NonEmpty



214
215
216
# File 'lib/stupidedi/parser/instruction_table.rb', line 214

def build(instructions)
  empty.push(instructions)
end

.emptyInstructionTable::Empty



209
210
211
# File 'lib/stupidedi/parser/instruction_table.rb', line 209

def empty
  InstructionTable::Empty
end