klisp

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

commit 1d7e0678dc3635630fb09fab8b4ea8363274d583
parent 8fcae1880075ee63492dc1dff4e623ffce0cf89f
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Sun, 13 Mar 2011 03:04:07 -0300

Added continuation? to the ground environment.

Diffstat:
Msrc/Makefile | 8++++++--
Asrc/kgcontinuations.h | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/kgenvironments.c | 2--
Msrc/kground.c | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 118 insertions(+), 4 deletions(-)

diff --git a/src/Makefile b/src/Makefile @@ -12,7 +12,7 @@ CORE_O= kobject.o ktoken.o kpair.o kstring.o ksymbol.o kread.o \ kcontinuation.o koperative.o kapplicative.o keval.o krepl.o \ kground.o kghelpers.o kgbooleans.o kgeqp.o kgequalp.o \ kgsymbols.o kgcontrol.o kgpairs_lists.o kgpair_mut.o kgenvironments.o \ - kgenv_mut.o kgcombiners.o + kgenv_mut.o kgcombiners.o kgcontinuations.o KRN_T= klisp KRN_O= klisp.o @@ -70,7 +70,8 @@ krepl.o: krepl.c krepl.h kcontinuation.h kstate.h kobject.h keval.h klisp.h \ kground.o: kground.c kground.h kstate.h kobject.h klisp.h kenvironment.h \ kapplicative.h koperative.h ksymbol.h kerror.h kghelpers.h \ kgbooleans.h kgeqp.h kgequalp.h kgsymbols.h kgpairs_lists.h \ - kgpair_mut.h kgenvironments.h kgenv_mut.h kgcombiners.h + kgpair_mut.h kgenvironments.h kgenv_mut.h kgcombiners.h \ + kgcontinuations.h kghelpers.o: kghelpers.c kghelpers.h kstate.h kstate.h klisp.h kpair.h \ kapplicative.h koperative.h kerror.h kobject.h ksymbol.h kgbooleans.o: kgbooleans.c kgbooleans.c kghelpers.h kstate.h klisp.h \ @@ -96,3 +97,6 @@ kgenv_mut.o: kgenv_mut.c kgenv_mut.h kghelpers.h kstate.h \ kgcombiners.o: kgcombiners.c kgenvironments.h kghelpers.h kstate.h \ klisp.h kobject.h kerror.h kpair.h ksymbol.h kcontinuation.h \ kenvironment.h kapplicative.h koperative.h +kgcontinuations.o: kgcontinuations.c kgcontinuations.h kghelpers.h kstate.h \ + klisp.h kobject.h kerror.h kpair.h ksymbol.h kcontinuation.h \ + kenvironment.h kapplicative.h koperative.h diff --git a/src/kgcontinuations.h b/src/kgcontinuations.h @@ -0,0 +1,54 @@ +/* +** kgcontinuations.h +** Continuations features for the ground environment +** See Copyright Notice in klisp.h +*/ + +#ifndef kgcontinuations_h +#define kgcontinuations_h + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <stdint.h> + +#include "kobject.h" +#include "klisp.h" +#include "kstate.h" +#include "kghelpers.h" + +/* 7.1.1 continuation? */ +/* uses typep */ + +/* 7.2.2 call/cc */ +/* TODO */ + +/* 7.2.3 extend-continuation */ +/* TODO */ + +/* 7.2.4 guard-continuation */ +/* TODO */ + +/* 7.2.5 continuation->applicative */ +/* TODO */ + +/* 7.2.6 root-continuation */ +/* TODO */ + +/* 7.2.7 error-continuation */ +/* TODO */ + +/* 7.3.1 apply-continuation */ +/* TODO */ + +/* 7.3.2 $let/cc */ +/* TODO */ + +/* 7.3.3 guard-dynamic-extent */ +/* TODO */ + +/* 7.3.4 exit */ +/* TODO */ + +#endif diff --git a/src/kgenvironments.c b/src/kgenvironments.c @@ -12,9 +12,7 @@ #include "kstate.h" #include "kobject.h" -#include "kground.h" #include "kpair.h" -#include "kstring.h" #include "kenvironment.h" #include "kcontinuation.h" #include "ksymbol.h" diff --git a/src/kground.c b/src/kground.c @@ -30,6 +30,7 @@ #include "kgenvironments.h" #include "kgenv_mut.h" #include "kgcombiners.h" +#include "kgcontinuations.h" /* ** BEWARE: this is highly unhygienic, it assumes variables "symbol" and @@ -329,5 +330,62 @@ TValue kmake_ground_env(klisp_State *K) /* 5.10.1 $let */ /* TODO */ + + /* + ** + ** 6 Core library features (II) + ** + */ + + /* ... */ + + /* + ** + ** 7 Continuations + ** + */ + + /* + ** 7.2 Primitive features + */ + + /* 7.1.1 continuation? */ + add_applicative(K, ground_env, "continuation?", typep, 2, symbol, + i2tv(K_TCONTINUATION)); + + /* 7.2.2 call/cc */ + /* TODO */ + + /* 7.2.3 extend-continuation */ + /* TODO */ + + /* 7.2.4 guard-continuation */ + /* TODO */ + + /* 7.2.5 continuation->applicative */ + /* TODO */ + + /* 7.2.6 root-continuation */ + /* TODO */ + + /* 7.2.7 error-continuation */ + /* TODO */ + + /* + ** 7.3 Library features + */ + + /* 7.3.1 apply-continuation */ + /* TODO */ + + /* 7.3.2 $let/cc */ + /* TODO */ + + /* 7.3.3 guard-dynamic-extent */ + /* TODO */ + + /* 7.3.4 exit */ + /* TODO */ + return ground_env; }