started writing qse_scm_eval()

This commit is contained in:
hyung-hwan 2011-03-05 17:45:12 +00:00
parent 5b60fd18f6
commit 2c48b27f9a
2 changed files with 101 additions and 19 deletions

View File

@ -232,18 +232,27 @@ void qse_scm_detachio (
qse_scm_t* scm /**< scheme */ qse_scm_t* scm /**< scheme */
); );
/**
* The qse_scm_read() function reads a textual expression into an entity.
*/
qse_scm_ent_t* qse_scm_read ( qse_scm_ent_t* qse_scm_read (
qse_scm_t* scm /**< scheme */ qse_scm_t* scm /**< scheme */
); );
/**
* The qse_scm_eval() function evaluates an entity.
*/
qse_scm_ent_t* qse_scm_eval ( qse_scm_ent_t* qse_scm_eval (
qse_scm_t* scm, /**< scheme */ qse_scm_t* scm, /**< scheme */
qse_scm_ent_t* obj qse_scm_ent_t* obj /**< entity */
); );
/**
* The qse_scm_print() function prints an entity.
*/
int qse_scm_print ( int qse_scm_print (
qse_scm_t* scm, /**< scheme */ qse_scm_t* scm, /**< scheme */
const qse_scm_ent_t* obj const qse_scm_ent_t* obj /**< entity */
); );
/** /**
@ -253,22 +262,6 @@ void qse_scm_gc (
qse_scm_t* scm /**< scheme */ qse_scm_t* scm /**< scheme */
); );
int qse_scm_addprim (
qse_scm_t* scm,
const qse_char_t* name,
qse_size_t name_len,
qse_scm_prim_t prim,
qse_size_t min_args,
qse_size_t max_args
);
int qse_scm_removeprim (
qse_scm_t* scm,
const qse_char_t* name
);
qse_scm_ent_t* qse_scm_makepairent ( qse_scm_ent_t* qse_scm_makepairent (
qse_scm_t* scm, qse_scm_t* scm,
qse_scm_ent_t* car, qse_scm_ent_t* car,

89
qse/lib/scm/eval.c Normal file
View File

@ -0,0 +1,89 @@
/*
* $Id$
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
QSE is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
QSE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
*/
#include "scm.h"
static qse_scm_ent_t* apply (qse_scm_t* scm)
{
if (TYPE(scm->reg.cod) == QSE_SCM_ENT_PROC)
{
/* builtin-procedure */
}
#if 0
else if (TYPE(scm->reg.cod) == QSE_SCM_ENT_CLO)
{
/* closure */
}
else if (TYPE(scm->reg.cod) == QSE_SCM_ENT_CON)
{
/* continuation */
}
#endif
else
{
}
}
static qse_scm_ent_t* eval_args (qse_scm_t* scm)
{
args = cons (value, args);
if (TYPE(scm->reg.cod))
{
}
else
{
}
}
static qse_scm_ent_t* eval_entity (qse_scm_t* scm)
{
if (IS_SMALLINT(scm->reg.cod))
{
}
else if (TYPE(scm->reg.cod) == QSE_SCM_ENT_SYM)
{
}
else if (TYPE(scm->reg.cod) == QSE_SCM_ENT_PAIR)
{
car = PAIR_CAR(scm->reg.cod);
if (SYNT(car))
{
}
else
{
push E1_ARG.... NIL, PAIR_CDR(code)
scm->reg.cod = car;
goback to eval...
}
}
else
{
}
}
qse_scm_ent_t* qse_scm_eval (qse_scm_t* scm, qse_scm_ent_t* obj)
{
scm->reg.dmp = scm->nil;
scm->reg.env = scm->gloenv;
scm->reg.cod = obj;
return eval_entity (scm);
}