More work on apply, also trying to read dotted pairs.
This commit is contained in:
parent
89b4f093f9
commit
8e7d1ab913
|
@ -175,6 +175,10 @@ lisp_eval( struct stack_frame *frame, struct cons_pointer env ) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (apply fn args)
|
* (apply fn args)
|
||||||
|
*
|
||||||
|
* Special form. Apply the function which is the result of evaluating the
|
||||||
|
* first argoment to the list of arguments which is the result of evaluating
|
||||||
|
* the second argument
|
||||||
*/
|
*/
|
||||||
struct cons_pointer
|
struct cons_pointer
|
||||||
lisp_apply( struct stack_frame *frame, struct cons_pointer env ) {
|
lisp_apply( struct stack_frame *frame, struct cons_pointer env ) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ void print_string( FILE * output, struct cons_pointer pointer ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a single list cell (cons cell). TODO: does not handle dotted pairs.
|
* Print a single list cell (cons cell).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
print_list_contents( FILE * output, struct cons_pointer pointer,
|
print_list_contents( FILE * output, struct cons_pointer pointer,
|
||||||
|
|
13
src/read.c
13
src/read.c
|
@ -67,7 +67,18 @@ struct cons_pointer read_continuation( FILE * input, wint_t initial ) {
|
||||||
result = read_string( input, fgetwc( input ) );
|
result = read_string( input, fgetwc( input ) );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ( iswdigit( c ) || c == '.' ) {
|
if ( c == '.' ) {
|
||||||
|
wint_t next = fgetwc( input );
|
||||||
|
if ( iswdigit( next) ) {
|
||||||
|
ungetwc( next, input );
|
||||||
|
result = read_number( input, c );
|
||||||
|
} else if ( iswblank( next ) ) {
|
||||||
|
result = read_continuation(input, fgetwc( input));
|
||||||
|
} else {
|
||||||
|
read_symbol( input, c );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( iswdigit( c ) ) {
|
||||||
result = read_number( input, c );
|
result = read_number( input, c );
|
||||||
} else if ( iswprint( c ) ) {
|
} else if ( iswprint( c ) ) {
|
||||||
result = read_symbol( input, c );
|
result = read_symbol( input, c );
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
expected='1'
|
expected='1'
|
||||||
actual=`echo "(apply add '(1))"| target/psse 2> /dev/null | head -1`
|
actual=`echo "(apply 'add '(1))"| target/psse 2> /dev/null | head -2 | tail -1`
|
||||||
|
|
||||||
if [ "${expected}" = "${actual}" ]
|
if [ "${expected}" = "${actual}" ]
|
||||||
then
|
then
|
||||||
|
|
Loading…
Reference in a new issue