Now have quote. Everything still seems to work. Unit tests still pass.
This commit is contained in:
parent
03dfe37045
commit
770767c11e
|
@ -36,6 +36,11 @@ int main (int argc, char *argv[]) {
|
||||||
fprintf( stderr, "Post scarcity software environment version %s\n", VERSION);
|
fprintf( stderr, "Post scarcity software environment version %s\n", VERSION);
|
||||||
initialise_cons_pages();
|
initialise_cons_pages();
|
||||||
|
|
||||||
|
/* privileged variables (keywords) */
|
||||||
|
deep_bind( intern( c_string_to_lisp_string( "nil"), oblist), NIL);
|
||||||
|
deep_bind( intern( c_string_to_lisp_string( "t"), oblist), TRUE);
|
||||||
|
|
||||||
|
/* primitive function operations */
|
||||||
bind_function( "assoc", &lisp_assoc);
|
bind_function( "assoc", &lisp_assoc);
|
||||||
bind_function( "car", &lisp_car);
|
bind_function( "car", &lisp_car);
|
||||||
bind_function( "cdr", &lisp_cdr);
|
bind_function( "cdr", &lisp_cdr);
|
||||||
|
@ -45,8 +50,10 @@ int main (int argc, char *argv[]) {
|
||||||
bind_function( "read", &lisp_read);
|
bind_function( "read", &lisp_read);
|
||||||
bind_function( "print", &lisp_print);
|
bind_function( "print", &lisp_print);
|
||||||
|
|
||||||
|
/* primitive special forms */
|
||||||
bind_special( "apply", &lisp_apply);
|
bind_special( "apply", &lisp_apply);
|
||||||
bind_special( "eval", &lisp_eval);
|
bind_special( "eval", &lisp_eval);
|
||||||
|
bind_special( "quote", &lisp_quote);
|
||||||
|
|
||||||
fprintf( stderr, "\n:: ");
|
fprintf( stderr, "\n:: ");
|
||||||
struct cons_pointer input = read( stdin);
|
struct cons_pointer input = read( stdin);
|
||||||
|
|
|
@ -117,6 +117,7 @@ struct cons_pointer lisp_eval( struct cons_pointer s_expr, struct cons_pointer e
|
||||||
struct cons_space_object special = pointer2cell( fn_pointer);
|
struct cons_space_object special = pointer2cell( fn_pointer);
|
||||||
result = (*special.payload.special.executable)( args, env, previous);
|
result = (*special.payload.special.executable)( args, env, previous);
|
||||||
} else if ( functionp( fn_pointer)) {
|
} else if ( functionp( fn_pointer)) {
|
||||||
|
/* actually, this is apply */
|
||||||
struct cons_space_object function = pointer2cell( fn_pointer);
|
struct cons_space_object function = pointer2cell( fn_pointer);
|
||||||
struct stack_frame* frame = make_stack_frame( my_frame, args, env);
|
struct stack_frame* frame = make_stack_frame( my_frame, args, env);
|
||||||
|
|
||||||
|
@ -147,6 +148,18 @@ struct cons_pointer lisp_eval( struct cons_pointer s_expr, struct cons_pointer e
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (quote a)
|
||||||
|
*
|
||||||
|
* Special form
|
||||||
|
* Returns its argument (strictly first argument - only one is expected but
|
||||||
|
* this isn't at this stage checked) unevaluated.
|
||||||
|
*/
|
||||||
|
struct cons_pointer lisp_quote( struct cons_pointer args, struct cons_pointer env,
|
||||||
|
struct stack_frame* frame) {
|
||||||
|
return c_car( args);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (cons a b)
|
* (cons a b)
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,6 +24,8 @@ struct cons_pointer lisp_eval( struct cons_pointer args, struct cons_pointer env
|
||||||
struct stack_frame* frame);
|
struct stack_frame* frame);
|
||||||
struct cons_pointer lisp_apply( struct cons_pointer args, struct cons_pointer env,
|
struct cons_pointer lisp_apply( struct cons_pointer args, struct cons_pointer env,
|
||||||
struct stack_frame* frame);
|
struct stack_frame* frame);
|
||||||
|
struct cons_pointer lisp_quote( struct cons_pointer args, struct cons_pointer env,
|
||||||
|
struct stack_frame* frame);
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
struct cons_pointer lisp_cons( struct stack_frame* frame, struct cons_pointer env);
|
struct cons_pointer lisp_cons( struct stack_frame* frame, struct cons_pointer env);
|
||||||
|
|
Loading…
Reference in a new issue