post-scarcity/src/repl.c
Simon Brooke e41ae1aa8b OK, big win: the oblist is now a hashmap, and it works. I have clear ideas now
about how to implement namespaces. There are probably regressions in this, but
progress nevertheless!
2026-02-03 17:20:55 +00:00

52 lines
1.1 KiB
C

/*
* repl.c
*
* the read/eval/print loop
*
* (c) 2017 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#include <stdbool.h>
#include <stdio.h>
#include <wchar.h>
#include <signal.h>
#include "memory/consspaceobject.h"
#include "debug.h"
#include "ops/intern.h"
#include "ops/lispops.h"
#include "memory/stack.h"
/**
* @brief Handle an interrupt signal.
*
* @param dummy
*/
void int_handler(int dummy) {
wprintf(L"TODO: handle ctrl-C in a more interesting way\n");
}
/**
* The read/eval/print loop.
*/
void repl( ) {
signal(SIGINT, int_handler);
debug_print( L"Entered repl\n", DEBUG_REPL );
struct cons_pointer env =
consp( oblist ) ? oblist : make_cons( oblist, NIL );
/* bottom of stack */
struct cons_pointer frame_pointer = make_stack_frame( NIL, NIL, env );
if ( !nilp( frame_pointer ) ) {
inc_ref( frame_pointer );
lisp_repl( get_stack_frame( frame_pointer ), frame_pointer, env );
dec_ref( frame_pointer );
}
debug_print( L"Leaving repl\n", DEBUG_REPL );
}