7d540aa5af22f26991dacd194371bbc9673215a6
[fw/altos] / src / scheme / ao_scheme_read.c
1 /*
2  * Copyright © 2016 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  */
14
15 #include "ao_scheme.h"
16 #include "ao_scheme_read.h"
17 #include <math.h>
18 #include <stdlib.h>
19
20 static const uint16_t   lex_classes[128] = {
21         IGNORE,         /* ^@ */
22         IGNORE,         /* ^A */
23         IGNORE,         /* ^B */
24         IGNORE,         /* ^C */
25         IGNORE,         /* ^D */
26         IGNORE,         /* ^E */
27         IGNORE,         /* ^F */
28         IGNORE,         /* ^G */
29         IGNORE,         /* ^H */
30         WHITE,          /* ^I */
31         WHITE,          /* ^J */
32         WHITE,          /* ^K */
33         WHITE,          /* ^L */
34         WHITE,          /* ^M */
35         IGNORE,         /* ^N */
36         IGNORE,         /* ^O */
37         IGNORE,         /* ^P */
38         IGNORE,         /* ^Q */
39         IGNORE,         /* ^R */
40         IGNORE,         /* ^S */
41         IGNORE,         /* ^T */
42         IGNORE,         /* ^U */
43         IGNORE,         /* ^V */
44         IGNORE,         /* ^W */
45         IGNORE,         /* ^X */
46         IGNORE,         /* ^Y */
47         IGNORE,         /* ^Z */
48         IGNORE,         /* ^[ */
49         IGNORE,         /* ^\ */
50         IGNORE,         /* ^] */
51         IGNORE,         /* ^^ */
52         IGNORE,         /* ^_ */
53         PRINTABLE|WHITE,        /*    */
54         PRINTABLE,              /* ! */
55         PRINTABLE|STRINGC,      /* " */
56         PRINTABLE,              /* # */
57         PRINTABLE,              /* $ */
58         PRINTABLE,              /* % */
59         PRINTABLE,              /* & */
60         PRINTABLE|SPECIAL,      /* ' */
61         PRINTABLE|SPECIAL,      /* ( */
62         PRINTABLE|SPECIAL,      /* ) */
63         PRINTABLE,              /* * */
64         PRINTABLE|SIGN,         /* + */
65         PRINTABLE|SPECIAL_QUASI,        /* , */
66         PRINTABLE|SIGN,         /* - */
67         PRINTABLE|DOTC|FLOATC,  /* . */
68         PRINTABLE,              /* / */
69         PRINTABLE|DIGIT,        /* 0 */
70         PRINTABLE|DIGIT,        /* 1 */
71         PRINTABLE|DIGIT,        /* 2 */
72         PRINTABLE|DIGIT,        /* 3 */
73         PRINTABLE|DIGIT,        /* 4 */
74         PRINTABLE|DIGIT,        /* 5 */
75         PRINTABLE|DIGIT,        /* 6 */
76         PRINTABLE|DIGIT,        /* 7 */
77         PRINTABLE|DIGIT,        /* 8 */
78         PRINTABLE|DIGIT,        /* 9 */
79         PRINTABLE,              /* : */
80         PRINTABLE|COMMENT,      /* ; */
81         PRINTABLE,              /* < */
82         PRINTABLE,              /* = */
83         PRINTABLE,              /* > */
84         PRINTABLE,              /* ? */
85         PRINTABLE,              /*  @ */
86         PRINTABLE|HEX_LETTER,   /*  A */
87         PRINTABLE|HEX_LETTER,   /*  B */
88         PRINTABLE|HEX_LETTER,   /*  C */
89         PRINTABLE|HEX_LETTER,   /*  D */
90         PRINTABLE|FLOATC|HEX_LETTER,/*  E */
91         PRINTABLE|HEX_LETTER,   /*  F */
92         PRINTABLE,              /*  G */
93         PRINTABLE,              /*  H */
94         PRINTABLE,              /*  I */
95         PRINTABLE,              /*  J */
96         PRINTABLE,              /*  K */
97         PRINTABLE,              /*  L */
98         PRINTABLE,              /*  M */
99         PRINTABLE,              /*  N */
100         PRINTABLE,              /*  O */
101         PRINTABLE,              /*  P */
102         PRINTABLE,              /*  Q */
103         PRINTABLE,              /*  R */
104         PRINTABLE,              /*  S */
105         PRINTABLE,              /*  T */
106         PRINTABLE,              /*  U */
107         PRINTABLE,              /*  V */
108         PRINTABLE,              /*  W */
109         PRINTABLE,              /*  X */
110         PRINTABLE,              /*  Y */
111         PRINTABLE,              /*  Z */
112         PRINTABLE,              /*  [ */
113         PRINTABLE|BACKSLASH,    /*  \ */
114         PRINTABLE,              /*  ] */
115         PRINTABLE,              /*  ^ */
116         PRINTABLE,              /*  _ */
117         PRINTABLE|SPECIAL_QUASI,        /*  ` */
118         PRINTABLE|HEX_LETTER,   /*  a */
119         PRINTABLE|HEX_LETTER,   /*  b */
120         PRINTABLE|HEX_LETTER,   /*  c */
121         PRINTABLE|HEX_LETTER,   /*  d */
122         PRINTABLE|FLOATC|HEX_LETTER,/*  e */
123         PRINTABLE|HEX_LETTER,   /*  f */
124         PRINTABLE,              /*  g */
125         PRINTABLE,              /*  h */
126         PRINTABLE,              /*  i */
127         PRINTABLE,              /*  j */
128         PRINTABLE,              /*  k */
129         PRINTABLE,              /*  l */
130         PRINTABLE,              /*  m */
131         PRINTABLE,              /*  n */
132         PRINTABLE,              /*  o */
133         PRINTABLE,              /*  p */
134         PRINTABLE,              /*  q */
135         PRINTABLE,              /*  r */
136         PRINTABLE,              /*  s */
137         PRINTABLE,              /*  t */
138         PRINTABLE,              /*  u */
139         PRINTABLE,              /*  v */
140         PRINTABLE,              /*  w */
141         PRINTABLE,              /*  x */
142         PRINTABLE,              /*  y */
143         PRINTABLE,              /*  z */
144         PRINTABLE,              /*  { */
145         PRINTABLE,              /*  | */
146         PRINTABLE,              /*  } */
147         PRINTABLE,              /*  ~ */
148         IGNORE,                 /*  ^? */
149 };
150
151 static int lex_unget_c;
152
153 static inline int
154 lex_get(void)
155 {
156         int     c;
157         if (lex_unget_c) {
158                 c = lex_unget_c;
159                 lex_unget_c = 0;
160         } else {
161                 c = ao_scheme_getc();
162         }
163         return c;
164 }
165
166 static inline void
167 lex_unget(int c)
168 {
169         if (c != EOF)
170                 lex_unget_c = c;
171 }
172
173 static uint16_t lex_class;
174
175 static int
176 lexc(void)
177 {
178         int     c;
179         do {
180                 c = lex_get();
181                 if (c == EOF) {
182                         c = 0;
183                         lex_class = ENDOFFILE;
184                 } else {
185                         c &= 0x7f;
186                         lex_class = lex_classes[c];
187                 }
188         } while (lex_class & IGNORE);
189         return c;
190 }
191
192 static int
193 lex_quoted(void)
194 {
195         int     c;
196         int     v;
197         int     count;
198
199         c = lex_get();
200         if (c == EOF) {
201                 lex_class = ENDOFFILE;
202                 return 0;
203         }
204         lex_class = 0;
205         c &= 0x7f;
206         switch (c) {
207         case 'n':
208                 return '\n';
209         case 'f':
210                 return '\f';
211         case 'b':
212                 return '\b';
213         case 'r':
214                 return '\r';
215         case 'v':
216                 return '\v';
217         case 't':
218                 return '\t';
219         case '0':
220         case '1':
221         case '2':
222         case '3':
223         case '4':
224         case '5':
225         case '6':
226         case '7':
227                 v = c - '0';
228                 count = 1;
229                 while (count <= 3) {
230                         c = lex_get();
231                         if (c == EOF)
232                                 return EOF;
233                         c &= 0x7f;
234                         if (c < '0' || '7' < c) {
235                                 lex_unget(c);
236                                 break;
237                         }
238                         v = (v << 3) + c - '0';
239                         ++count;
240                 }
241                 return v;
242         default:
243                 return c;
244         }
245 }
246
247 #ifndef AO_SCHEME_TOKEN_MAX
248 #define AO_SCHEME_TOKEN_MAX     128
249 #endif
250
251 static char     token_string[AO_SCHEME_TOKEN_MAX];
252 static int32_t  token_int;
253 static int      token_len;
254
255 static inline void add_token(int c) {
256         if (c && token_len < AO_SCHEME_TOKEN_MAX - 1)
257                 token_string[token_len++] = c;
258 }
259
260 static inline void del_token(void) {
261         if (token_len > 0)
262                 token_len--;
263 }
264
265 static inline void end_token(void) {
266         token_string[token_len] = '\0';
267 }
268
269 #ifdef AO_SCHEME_FEATURE_FLOAT
270 static float    token_float;
271
272 struct namedfloat {
273         const char      *name;
274         float           value;
275 };
276
277 static const struct namedfloat namedfloats[] = {
278         { .name = "+inf.0", .value = INFINITY },
279         { .name = "-inf.0", .value = -INFINITY },
280         { .name = "+nan.0", .value = NAN },
281         { .name = "-nan.0", .value = NAN },
282 };
283
284 #define NUM_NAMED_FLOATS        (sizeof namedfloats / sizeof namedfloats[0])
285 #endif
286
287 static int
288 parse_int(int base)
289 {
290         int     cval;
291         int     c;
292
293         token_int = 0;
294         for (;;) {
295                 c = lexc();
296                 if ((lex_class & HEX_DIGIT) == 0) {
297                         lex_unget(c);
298                         end_token();
299                         return NUM;
300                 }
301                 add_token(c);
302                 if ('0' <= c && c <= '9')
303                         cval = c - '0';
304                 else
305                         cval = (c | ('a' - 'A')) - 'a' + 10;
306                 token_int = token_int * base + cval;
307         }
308         return NUM;
309 }
310
311 static int
312 _lex(void)
313 {
314         int     c;
315
316         token_len = 0;
317         for (;;) {
318                 c = lexc();
319                 if (lex_class & ENDOFFILE)
320                         return END;
321
322                 if (lex_class & WHITE)
323                         continue;
324
325                 if (lex_class & COMMENT) {
326                         while ((c = lexc()) != '\n') {
327                                 if (lex_class & ENDOFFILE)
328                                         return END;
329                         }
330                         continue;
331                 }
332
333                 if (lex_class & (SPECIAL|DOTC)) {
334                         add_token(c);
335                         end_token();
336                         switch (c) {
337                         case '(':
338                         case '[':
339                                 return OPEN;
340                         case ')':
341                         case ']':
342                                 return CLOSE;
343                         case '\'':
344                                 return QUOTE;
345                         case '.':
346                                 return DOT;
347 #ifdef AO_SCHEME_FEATURE_QUASI
348                         case '`':
349                                 return QUASIQUOTE;
350                         case ',':
351                                 c = lexc();
352                                 if (c == '@') {
353                                         add_token(c);
354                                         end_token();
355                                         return UNQUOTE_SPLICING;
356                                 } else {
357                                         lex_unget(c);
358                                         return UNQUOTE;
359                                 }
360 #endif
361                         }
362                 }
363                 if (c == '#') {
364                         c = lexc();
365                         switch (c) {
366                         case 't':
367                                 add_token(c);
368                                 end_token();
369                                 return BOOL;
370                         case 'f':
371                                 add_token(c);
372                                 end_token();
373                                 return BOOL;
374 #ifdef AO_SCHEME_FEATURE_VECTOR
375                         case '(':
376                                 return OPEN_VECTOR;
377 #endif
378                         case '\\':
379                                 for (;;) {
380                                         int alphabetic;
381                                         c = lexc();
382                                         alphabetic = (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'));
383                                         if (token_len == 0) {
384                                                 add_token(c);
385                                                 if (!alphabetic)
386                                                         break;
387                                         } else {
388                                                 if (alphabetic)
389                                                         add_token(c);
390                                                 else {
391                                                         lex_unget(c);
392                                                         break;
393                                                 }
394                                         }
395                                 }
396                                 end_token();
397                                 if (token_len == 1)
398                                         token_int = token_string[0];
399                                 else if (!strcmp(token_string, "space"))
400                                         token_int = ' ';
401                                 else if (!strcmp(token_string, "newline"))
402                                         token_int = '\n';
403                                 else if (!strcmp(token_string, "tab"))
404                                         token_int = '\t';
405                                 else if (!strcmp(token_string, "return"))
406                                         token_int = '\r';
407                                 else if (!strcmp(token_string, "formfeed"))
408                                         token_int = '\f';
409                                 else {
410                                         ao_scheme_error(AO_SCHEME_INVALID, "invalid character token #\\%s", token_string);
411                                         continue;
412                                 }
413                                 return NUM;
414                         case 'x':
415                                 return parse_int(16);
416                         case 'o':
417                                 return parse_int(8);
418                         case 'b':
419                                 return parse_int(2);
420                         }
421                 }
422                 if (lex_class & STRINGC) {
423                         for (;;) {
424                                 c = lexc();
425                                 if (lex_class & BACKSLASH)
426                                         c = lex_quoted();
427                                 if (lex_class & (STRINGC|ENDOFFILE)) {
428                                         end_token();
429                                         return STRING;
430                                 }
431                                 add_token(c);
432                         }
433                 }
434                 if (lex_class & PRINTABLE) {
435 #ifdef AO_SCHEME_FEATURE_FLOAT
436                         int     isfloat = 1;
437                         int     epos = 0;
438 #endif
439                         int     hasdigit = 0;
440                         int     isneg = 0;
441                         int     isint = 1;
442
443                         token_int = 0;
444                         for (;;) {
445                                 if (!(lex_class & NUMBER)) {
446                                         isint = 0;
447 #ifdef AO_SCHEME_FEATURE_FLOAT
448                                         isfloat = 0;
449 #endif
450                                 } else {
451 #ifdef AO_SCHEME_FEATURE_FLOAT
452                                         if (!(lex_class & INTEGER))
453                                                 isint = 0;
454                                         if (token_len != epos &&
455                                             (lex_class & SIGN))
456                                         {
457                                                 isint = 0;
458                                                 isfloat = 0;
459                                         }
460 #endif
461                                         if (c == '-')
462                                                 isneg = 1;
463 #ifdef AO_SCHEME_FEATURE_FLOAT
464                                         if (c == '.' && epos != 0)
465                                                 isfloat = 0;
466                                         if (c == 'e' || c == 'E') {
467                                                 if (token_len == 0)
468                                                         isfloat = 0;
469                                                 else
470                                                         epos = token_len + 1;
471                                         }
472 #endif
473                                         if (lex_class & DIGIT) {
474                                                 hasdigit = 1;
475                                                 if (isint)
476                                                         token_int = token_int * 10 + c - '0';
477                                         }
478                                 }
479                                 add_token (c);
480                                 c = lexc ();
481                                 if ((lex_class & (NOTNAME))
482 #ifdef AO_SCHEME_FEATURE_FLOAT
483                                     && (c != '.' || !isfloat)
484 #endif
485                                         ) {
486 #ifdef AO_SCHEME_FEATURE_FLOAT
487                                         unsigned int u;
488 #endif
489 //                                      if (lex_class & ENDOFFILE)
490 //                                              clearerr (f);
491                                         lex_unget(c);
492                                         end_token ();
493                                         if (isint && hasdigit) {
494                                                 if (isneg)
495                                                         token_int = -token_int;
496                                                 return NUM;
497                                         }
498 #ifdef AO_SCHEME_FEATURE_FLOAT
499                                         if (isfloat && hasdigit) {
500                                                 token_float = strtof(token_string, NULL);
501                                                 return FLOAT;
502                                         }
503                                         for (u = 0; u < NUM_NAMED_FLOATS; u++)
504                                                 if (!strcmp(namedfloats[u].name, token_string)) {
505                                                         token_float = namedfloats[u].value;
506                                                         return FLOAT;
507                                                 }
508 #endif
509                                         return NAME;
510                                 }
511                         }
512                 }
513         }
514 }
515
516 static inline int lex(void)
517 {
518         int     parse_token = _lex();
519         RDBGI("token %d \"%s\"\n", parse_token, token_string);
520         return parse_token;
521 }
522
523 static int parse_token;
524
525 int                     ao_scheme_read_list;
526 struct ao_scheme_cons   *ao_scheme_read_cons;
527 struct ao_scheme_cons   *ao_scheme_read_cons_tail;
528 struct ao_scheme_cons   *ao_scheme_read_stack;
529 static int              ao_scheme_read_state;
530
531 #define READ_IN_QUOTE   0x01
532 #define READ_SAW_DOT    0x02
533 #define READ_DONE_DOT   0x04
534 #define READ_SAW_VECTOR 0x08
535
536 static int
537 push_read_stack(int read_state)
538 {
539         RDBGI("push read stack %p 0x%x\n", ao_scheme_read_cons, read_state);
540         RDBG_IN();
541         if (ao_scheme_read_list) {
542                 ao_scheme_read_stack = ao_scheme_cons_cons(ao_scheme_cons_poly(ao_scheme_read_cons),
543                                                        ao_scheme_cons(ao_scheme_int_poly(read_state),
544                                                                      ao_scheme_cons_poly(ao_scheme_read_stack)));
545                 if (!ao_scheme_read_stack)
546                         return 0;
547         } else
548                 ao_scheme_read_state = read_state;
549         ao_scheme_read_cons = NULL;
550         ao_scheme_read_cons_tail = NULL;
551         return 1;
552 }
553
554 static int
555 pop_read_stack(void)
556 {
557         int     read_state = 0;
558         if (ao_scheme_read_list) {
559                 ao_scheme_read_cons = ao_scheme_poly_cons(ao_scheme_read_stack->car);
560                 ao_scheme_read_stack = ao_scheme_poly_cons(ao_scheme_read_stack->cdr);
561                 read_state = ao_scheme_poly_int(ao_scheme_read_stack->car);
562                 ao_scheme_read_stack = ao_scheme_poly_cons(ao_scheme_read_stack->cdr);
563                 for (ao_scheme_read_cons_tail = ao_scheme_read_cons;
564                      ao_scheme_read_cons_tail && ao_scheme_read_cons_tail->cdr;
565                      ao_scheme_read_cons_tail = ao_scheme_poly_cons(ao_scheme_read_cons_tail->cdr))
566                         ;
567         } else {
568                 read_state = ao_scheme_read_state;
569                 ao_scheme_read_cons = NULL;
570                 ao_scheme_read_cons_tail = NULL;
571                 ao_scheme_read_stack = NULL;
572                 ao_scheme_read_state = 0;
573         }
574         RDBG_OUT();
575         RDBGI("pop read stack %p %d\n", ao_scheme_read_cons, read_state);
576         return read_state;
577 }
578
579 #ifdef AO_SCHEME_FEATURE_VECTOR
580 #define is_open(t) ((t) == OPEN || (t) == OPEN_VECTOR)
581 #else
582 #define is_open(t) ((t) == OPEN)
583 #endif
584
585 ao_poly
586 ao_scheme_read(void)
587 {
588         struct ao_scheme_atom   *atom;
589         struct ao_scheme_string *string;
590         int                     read_state;
591         ao_poly                 v = AO_SCHEME_NIL;
592
593         ao_scheme_read_list = 0;
594         read_state = 0;
595         ao_scheme_read_cons = ao_scheme_read_cons_tail = ao_scheme_read_stack = NULL;
596         for (;;) {
597                 parse_token = lex();
598                 while (is_open(parse_token)) {
599 #ifdef AO_SCHEME_FEATURE_VECTOR
600                         if (parse_token == OPEN_VECTOR)
601                                 read_state |= READ_SAW_VECTOR;
602 #endif
603                         if (!push_read_stack(read_state))
604                                 return AO_SCHEME_NIL;
605                         ao_scheme_read_list++;
606                         read_state = 0;
607                         parse_token = lex();
608                 }
609
610                 switch (parse_token) {
611                 case END:
612                 default:
613                         if (ao_scheme_read_list)
614                                 ao_scheme_error(AO_SCHEME_EOF, "unexpected end of file");
615                         return _ao_scheme_atom_eof;
616                         break;
617                 case NAME:
618                         atom = ao_scheme_atom_intern(token_string);
619                         if (atom)
620                                 v = ao_scheme_atom_poly(atom);
621                         else
622                                 v = AO_SCHEME_NIL;
623                         break;
624                 case NUM:
625                         v = ao_scheme_integer_poly(token_int);
626                         break;
627 #ifdef AO_SCHEME_FEATURE_FLOAT
628                 case FLOAT:
629                         v = ao_scheme_float_get(token_float);
630                         break;
631 #endif
632                 case BOOL:
633                         if (token_string[0] == 't')
634                                 v = _ao_scheme_bool_true;
635                         else
636                                 v = _ao_scheme_bool_false;
637                         break;
638                 case STRING:
639                         string = ao_scheme_string_make(token_string);
640                         if (string)
641                                 v = ao_scheme_string_poly(string);
642                         else
643                                 v = AO_SCHEME_NIL;
644                         break;
645                 case QUOTE:
646 #ifdef AO_SCHEME_FEATURE_QUASI
647                 case QUASIQUOTE:
648                 case UNQUOTE:
649                 case UNQUOTE_SPLICING:
650 #endif
651                         if (!push_read_stack(read_state))
652                                 return AO_SCHEME_NIL;
653                         ao_scheme_read_list++;
654                         read_state = READ_IN_QUOTE;
655                         switch (parse_token) {
656                         case QUOTE:
657                                 v = _ao_scheme_atom_quote;
658                                 break;
659 #ifdef AO_SCHEME_FEATURE_QUASI
660                         case QUASIQUOTE:
661                                 v = _ao_scheme_atom_quasiquote;
662                                 break;
663                         case UNQUOTE:
664                                 v = _ao_scheme_atom_unquote;
665                                 break;
666                         case UNQUOTE_SPLICING:
667                                 v = _ao_scheme_atom_unquote2dsplicing;
668                                 break;
669 #endif
670                         }
671                         break;
672                 case CLOSE:
673                         if (!ao_scheme_read_list) {
674                                 v = AO_SCHEME_NIL;
675                                 break;
676                         }
677                         v = ao_scheme_cons_poly(ao_scheme_read_cons);
678                         --ao_scheme_read_list;
679                         read_state = pop_read_stack();
680 #ifdef AO_SCHEME_FEATURE_VECTOR
681                         if (read_state & READ_SAW_VECTOR) {
682                                 v = ao_scheme_vector_poly(ao_scheme_list_to_vector(ao_scheme_poly_cons(v)));
683                                 read_state &= ~READ_SAW_VECTOR;
684                         }
685 #endif
686                         break;
687                 case DOT:
688                         if (!ao_scheme_read_list) {
689                                 ao_scheme_error(AO_SCHEME_INVALID, ". outside of cons");
690                                 return AO_SCHEME_NIL;
691                         }
692                         if (!ao_scheme_read_cons) {
693                                 ao_scheme_error(AO_SCHEME_INVALID, ". first in cons");
694                                 return AO_SCHEME_NIL;
695                         }
696                         read_state |= READ_SAW_DOT;
697                         continue;
698                 }
699
700                 /* loop over QUOTE ends */
701                 for (;;) {
702                         if (!ao_scheme_read_list)
703                                 return v;
704
705                         if (read_state & READ_DONE_DOT) {
706                                 ao_scheme_error(AO_SCHEME_INVALID, ". not last in cons");
707                                 return AO_SCHEME_NIL;
708                         }
709
710                         if (read_state & READ_SAW_DOT) {
711                                 read_state |= READ_DONE_DOT;
712                                 ao_scheme_read_cons_tail->cdr = v;
713                         } else {
714                                 struct ao_scheme_cons   *read = ao_scheme_cons_cons(v, AO_SCHEME_NIL);
715                                 if (!read)
716                                         return AO_SCHEME_NIL;
717
718                                 if (ao_scheme_read_cons_tail)
719                                         ao_scheme_read_cons_tail->cdr = ao_scheme_cons_poly(read);
720                                 else
721                                         ao_scheme_read_cons = read;
722                                 ao_scheme_read_cons_tail = read;
723                         }
724
725                         if (!(read_state & READ_IN_QUOTE) || !ao_scheme_read_cons->cdr)
726                                 break;
727
728                         v = ao_scheme_cons_poly(ao_scheme_read_cons);
729                         --ao_scheme_read_list;
730                         read_state = pop_read_stack();
731                 }
732         }
733         return v;
734 }