Very close to a basic REPL now.
This commit is contained in:
parent
83537391a6
commit
4efe9eab87
23 changed files with 188 additions and 84 deletions
47
src/c/psse.c
47
src/c/psse.c
|
|
@ -12,13 +12,24 @@
|
|||
* 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 "debug.h"
|
||||
#include "psse.h"
|
||||
#include "io/io.h"
|
||||
#include "memory/node.h"
|
||||
#include "memory/pso.h"
|
||||
#include "memory/tags.h"
|
||||
|
||||
#include "ops/stack_ops.h"
|
||||
#include "ops/truth.h"
|
||||
|
||||
#include "payloads/cons.h"
|
||||
#include "payloads/stack.h"
|
||||
|
||||
void print_banner( ) {
|
||||
fwprintf( stdout, L"Post-Scarcity Software Environment version %s\n\n",
|
||||
VERSION );
|
||||
|
|
@ -54,6 +65,35 @@ void print_options( FILE *stream ) {
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @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, 0 );
|
||||
|
||||
struct pso_pointer env = consp( oblist ) ? oblist : c_cons( oblist, nil );
|
||||
|
||||
/* bottom of stack */
|
||||
struct pso_pointer frame_pointer = make_frame( 1, nil, nil, env );
|
||||
|
||||
if ( !nilp( frame_pointer ) ) {
|
||||
// lisp_repl( get_stack_frame( frame_pointer ), frame_pointer, env );
|
||||
|
||||
dec_ref( frame_pointer );
|
||||
}
|
||||
|
||||
debug_print( L"Leaving repl\n", DEBUG_REPL, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* main entry point; parse command line arguments, initialise the environment,
|
||||
|
|
@ -101,7 +141,12 @@ int main( int argc, char *argv[] ) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( nilp( initialise_node( 0 ) ) ) {
|
||||
oblist = initialise_node( 0 );
|
||||
debug_print( L"Oblist: ", DEBUG_BOOTSTRAP, 0 );
|
||||
debug_print_object( oblist, DEBUG_BOOTSTRAP, 0 );
|
||||
debug_println( DEBUG_BOOTSTRAP );
|
||||
|
||||
if ( nilp( oblist ) ) {
|
||||
fputs( "Failed to initialise node\n", stderr );
|
||||
exit( 1 );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue