klisp

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

commit 325ec791772b76cc10b2beb006b12a86af2b2f5e
parent 1fd77306e1272028f751d976d666cf682e43e9dd
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Thu, 17 Mar 2011 16:58:29 -0300

Bugfix: returning an EOF doen't exit the interpreter anymore. ISSUE: Is the seen_eof flag even necessary??

Diffstat:
Msrc/kread.c | 2++
Msrc/krepl.c | 29++++++++++++++++-------------
2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/kread.c b/src/kread.c @@ -465,6 +465,8 @@ TValue kread(klisp_State *K) TValue obj; assert(ttisnil(K->shared_dict)); + /* TEMP: workaround repl problem with eofs */ + K->ktok_seen_eof = false; obj = kread_fsm(K); diff --git a/src/krepl.c b/src/krepl.c @@ -44,7 +44,7 @@ void read_fn(klisp_State *K, TValue *xparams, TValue obj) ktok_reset_source_info(K); obj = kread(K); - kapply_cc(K,obj); + kapply_cc(K, obj); } /* the underlying function of the eval cont */ @@ -55,7 +55,14 @@ void eval_cfn(klisp_State *K, TValue *xparams, TValue obj) */ TValue denv = xparams[0]; - ktail_call(K, K->eval_op, obj, denv); + if (ttiseof(obj)) { + /* read [EOF], should terminate the repl */ + /* this will in turn call main_cont */ + kset_cc(K, K->root_cont); + kapply_cc(K, KINERT); + } else { + ktail_call(K, K->eval_op, obj, denv); + } } void loop_fn(klisp_State *K, TValue *xparams, TValue obj); @@ -79,18 +86,14 @@ void loop_fn(klisp_State *K, TValue *xparams, TValue obj) /* ** xparams[0]: dynamic environment */ - if (ttiseof(obj)) { - /* this will in turn call main_cont */ - kapply_cc(K, obj); - } else { - /* TEMP: for now set this by hand */ - K->curr_out = stdout; - kwrite(K, obj); - knewline(K); - TValue denv = xparams[0]; - create_loop(K, denv); - } + /* TEMP: for now set this by hand */ + K->curr_out = stdout; + + kwrite(K, obj); + knewline(K); + TValue denv = xparams[0]; + create_loop(K, denv); } /* the underlying function of the error cont */