module Whitespace::Util

Constants

BINOPS

Public Class Methods

find_label(instructions, name) click to toggle source
# File lib/whitespace/util.rb, line 20
def find_label(instructions, name)
  instructions.each_with_index do |instr, i|
    return i if instr.instance_of?(ISA::Label) && instr.name == name
  end

  raise LabelError, "missing: \"#{name}\""
end
is_ascii?(n) click to toggle source
# File lib/whitespace/util.rb, line 8
def is_ascii?(n)
  n == 10 || n == 13 || (n >= 32 && n <= 127)
end
is_binop?(op) click to toggle source
# File lib/whitespace/util.rb, line 12
def is_binop?(op)
  BINOPS.include? op
end
is_integer?(n) click to toggle source
# File lib/whitespace/util.rb, line 4
def is_integer?(n)
  n.is_a? Integer
end
is_label?(name) click to toggle source
# File lib/whitespace/util.rb, line 16
def is_label?(name)
  name.instance_of?(String) && !/\A[ \t]+\z/.match(name).nil?
end