ELIP/Unlambda

From Esolang
Jump to navigation Jump to search
Back to ELIP

The ELIP Unlambda project is implemented using the Order preprocessor library. Order is a Lisp-like functional language, similar to Scheme (it even has call/cc, force and delay!) so it would be a good base for the Unlambda interpreter. Order's variables match the regex pattern 8[A-Z], or 8[A-Z][A-Z0-9] if "lib/ext_sym.h" is included. The combinators are implemented as Order lambda functions. They all begin with 6, and 6dot(string) is the .x output operator.

#include <order/interpreter.h>
#define ORDER_PP_DEF_6i			\
	ORDER_PP_FN(8fn(8A,		\
		8A			\
	))

#define ORDER_PP_DEF_6v			\
	ORDER_PP_FN(8fn(8A,		\
		6v			\
	))

#define ORDER_PP_DEF_6k			\
	ORDER_PP_FN(8fn(8A,		\
		8fn(8B,			\
			8A		\
	)))

#define ORDER_PP_DEF_6s						\
	ORDER_PP_FN(8fn(8A,					\
		8fn(8B,						\
			8fn(8C,					\
				8ap(8ap(8A,8C),8ap(8B,8C))	\
	))))

#define ORDER_PP_DEF_6dot(arg)			\
	ORDER_PP_MACRO(8fn(8A,			\
		8chain(				\
			8put(8(arg)),		\
			8A			\
	)))

#define ORDER_PP_DEF_6r				\
	ORDER_PP_FN(8fn(8A,			\
		8chain(				\
			8put(8(*NEWLINE*)),	\
			8A			\
	)))

#define ORDER_PP_DEF_6c			\
	ORDER_PP_FN(8fn(8A,		\
		8call_cc(8A)		\
	))

The combinators are complete, but there is no automatic translation from Unlambda into a form that can be used by the C preprocessor. This makes it a reduction instead of a true interpreter. Input is still not yet implemented, but can be done using a sequence of symbols as the source. The 6d function is not yet implemented, but it will probably use the 8delay builtin.