mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-09 14:40:37 -07:00
[r2rs] add read-print-loop
This commit is contained in:
parent
e696eb0d91
commit
ff944563de
1 changed files with 42 additions and 2 deletions
44
src/c/r2rs.c
44
src/c/r2rs.c
|
|
@ -46,7 +46,7 @@ alloc_readtable(void) {
|
|||
|
||||
static cl_object
|
||||
r2rs_parse_token(cl_object token, cl_object in, int flags) {
|
||||
return ECL_NIL;
|
||||
return ostr;
|
||||
}
|
||||
|
||||
static cl_object
|
||||
|
|
@ -96,6 +96,42 @@ init_r2rs_reader(void) {
|
|||
|
||||
/* -- Entry point ----------------------------------------------------------- */
|
||||
|
||||
cl_object
|
||||
r2rs_write_cstr(const char *s)
|
||||
{
|
||||
cl_object strm = ostr;
|
||||
while(*s != '\0')
|
||||
ecl_write_char(*s++, strm);
|
||||
}
|
||||
|
||||
cl_object
|
||||
r2rs_write_object(cl_object self)
|
||||
{
|
||||
if(self == OBJNULL) {
|
||||
r2rs_write_cstr("%OBJNULL");
|
||||
return self;
|
||||
}
|
||||
cl_type t = ecl_t_of(self);
|
||||
cl_object reg = ECL_NIL;
|
||||
int aux = 0;
|
||||
|
||||
/* FIXME ecl_type_info[NIL] -> "CONS" */
|
||||
const char *name = ecl_type_info[t].name;
|
||||
r2rs_write_cstr("#<");
|
||||
r2rs_write_cstr(name);
|
||||
r2rs_write_cstr(">");
|
||||
return ECL_NIL;
|
||||
}
|
||||
|
||||
void r2rs_repl(void) {
|
||||
cl_object result;
|
||||
while(1) {
|
||||
printf("> ");
|
||||
result = ecl_read_object_with_delimiter(rtab, istr, '\n', 0);
|
||||
r2rs_write_object(result);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
cl_env_ptr the_env = ecl_core.first_env;
|
||||
ecl_set_option(ECL_OPT_BIND_STACK_SIZE, 32);
|
||||
|
|
@ -105,14 +141,18 @@ int main() {
|
|||
ecl_set_option(ECL_OPT_LISP_STACK_SIZE, 32);
|
||||
ecl_set_option(ECL_OPT_LISP_STACK_SAFETY_AREA, 8);
|
||||
|
||||
the_env->string_pool = ECL_NIL;
|
||||
the_env->token_pool = ECL_NIL;
|
||||
|
||||
ecl_boot();
|
||||
ecl_add_module(ecl_module_process);
|
||||
ecl_add_module(ecl_module_stacks);
|
||||
|
||||
init_r2rs_streams();
|
||||
init_r2rs_reader();
|
||||
|
||||
printf("Hello ECL! %p\n", the_env);
|
||||
/* nucl_repl(); */
|
||||
r2rs_repl();
|
||||
printf("Good bye ECL! %p\n", the_env);
|
||||
|
||||
ecl_halt();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue