#ifndef _VAE_H #define _VAE_H #include "va.h" typedef Value (*Function)(Value); void VA__INIT(void); typedef enum { NILAD, MONAD, DYAD, TRIAD } Arity; typedef struct { char *name; Arity arity; Function function; } ExternalFunction; typedef enum { FUNCTION, VARIABLE } ExternalType; typedef struct { ExternalFunction function; ExternalType type; } External; #define FUNDEF(n) \ Value n(Value args) { \ Value x, y, z; \ x = y = z = Nil; \ switch (lenof(args)) { \ case 1: x = FIRST(args); break; \ case 2: x = FIRST(args); y = SECOND(args); break; \ case 3: x = FIRST(args); y = SECOND(args); z = THIRD(args); break; \ } #define FUN(n, a, f) {{n, a, f}, FUNCTION} #define VAR(n, v) {{n, 0, v}, VARIABLE} #define VARSET(n, v) Value n(Value _N_) { return (v); } #define INIT void VA__INIT(void) #define EXPORT(c) int __VA_EXPORTED__ = c; External __VA_EXPORT__[c] = #endif