ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/microscheme/scheme.c
(Generate patch)

Comparing cvsroot/microscheme/scheme.c (file contents):
Revision 1.35 by root, Sun Nov 29 00:02:21 2015 UTC vs.
Revision 1.45 by root, Mon Nov 30 07:44:23 2015 UTC

16 * (MINISCM) This is a revised and modified version by Akira KIDA. 16 * (MINISCM) This is a revised and modified version by Akira KIDA.
17 * (MINISCM) current version is 0.85k4 (15 May 1994) 17 * (MINISCM) current version is 0.85k4 (15 May 1994)
18 * 18 *
19 */ 19 */
20 20
21#define EXPERIMENT 1
22
21#define PAGE_SIZE 4096 /* does not work on sparc/alpha */ 23#define PAGE_SIZE 4096 /* does not work on sparc/alpha */
22#include "malloc.c" 24#include "malloc.c"
23 25
24#define SCHEME_SOURCE 26#define SCHEME_SOURCE
25#include "scheme-private.h" 27#include "scheme-private.h"
74 TOK_SHARP_CONST, 76 TOK_SHARP_CONST,
75 TOK_VEC 77 TOK_VEC
76}; 78};
77 79
78#define BACKQUOTE '`' 80#define BACKQUOTE '`'
79#define DELIMITERS "()\";\f\t\v\n\r " 81#define WHITESPACE " \t\r\n\v\f"
82#define DELIMITERS "()\";" WHITESPACE
80 83
81#define NIL (&SCHEME_V->xNIL) //TODO: make this 0? 84#define NIL (&SCHEME_V->xNIL) //TODO: make this 0?
82#define S_T (&SCHEME_V->xT) //TODO: magic ptr value? 85#define S_T (&SCHEME_V->xT) //TODO: magic ptr value?
83#define S_F (&SCHEME_V->xF) //TODO: magic ptr value? 86#define S_F (&SCHEME_V->xF) //TODO: magic ptr value?
84#define S_SINK (&SCHEME_V->xsink) 87#define S_SINK (&SCHEME_V->xsink)
406} 409}
407 410
408INTERFACE char * 411INTERFACE char *
409symname (pointer p) 412symname (pointer p)
410{ 413{
411 return strvalue (car (p)); 414 return strvalue (p);
412} 415}
413 416
414#if USE_PLIST 417#if USE_PLIST
418#define symprop(p) cdr(p)
415SCHEME_EXPORT int 419SCHEME_EXPORT int
416hasprop (pointer p) 420hasprop (pointer p)
417{ 421{
418 return typeflag (p) & T_SYMBOL; 422 return typeflag (p) & T_SYMBOL;
419} 423}
420
421# define symprop(p) cdr(p)
422#endif 424#endif
423 425
424INTERFACE int 426INTERFACE int
425is_syntax (pointer p) 427is_syntax (pointer p)
426{ 428{
440} 442}
441 443
442INTERFACE char * 444INTERFACE char *
443syntaxname (pointer p) 445syntaxname (pointer p)
444{ 446{
445 return strvalue (car (p)); 447 return strvalue (p);
446} 448}
447 449
448#define procnum(p) ivalue_unchecked (p) 450#define procnum(p) ivalue_unchecked (p)
449static const char *procname (pointer x); 451static const char *procname (pointer x);
450 452
967 if (SCHEME_V->no_memory && USE_ERROR_CHECKING) 969 if (SCHEME_V->no_memory && USE_ERROR_CHECKING)
968 return S_SINK; 970 return S_SINK;
969 971
970 if (SCHEME_V->free_cell == NIL) 972 if (SCHEME_V->free_cell == NIL)
971 { 973 {
972 const int min_to_be_recovered = SCHEME_V->last_cell_seg < 128 ? 128 * 8 : SCHEME_V->last_cell_seg * 8; 974 const int min_to_be_recovered = SCHEME_V->cell_segsize [SCHEME_V->last_cell_seg] >> 2;
973 975
974 gc (SCHEME_A_ a, b); 976 gc (SCHEME_A_ a, b);
975 977
976 if (SCHEME_V->fcells < min_to_be_recovered || SCHEME_V->free_cell == NIL) 978 if (SCHEME_V->fcells < min_to_be_recovered || SCHEME_V->free_cell == NIL)
977 { 979 {
1028} 1030}
1029 1031
1030static pointer 1032static pointer
1031get_vector_object (SCHEME_P_ uint32_t len, pointer init) 1033get_vector_object (SCHEME_P_ uint32_t len, pointer init)
1032{ 1034{
1033 pointer v = get_cell_x (SCHEME_A_ 0, 0); 1035 pointer v = get_cell_x (SCHEME_A_ NIL, NIL);
1034 pointer *e = malloc (len * sizeof (pointer)); 1036 pointer *e = malloc (len * sizeof (pointer));
1035 1037
1036 if (!e && USE_ERROR_CHECKING) 1038 if (!e && USE_ERROR_CHECKING)
1037 return S_SINK; 1039 return S_SINK;
1038 1040
1092 set_cdr (x, b); 1094 set_cdr (x, b);
1093 1095
1094 return x; 1096 return x;
1095} 1097}
1096 1098
1097/* ========== oblist implementation ========== */
1098
1099static pointer 1099static pointer
1100generate_symbol (SCHEME_P_ const char *name) 1100generate_symbol (SCHEME_P_ const char *name)
1101{ 1101{
1102 pointer x = mk_string (SCHEME_A_ name); 1102 pointer x = mk_string (SCHEME_A_ name);
1103 setimmutable (x); 1103 setimmutable (x);
1104 x = immutable_cons (x, NIL);
1105 set_typeflag (x, T_SYMBOL); 1104 set_typeflag (x, T_SYMBOL | T_ATOM);
1106 return x; 1105 return x;
1107} 1106}
1107
1108/* ========== oblist implementation ========== */
1108 1109
1109#ifndef USE_OBJECT_LIST 1110#ifndef USE_OBJECT_LIST
1110 1111
1111static int 1112static int
1112hash_fn (const char *key, int table_size) 1113hash_fn (const char *key, int table_size)
1354 1355
1355 for (i = start; i < veclength (vec); i++) 1356 for (i = start; i < veclength (vec); i++)
1356 vecvalue (vec)[i] = obj; 1357 vecvalue (vec)[i] = obj;
1357} 1358}
1358 1359
1360INTERFACE void
1361vector_resize (pointer vec, uint32_t newsize, pointer fill)
1362{
1363 uint32_t oldsize = veclength (vec);
1364 vecvalue (vec) = realloc (vecvalue (vec), newsize * sizeof (pointer));
1365 veclength (vec) = newsize;
1366 fill_vector (vec, oldsize, fill);
1367}
1368
1359INTERFACE pointer 1369INTERFACE pointer
1360vector_get (pointer vec, uint32_t ielem) 1370vector_get (pointer vec, uint32_t ielem)
1361{ 1371{
1362 return vecvalue(vec)[ielem]; 1372 return vecvalue(vec)[ielem];
1363} 1373}
1384INTERFACE pointer 1394INTERFACE pointer
1385gensym (SCHEME_P) 1395gensym (SCHEME_P)
1386{ 1396{
1387 pointer x; 1397 pointer x;
1388 char name[40] = "gensym-"; 1398 char name[40] = "gensym-";
1389 xnum (name + 7, SCHEME_V->gensym_cnt); 1399 xnum (name + 7, ++SCHEME_V->gensym_cnt);
1390 1400
1391 return generate_symbol (SCHEME_A_ name); 1401 return generate_symbol (SCHEME_A_ name);
1402}
1403
1404static int
1405is_gensym (SCHEME_P_ pointer x)
1406{
1407 return is_symbol (x) && oblist_find_by_name (SCHEME_A_ strvalue (x)) != x;
1392} 1408}
1393 1409
1394/* make symbol or number atom from string */ 1410/* make symbol or number atom from string */
1395static pointer 1411static pointer
1396mk_atom (SCHEME_P_ char *q) 1412mk_atom (SCHEME_P_ char *q)
1640 /* garbage collect */ 1656 /* garbage collect */
1641 clrmark (NIL); 1657 clrmark (NIL);
1642 SCHEME_V->fcells = 0; 1658 SCHEME_V->fcells = 0;
1643 SCHEME_V->free_cell = NIL; 1659 SCHEME_V->free_cell = NIL;
1644 1660
1645 /* free-list is kept sorted by address so as to maintain consecutive 1661 if (SCHEME_V->gc_verbose)
1646 ranges, if possible, for use with vectors. Here we scan the cells 1662 xwrstr ("freeing...");
1647 (which are also kept sorted by address) downwards to build the 1663
1648 free-list in sorted order. 1664 uint32_t total = 0;
1649 */ 1665
1666 /* Here we scan the cells to build the free-list. */
1650 for (i = SCHEME_V->last_cell_seg; i >= 0; i--) 1667 for (i = SCHEME_V->last_cell_seg; i >= 0; i--)
1651 { 1668 {
1652 p = SCHEME_V->cell_seg[i] + SCHEME_V->cell_segsize [i]; 1669 pointer end = SCHEME_V->cell_seg[i] + SCHEME_V->cell_segsize [i];
1670 total += SCHEME_V->cell_segsize [i];
1653 1671
1654 while (--p >= SCHEME_V->cell_seg[i]) 1672 for (p = SCHEME_V->cell_seg[i]; p < end; ++p)
1655 { 1673 {
1656 if (is_mark (p)) 1674 if (is_mark (p))
1657 clrmark (p); 1675 clrmark (p);
1658 else 1676 else
1659 { 1677 {
1672 } 1690 }
1673 } 1691 }
1674 1692
1675 if (SCHEME_V->gc_verbose) 1693 if (SCHEME_V->gc_verbose)
1676 { 1694 {
1677 xwrstr ("done: "); xwrnum (SCHEME_V->fcells); xwrstr (" cells were recovered.\n"); 1695 xwrstr ("done: "); xwrnum (SCHEME_V->fcells); xwrstr (" out of "); xwrnum (total); xwrstr (" cells were recovered.\n");
1678 } 1696 }
1679} 1697}
1680 1698
1681static void 1699static void
1682finalize_cell (SCHEME_P_ pointer a) 1700finalize_cell (SCHEME_P_ pointer a)
1683{ 1701{
1684 /* TODO, fast bitmap check? */ 1702 /* TODO, fast bitmap check? */
1685 if (is_string (a)) 1703 if (is_string (a) || is_symbol (a))
1686 free (strvalue (a)); 1704 free (strvalue (a));
1687 else if (is_vector (a)) 1705 else if (is_vector (a))
1688 free (vecvalue (a)); 1706 free (vecvalue (a));
1689#if USE_PORTS 1707#if USE_PORTS
1690 else if (is_port (a)) 1708 else if (is_port (a))
2256 2274
2257/* check c is in chars */ 2275/* check c is in chars */
2258ecb_inline int 2276ecb_inline int
2259is_one_of (const char *s, int c) 2277is_one_of (const char *s, int c)
2260{ 2278{
2261 if (c == EOF)
2262 return 1;
2263
2264 return !!strchr (s, c); 2279 return c == EOF || !!strchr (s, c);
2265} 2280}
2266 2281
2267/* skip white characters */ 2282/* skip white characters */
2268ecb_inline int 2283ecb_inline int
2269skipspace (SCHEME_P) 2284skipspace (SCHEME_P)
2271 int c, curr_line = 0; 2286 int c, curr_line = 0;
2272 2287
2273 do 2288 do
2274 { 2289 {
2275 c = inchar (SCHEME_A); 2290 c = inchar (SCHEME_A);
2291
2276#if SHOW_ERROR_LINE 2292#if SHOW_ERROR_LINE
2277 if (c == '\n') 2293 if (ecb_expect_false (c == '\n'))
2278 curr_line++; 2294 curr_line++;
2279#endif 2295#endif
2296
2297 if (ecb_expect_false (c == EOF))
2298 return c;
2280 } 2299 }
2281 while (c == ' ' || c == '\n' || c == '\r' || c == '\t'); 2300 while (is_one_of (WHITESPACE, c));
2282 2301
2283 /* record it */ 2302 /* record it */
2284#if SHOW_ERROR_LINE 2303#if SHOW_ERROR_LINE
2285 if (SCHEME_V->load_stack[SCHEME_V->file_i].kind & port_file) 2304 if (SCHEME_V->load_stack[SCHEME_V->file_i].kind & port_file)
2286 SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.curr_line += curr_line; 2305 SCHEME_V->load_stack[SCHEME_V->file_i].rep.stdio.curr_line += curr_line;
2287#endif 2306#endif
2288 2307
2289 if (c != EOF)
2290 {
2291 backchar (SCHEME_A_ c); 2308 backchar (SCHEME_A_ c);
2292 return 1; 2309 return 1;
2293 }
2294 else
2295 return EOF;
2296} 2310}
2297 2311
2298/* get token */ 2312/* get token */
2299static int 2313static int
2300token (SCHEME_P) 2314token (SCHEME_P)
2316 return TOK_RPAREN; 2330 return TOK_RPAREN;
2317 2331
2318 case '.': 2332 case '.':
2319 c = inchar (SCHEME_A); 2333 c = inchar (SCHEME_A);
2320 2334
2321 if (is_one_of (" \n\t", c)) 2335 if (is_one_of (WHITESPACE, c))
2322 return TOK_DOT; 2336 return TOK_DOT;
2323 else 2337 else
2324 { 2338 {
2325 backchar (SCHEME_A_ c); 2339 backchar (SCHEME_A_ c);
2326 return TOK_DOTATOM; 2340 return TOK_DOTATOM;
2467 } 2481 }
2468 2482
2469 putcharacter (SCHEME_A_ '"'); 2483 putcharacter (SCHEME_A_ '"');
2470} 2484}
2471 2485
2472
2473/* print atoms */ 2486/* print atoms */
2474static void 2487static void
2475printatom (SCHEME_P_ pointer l, int f) 2488printatom (SCHEME_P_ pointer l, int f)
2476{ 2489{
2477 char *p; 2490 char *p;
2478 int len; 2491 int len;
2479 2492
2480 atom2str (SCHEME_A_ l, f, &p, &len); 2493 atom2str (SCHEME_A_ l, f, &p, &len);
2481 putchars (SCHEME_A_ p, len); 2494 putchars (SCHEME_A_ p, len);
2482} 2495}
2483
2484 2496
2485/* Uses internal buffer unless string pointer is already available */ 2497/* Uses internal buffer unless string pointer is already available */
2486static void 2498static void
2487atom2str (SCHEME_P_ pointer l, int f, char **pp, int *plen) 2499atom2str (SCHEME_P_ pointer l, int f, char **pp, int *plen)
2488{ 2500{
2649#endif 2661#endif
2650 } 2662 }
2651 else if (is_continuation (l)) 2663 else if (is_continuation (l))
2652 p = "#<CONTINUATION>"; 2664 p = "#<CONTINUATION>";
2653 else 2665 else
2666 {
2667#if USE_PRINTF
2668 p = SCHEME_V->strbuff;
2669 snprintf (p, STRBUFFSIZE, "#<ERROR %x>", (int)typeflag (l));
2670#else
2654 p = "#<ERROR>"; 2671 p = "#<ERROR>";
2672#endif
2673 }
2655 2674
2656 *pp = p; 2675 *pp = p;
2657 *plen = strlen (p); 2676 *plen = strlen (p);
2658} 2677}
2659 2678
2929#endif /* USE_ALIST_ENV else */ 2948#endif /* USE_ALIST_ENV else */
2930 2949
2931ecb_inline void 2950ecb_inline void
2932new_slot_in_env (SCHEME_P_ pointer variable, pointer value) 2951new_slot_in_env (SCHEME_P_ pointer variable, pointer value)
2933{ 2952{
2953 assert (is_symbol (variable));//TODO: bug in current-ws/OP_LET2
2934 new_slot_spec_in_env (SCHEME_A_ SCHEME_V->envir, variable, value); 2954 new_slot_spec_in_env (SCHEME_A_ SCHEME_V->envir, variable, value);
2935} 2955}
2936 2956
2937ecb_inline void 2957ecb_inline void
2938set_slot_in_env (SCHEME_P_ pointer slot, pointer value) 2958set_slot_in_env (SCHEME_P_ pointer slot, pointer value)
3230 3250
3231#endif 3251#endif
3232 3252
3233#define s_retbool(tf) s_return ((tf) ? S_T : S_F) 3253#define s_retbool(tf) s_return ((tf) ? S_T : S_F)
3234 3254
3255#if EXPERIMENT
3256static int
3257debug (SCHEME_P_ int indent, pointer x)
3258{
3259 int c;
3260
3261 if (is_syntax (x))
3262 {
3263 printf ("%*ssyntax<%s,%d>\n", indent, "", syntaxname(x),syntaxnum(x));
3264 return 8 + 8;
3265 }
3266
3267 if (x == NIL)
3268 {
3269 printf ("%*sNIL\n", indent, "");
3270 return 3;
3271 }
3272
3273 switch (type (x))
3274 {
3275 case T_INTEGER:
3276 printf ("%*sI<%d>%p\n", indent, "", (int)ivalue_unchecked (x), x);
3277 return 32+8;
3278
3279 case T_SYMBOL:
3280 printf ("%*sS<%s>\n", indent, "", symname (x));
3281 return 24+8;
3282
3283 case T_CLOSURE:
3284 printf ("%*sS<%s>\n", indent, "", "closure");
3285 debug (SCHEME_A_ indent + 3, cdr(x));
3286 return 32 + debug (SCHEME_A_ indent + 3, car (x));
3287
3288 case T_PAIR:
3289 printf ("%*spair %p %p\n", indent, "", car(x),cdr(x));
3290 c = debug (SCHEME_A_ indent + 3, car (x));
3291 c += debug (SCHEME_A_ indent + 3, cdr (x));
3292 return c + 1;
3293
3294 case T_PORT:
3295 printf ("%*sS<%s>\n", indent, "", "port");
3296 return 24+8;
3297
3298 case T_VECTOR:
3299 printf ("%*sS<%s>\n", indent, "", "vector");
3300 return 24+8;
3301
3302 case T_ENVIRONMENT:
3303 printf ("%*sS<%s>\n", indent, "", "environment");
3304 return 0 + debug (SCHEME_A_ indent + 3, car (x));
3305
3306 default:
3307 printf ("unhandled type %d\n", type (x));
3308 break;
3309 }
3310}
3311#endif
3312
3235static int 3313static int
3236opexe_0 (SCHEME_P_ enum scheme_opcodes op) 3314opexe_0 (SCHEME_P_ enum scheme_opcodes op)
3237{ 3315{
3238 pointer args = SCHEME_V->args; 3316 pointer args = SCHEME_V->args;
3239 pointer x, y; 3317 pointer x, y;
3240 3318
3241 switch (op) 3319 switch (op)
3242 { 3320 {
3321#if EXPERIMENT //D
3322 case OP_DEBUG:
3323 printf ("len = %d\n", debug (SCHEME_A_ 0, args) / 8);
3324 printf ("\n");
3325 s_return (S_T);
3326#endif
3243 case OP_LOAD: /* load */ 3327 case OP_LOAD: /* load */
3244 if (file_interactive (SCHEME_A)) 3328 if (file_interactive (SCHEME_A))
3245 { 3329 {
3246 xwrstr ("Loading "); xwrstr (strvalue (car (args))); xwrstr ("\n"); 3330 xwrstr ("Loading "); xwrstr (strvalue (car (args))); xwrstr ("\n");
3247 //D fprintf (SCHEME_V->outport->object.port->rep.stdio.file, "Loading %s\n", strvalue (car (args))); 3331 //D fprintf (SCHEME_V->outport->object.port->rep.stdio.file, "Loading %s\n", strvalue (car (args)));
3370 } 3454 }
3371 else 3455 else
3372 s_return (SCHEME_V->code); 3456 s_return (SCHEME_V->code);
3373 3457
3374 case OP_E0ARGS: /* eval arguments */ 3458 case OP_E0ARGS: /* eval arguments */
3375 if (is_macro (SCHEME_V->value)) /* macro expansion */ 3459 if (ecb_expect_false (is_macro (SCHEME_V->value))) /* macro expansion */
3376 { 3460 {
3377 s_save (SCHEME_A_ OP_DOMACRO, NIL, NIL); 3461 s_save (SCHEME_A_ OP_DOMACRO, NIL, NIL);
3378 SCHEME_V->args = cons (SCHEME_V->code, NIL); 3462 SCHEME_V->args = cons (SCHEME_V->code, NIL);
3379 SCHEME_V->code = SCHEME_V->value; 3463 SCHEME_V->code = SCHEME_V->value;
3380 s_goto (OP_APPLY); 3464 s_goto (OP_APPLY);
4378 } 4462 }
4379 4463
4380 case OP_VECLEN: /* vector-length */ 4464 case OP_VECLEN: /* vector-length */
4381 s_return (mk_integer (SCHEME_A_ veclength (x))); 4465 s_return (mk_integer (SCHEME_A_ veclength (x)));
4382 4466
4467 case OP_VECRESIZE:
4468 vector_resize (x, ivalue_unchecked (cadr (args)), caddr (args));
4469 s_return (x);
4470
4383 case OP_VECREF: /* vector-ref */ 4471 case OP_VECREF: /* vector-ref */
4384 { 4472 {
4385 int index = ivalue_unchecked (cadr (args)); 4473 int index = ivalue_unchecked (cadr (args));
4386 4474
4387 if (index >= veclength (car (args)) && USE_ERROR_CHECKING) 4475 if (index >= veclength (car (args)) && USE_ERROR_CHECKING)
4447 pointer d = cdr (args); 4535 pointer d = cdr (args);
4448 int r; 4536 int r;
4449 4537
4450 switch (op) 4538 switch (op)
4451 { 4539 {
4452 case OP_NOT: /* not */ r = is_false (a) ; break; 4540 case OP_NOT: /* not */ r = is_false (a) ; break;
4453 case OP_BOOLP: /* boolean? */ r = a == S_F || a == S_T; break; 4541 case OP_BOOLP: /* boolean? */ r = a == S_F || a == S_T ; break;
4454 case OP_EOFOBJP: /* eof-object? */ r = a == S_EOF ; break; 4542 case OP_EOFOBJP: /* eof-object? */ r = a == S_EOF ; break;
4455 case OP_NULLP: /* null? */ r = a == NIL ; break; 4543 case OP_NULLP: /* null? */ r = a == NIL ; break;
4456 case OP_SYMBOLP: /* symbol? */ r = is_symbol (a) ; break; 4544 case OP_SYMBOLP: /* symbol? */ r = is_symbol (a) ; break;
4545 case OP_GENSYMP: /* gensym? */ r = is_gensym (SCHEME_A_ a); break;
4457 case OP_NUMBERP: /* number? */ r = is_number (a) ; break; 4546 case OP_NUMBERP: /* number? */ r = is_number (a) ; break;
4458 case OP_STRINGP: /* string? */ r = is_string (a) ; break; 4547 case OP_STRINGP: /* string? */ r = is_string (a) ; break;
4459 case OP_INTEGERP: /* integer? */ r = is_integer (a) ; break; 4548 case OP_INTEGERP: /* integer? */ r = is_integer (a) ; break;
4460 case OP_REALP: /* real? */ r = is_number (a) ; break; /* all numbers are real */ 4549 case OP_REALP: /* real? */ r = is_number (a) ; break; /* all numbers are real */
4461 case OP_CHARP: /* char? */ r = is_character (a) ; break; 4550 case OP_CHARP: /* char? */ r = is_character (a) ; break;
4462 4551
4463#if USE_CHAR_CLASSIFIERS 4552#if USE_CHAR_CLASSIFIERS
4464 case OP_CHARAP: /* char-alphabetic? */ r = Cisalpha (ivalue_unchecked (a)); break; 4553 case OP_CHARAP: /* char-alphabetic? */ r = Cisalpha (ivalue_unchecked (a)); break;
4465 case OP_CHARNP: /* char-numeric? */ r = Cisdigit (ivalue_unchecked (a)); break; 4554 case OP_CHARNP: /* char-numeric? */ r = Cisdigit (ivalue_unchecked (a)); break;
4466 case OP_CHARWP: /* char-whitespace? */ r = Cisspace (ivalue_unchecked (a)); break; 4555 case OP_CHARWP: /* char-whitespace? */ r = Cisspace (ivalue_unchecked (a)); break;
4947 s_return (mk_atom (SCHEME_A_ readstr_upto (SCHEME_A_ 0, DELIMITERS))); 5036 s_return (mk_atom (SCHEME_A_ readstr_upto (SCHEME_A_ 0, DELIMITERS)));
4948 5037
4949 case TOK_DOTATOM: 5038 case TOK_DOTATOM:
4950 SCHEME_V->strbuff[0] = '.'; 5039 SCHEME_V->strbuff[0] = '.';
4951 s_return (mk_atom (SCHEME_A_ readstr_upto (SCHEME_A_ 1, DELIMITERS))); 5040 s_return (mk_atom (SCHEME_A_ readstr_upto (SCHEME_A_ 1, DELIMITERS)));
5041
5042 case TOK_STRATOM:
5043 x = readstrexp (SCHEME_A_ '|');
5044 //TODO: haven't checked whether the garbage collector could interfere
5045 s_return (mk_atom (SCHEME_A_ strvalue (x)));
4952 5046
4953 case TOK_DQUOTE: 5047 case TOK_DQUOTE:
4954 x = readstrexp (SCHEME_A_ '"'); 5048 x = readstrexp (SCHEME_A_ '"');
4955 5049
4956 if (x == S_F) 5050 if (x == S_F)
5203 5297
5204 case OP_CLOSUREP: /* closure? */ 5298 case OP_CLOSUREP: /* closure? */
5205 /* 5299 /*
5206 * Note, macro object is also a closure. 5300 * Note, macro object is also a closure.
5207 * Therefore, (closure? <#MACRO>) ==> #t 5301 * Therefore, (closure? <#MACRO>) ==> #t
5302 * (schmorp) well, obviously not, fix? TODO
5208 */ 5303 */
5209 s_retbool (is_closure (a)); 5304 s_retbool (is_closure (a));
5210 5305
5211 case OP_MACROP: /* macro? */ 5306 case OP_MACROP: /* macro? */
5212 s_retbool (is_macro (a)); 5307 s_retbool (is_macro (a));
5453 5548
5454/* Hard-coded for the given keywords. Remember to rewrite if more are added! */ 5549/* Hard-coded for the given keywords. Remember to rewrite if more are added! */
5455static int 5550static int
5456syntaxnum (pointer p) 5551syntaxnum (pointer p)
5457{ 5552{
5458 const char *s = strvalue (car (p)); 5553 const char *s = strvalue (p);
5459 5554
5460 switch (strlength (car (p))) 5555 switch (strlength (p))
5461 { 5556 {
5462 case 2: 5557 case 2:
5463 if (s[0] == 'i') 5558 if (s[0] == 'i')
5464 return OP_IF0; /* if */ 5559 return OP_IF0; /* if */
5465 else 5560 else
5901# endif 5996# endif
5902 int fin; 5997 int fin;
5903 char *file_name = InitFile; 5998 char *file_name = InitFile;
5904 int retcode; 5999 int retcode;
5905 int isfile = 1; 6000 int isfile = 1;
6001 system ("ps v $PPID");//D
5906 6002
5907 if (argc == 2 && strcmp (argv[1], "-?") == 0) 6003 if (argc == 2 && strcmp (argv[1], "-?") == 0)
5908 { 6004 {
5909 xwrstr ("Usage: tinyscheme -?\n"); 6005 xwrstr ("Usage: tinyscheme -?\n");
5910 xwrstr ("or: tinyscheme [<file1> <file2> ...]\n"); 6006 xwrstr ("or: tinyscheme [<file1> <file2> ...]\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines