projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos/lisp: Make read() return eof atom on end of file
[fw/altos]
/
src
/
lisp
/
ao_lisp_read.c
diff --git
a/src/lisp/ao_lisp_read.c
b/src/lisp/ao_lisp_read.c
index 3a2ef7f1f15cef109e81589a1adcd6e33132f61a..7a5751cef0315a7ec4662b3a49ab6ab0490a6592 100644
(file)
--- a/
src/lisp/ao_lisp_read.c
+++ b/
src/lisp/ao_lisp_read.c
@@
-12,6
+12,7
@@
* General Public License for more details.
*/
* General Public License for more details.
*/
+#define DBG_EVAL 0
#include "ao_lisp.h"
#include "ao_lisp_read.h"
#include "ao_lisp.h"
#include "ao_lisp_read.h"
@@
-270,7
+271,7
@@
lex(void)
for (;;) {
c = lexc();
if (lex_class & ENDOFFILE)
for (;;) {
c = lexc();
if (lex_class & ENDOFFILE)
- return
AO_LISP_NIL
;
+ return
END
;
if (lex_class & WHITE)
continue;
if (lex_class & WHITE)
continue;
@@
-278,7
+279,7
@@
lex(void)
if (lex_class & COMMENT) {
while ((c = lexc()) != '\n') {
if (lex_class & ENDOFFILE)
if (lex_class & COMMENT) {
while ((c = lexc()) != '\n') {
if (lex_class & ENDOFFILE)
- return
AO_LISP_NIL
;
+ return
END
;
}
continue;
}
}
continue;
}
@@
-364,6
+365,8
@@
static struct ao_lisp_cons *read_stack;
static int
push_read_stack(int cons, int in_quote)
{
static int
push_read_stack(int cons, int in_quote)
{
+ DBGI("push read stack %p %d\n", read_cons, in_quote);
+ DBG_IN();
if (cons) {
read_stack = ao_lisp_cons_cons(ao_lisp_cons_poly(read_cons),
ao_lisp_cons_cons(ao_lisp_int_poly(in_quote),
if (cons) {
read_stack = ao_lisp_cons_cons(ao_lisp_cons_poly(read_cons),
ao_lisp_cons_cons(ao_lisp_int_poly(in_quote),
@@
-394,6
+397,8
@@
pop_read_stack(int cons)
read_cons_tail = 0;
read_stack = 0;
}
read_cons_tail = 0;
read_stack = 0;
}
+ DBG_OUT();
+ DBGI("pop read stack %p %d\n", read_cons, in_quote);
return in_quote;
}
return in_quote;
}
@@
-413,6
+418,7
@@
ao_lisp_read(void)
been_here = 1;
}
parse_token = lex();
been_here = 1;
}
parse_token = lex();
+ DBGI("token %d (%s)\n", parse_token, token_string);
cons = 0;
in_quote = 0;
cons = 0;
in_quote = 0;
@@
-424,12
+430,15
@@
ao_lisp_read(void)
cons++;
in_quote = 0;
parse_token = lex();
cons++;
in_quote = 0;
parse_token = lex();
+ DBGI("token %d (%s)\n", parse_token, token_string);
}
switch (parse_token) {
}
switch (parse_token) {
- case END
OFFILE
:
+ case END:
default:
default:
- v = AO_LISP_NIL;
+ if (cons)
+ ao_lisp_error(AO_LISP_EOF, "unexpected end of file");
+ return _ao_lisp_atom_eof;
break;
case NAME:
atom = ao_lisp_atom_intern(token_string);
break;
case NAME:
atom = ao_lisp_atom_intern(token_string);
@@
-490,6
+499,7
@@
ao_lisp_read(void)
}
parse_token = lex();
}
parse_token = lex();
+ DBGI("token %d (%s)\n", parse_token, token_string);
}
return v;
}
}
return v;
}