String-like-things are being created and printed correctly; bind is broken.

This commit is contained in:
Simon Brooke 2026-04-17 18:40:32 +01:00
parent cf05e30540
commit ca5671f613
8 changed files with 508 additions and 450 deletions

View file

@ -41,7 +41,7 @@ struct pso_pointer search( struct pso_pointer key,
if ( consp( store ) ) {
for ( struct pso_pointer cursor = store;
consp( store ) && found == false; cursor = c_cdr( cursor ) ) {
consp( cursor ) && found == false; cursor = c_cdr( cursor ) ) {
struct pso_pointer pair = c_car( cursor );
if ( consp( pair ) && c_equal( c_car( pair ), key ) ) {

View file

@ -57,6 +57,15 @@ void c_repl( ) {
struct pso_pointer env = consp( oblist ) ? oblist : c_cons( oblist, nil );
struct pso_pointer input_stream = c_assoc( lisp_io_in, env );
struct pso_pointer output_stream = c_assoc( lisp_io_out, env );
if (!readp(input_stream)) {
debug_print(L"Invalid read stream: ", DEBUG_IO, 0);
debug_print_object(input_stream, DEBUG_IO, 0);
}
if (!writep(output_stream)) {
debug_print(L"Invalid write stream: ", DEBUG_IO, 0);
debug_print_object(output_stream, DEBUG_IO, 0);
}
while ( readp( input_stream )
&& !url_feof( stream_get_url_file( input_stream ) ) ) {

View file

@ -71,7 +71,7 @@ uint32_t calculate_hash( wint_t c, struct pso_pointer ptr ) {
*/
struct pso_pointer make_string_like_thing( wint_t c, struct pso_pointer tail,
char *tag ) {
struct pso_pointer pointer = nil;
struct pso_pointer pointer = tail;
if ( check_type( tail, tag ) || nilp( tail ) ) {
pointer = allocate( tag, CONS_SIZE_CLASS );
@ -81,8 +81,11 @@ struct pso_pointer make_string_like_thing( wint_t c, struct pso_pointer tail,
cell->payload.string.cdr = tail;
cell->payload.string.hash = calculate_hash( c, tail );
debug_dump_object( pointer, DEBUG_ALLOC, 0 );
debug_println( DEBUG_ALLOC );
debug_printf( DEBUG_ALLOC, 0,
L"Building string-like-thing of type %3.3s: ",
cell->header.tag.bytes.mnemonic);
debug_print_object(pointer, DEBUG_ALLOC, 0);
debug_println(DEBUG_ALLOC);
} else {
// \todo should throw an exception!
struct pso2 *tobj = pointer_to_object( tail );
@ -91,6 +94,7 @@ struct pso_pointer make_string_like_thing( wint_t c, struct pso_pointer tail,
tag, tobj->header.tag.bytes.mnemonic );
}
return pointer;
}
@ -138,9 +142,11 @@ struct pso_pointer c_string_to_lisp_string( wchar_t *string ) {
struct pso_pointer result = nil;
for ( int i = wcslen( string ) - 1; i >= 0; i-- ) {
if ( iswprint( string[i] ) && string[i] != '"' ) {
if ( string[i] != '"' ) {
result = make_string( string[i], result );
}
} else {
result = make_string( L'\\', make_string( string[i], result));
}
}
return result;
@ -157,7 +163,7 @@ struct pso_pointer c_string_to_lisp_symbol( wchar_t *symbol ) {
for ( int i = wcslen( symbol ) - 1; i >= 0; i-- ) {
wchar_t c = towlower( symbol[i] );
if ( iswalpha( c ) || c == L'-' ) {
if ( iswalpha( c ) || c == L'-' || c == L'*') {
result = make_symbol( c, result );
}
}