klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 549680e61bdf282f27c1790278a60e4a9056f953
parent 4d9d94a2bd9ad6f3fd5c69512b06225a56ffb755
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Tue,  5 Apr 2011 12:07:59 -0300

Added bind_al3tp & bind_al3p macros (needed for reduce).

Diffstat:
Msrc/kghelpers.h | 33+++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+), 0 deletions(-)

diff --git a/src/kghelpers.h b/src/kghelpers.h @@ -157,6 +157,39 @@ return; \ } +/* bind at least 3 parameters, like (v1_ v2_ v3_ . v4_) */ +#define bind_al3p(K_, n_, ptree_, v1_, v2_, v3_, v4_) \ + bind_al3tp((K_), (n_), (ptree_), "any", anytype, (v1_), \ + "any", anytype, (v2_), "any", anytype, (v3_), (v4_)) \ + +/* bind at least 3 parameters (with type), like (v1_ v2_ v3_ . v4_) */ +#define bind_al3tp(K_, n_, ptree_, tstr1_, t1_, v1_, \ + tstr2_, t2_, v2_, tstr3_, t3_, v3_, v4_) \ + TValue v1_, v2_, v3_, v4_; \ + if (!ttispair(ptree_) || !ttispair(kcdr(ptree_)) || \ + !ttispair(kcddr(ptree_))) { \ + klispE_throw_extra(K_, n_ , ": Bad ptree (expected at least " \ + "three arguments)"); \ + return; \ + } \ + v1_ = kcar(ptree_); \ + v2_ = kcadr(ptree_); \ + v3_ = kcaddr(ptree_); \ + v4_ = kcdddr(ptree_); \ + if (!t1_(v1_)) { \ + klispE_throw_extra(K_, n_, ": Bad type on first argument (expected " \ + tstr1_ ")"); \ + return; \ + } else if (!t2_(v2_)) { \ + klispE_throw_extra(K_, n_, ": Bad type on second argument (expected " \ + tstr2_ ")"); \ + return; \ + } else if (!t3_(v3_)) { \ + klispE_throw_extra(K_, n_, ": Bad type on third argument (expected " \ + tstr3_ ")"); \ + return; \ + } + /* returns true if the obj pointed by par is a list of one element of type type, and puts that element in par