module Rucc::Parser::Ensure

Private Instance Methods

ensure_arithtype!(node) click to toggle source
# File lib/rucc/parser/ensure.rb, line 23
def ensure_arithtype!(node)
  if !Type.is_arithtype(node.ty)
    raise "arithmetic type expected, but got #{node}"
    # error("arithmetic type expected, but got %s", node2s(node));
  end
end
ensure_inttype!(node) click to toggle source

@param [Node] node

# File lib/rucc/parser/ensure.rb, line 31
def ensure_inttype!(node)
  if !Type.is_inttype(node.ty)
    raise "integer type expected, but got #{node}"
    # error("integer type expected, but got %s", node2s(node));
  end
end
ensure_lvalue!(node) click to toggle source

@param [Node] node

# File lib/rucc/parser/ensure.rb, line 14
def ensure_lvalue!(node)
  case node.kind
  when AST::LVAR, AST::GVAR, AST::DEREF, AST::STRUCT_REF
    return
  else
    raise "lvalue expected, but got #{node}"
  end
end
ensure_not_void!(ty) click to toggle source
# File lib/rucc/parser/ensure.rb, line 7
def ensure_not_void!(ty)
  if ty.kind == Kind::VOID
    raise "void is not allowed"
  end
end