Trying to get to the point where make format works the same
on Linux and MacOS
This commit is contained in:
parent
93b84087ce
commit
d620542ee5
13 changed files with 191 additions and 176 deletions
60
src/repl.c
60
src/repl.c
|
|
@ -30,41 +30,42 @@
|
|||
/**
|
||||
* Dummy up a Lisp read call with its own stack frame.
|
||||
*/
|
||||
struct cons_pointer repl_read( struct cons_pointer stream_pointer) {
|
||||
struct stack_frame *frame = make_empty_frame( NULL, oblist );
|
||||
struct cons_pointer repl_read( struct cons_pointer stream_pointer ) {
|
||||
struct stack_frame *frame = make_empty_frame( NULL, oblist );
|
||||
|
||||
frame->arg[0] = stream_pointer;
|
||||
struct cons_pointer result = lisp_read( frame, oblist);
|
||||
free_stack_frame( frame );
|
||||
frame->arg[0] = stream_pointer;
|
||||
struct cons_pointer result = lisp_read( frame, oblist );
|
||||
free_stack_frame( frame );
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy up a Lisp eval call with its own stack frame.
|
||||
*/
|
||||
struct cons_pointer repl_eval( struct cons_pointer input) {
|
||||
struct stack_frame *frame = make_empty_frame( NULL, oblist );
|
||||
struct cons_pointer repl_eval( struct cons_pointer input ) {
|
||||
struct stack_frame *frame = make_empty_frame( NULL, oblist );
|
||||
|
||||
frame->arg[0] = NIL /* input */;
|
||||
struct cons_pointer result = lisp_eval( frame, oblist);
|
||||
free_stack_frame( frame );
|
||||
frame->arg[0] = NIL /* input */ ;
|
||||
struct cons_pointer result = lisp_eval( frame, oblist );
|
||||
free_stack_frame( frame );
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy up a Lisp print call with its own stack frame.
|
||||
*/
|
||||
struct cons_pointer repl_print( struct cons_pointer stream_pointer, struct cons_pointer value) {
|
||||
struct stack_frame *frame = make_empty_frame( NULL, oblist );
|
||||
struct cons_pointer repl_print( struct cons_pointer stream_pointer,
|
||||
struct cons_pointer value ) {
|
||||
struct stack_frame *frame = make_empty_frame( NULL, oblist );
|
||||
|
||||
frame->arg[0] = value;
|
||||
frame->arg[1] = NIL /* stream_pointer */;
|
||||
struct cons_pointer result = lisp_print( frame, oblist);
|
||||
free_stack_frame( frame );
|
||||
frame->arg[0] = value;
|
||||
frame->arg[1] = NIL /* stream_pointer */ ;
|
||||
struct cons_pointer result = lisp_print( frame, oblist );
|
||||
free_stack_frame( frame );
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -77,21 +78,20 @@ struct cons_pointer repl_print( struct cons_pointer stream_pointer, struct cons_
|
|||
void
|
||||
repl( FILE * in_stream, FILE * out_stream, FILE * error_stream,
|
||||
bool show_prompt ) {
|
||||
struct cons_pointer input_stream = make_read_stream(in_stream);
|
||||
struct cons_pointer output_stream = make_write_stream(out_stream);
|
||||
struct cons_pointer input_stream = make_read_stream( in_stream );
|
||||
struct cons_pointer output_stream = make_write_stream( out_stream );
|
||||
|
||||
while ( !feof( pointer2cell(input_stream).payload.stream.stream ) ) {
|
||||
if ( show_prompt ) {
|
||||
fwprintf( out_stream, L"\n:: " );
|
||||
}
|
||||
while ( !feof( pointer2cell( input_stream ).payload.stream.stream ) ) {
|
||||
if ( show_prompt ) {
|
||||
fwprintf( out_stream, L"\n:: " );
|
||||
}
|
||||
|
||||
struct cons_pointer val = repl_eval( repl_read( input_stream));
|
||||
struct cons_pointer val = repl_eval( repl_read( input_stream ) );
|
||||
|
||||
/* suppress the 'end of stream' exception */
|
||||
if ( exceptionp(val) &&
|
||||
!feof( pointer2cell( input_stream).payload.stream.stream ) )
|
||||
{
|
||||
repl_print( output_stream, val);
|
||||
if ( exceptionp( val ) &&
|
||||
!feof( pointer2cell( input_stream ).payload.stream.stream ) ) {
|
||||
repl_print( output_stream, val );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue