summaryrefslogtreecommitdiff
path: root/src/lisp/ao_lisp_read.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-11-02 22:56:01 -0700
committerKeith Packard <keithp@keithp.com>2017-02-20 11:16:49 -0800
commit11cb03b1d336ee90c422be27588f57be573a9546 (patch)
tree944a9c36379c02383081fd3246395158f662ce7b /src/lisp/ao_lisp_read.c
parent9e1a787f8828fb7b750ad3310c89a89536ea5286 (diff)
altos/lisp: Separate out values from atoms
This enables changing values of atoms declared as constants, should enable lets, and with some work, even lexical scoping. this required changing the constant computation to run ao_lisp_collect() before dumping the block of constant data, and that uncovered some minor memory manager bugs. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp/ao_lisp_read.c')
-rw-r--r--src/lisp/ao_lisp_read.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/lisp/ao_lisp_read.c b/src/lisp/ao_lisp_read.c
index 8fc134e5..bc1eb36b 100644
--- a/src/lisp/ao_lisp_read.c
+++ b/src/lisp/ao_lisp_read.c
@@ -188,8 +188,6 @@ lex_quoted (void)
int count;
c = lex_get();
-// if (jumping)
-// return nil;
if (c == EOF)
return EOF;
c &= 0x7f;
@@ -218,8 +216,6 @@ lex_quoted (void)
count = 1;
while (count <= 3) {
c = lex_get();
-// if (jumping)
-// return nil;
if (c == EOF)
return EOF;
c &= 0x7f;
@@ -288,11 +284,17 @@ lex(void)
if (lex_class & ENDOFFILE)
return AO_LISP_NIL;
-// if (jumping)
-// return nil;
if (lex_class & WHITE)
continue;
+ if (lex_class & COMMENT) {
+ while ((c = lexc()) != '\n') {
+ if (lex_class & ENDOFFILE)
+ return AO_LISP_NIL;
+ }
+ continue;
+ }
+
if (lex_class & (BRA|KET|QUOTEC)) {
add_token(c);
end_token();
@@ -312,8 +314,6 @@ lex(void)
if (lex_class & STRINGC) {
for (;;) {
c = lexc();
-// if (jumping)
-// return nil;
if (lex_class & (STRINGC|ENDOFFILE)) {
end_token();
return STRING;
@@ -349,8 +349,6 @@ lex(void)
}
add_token (c);
c = lexc ();
-// if (jumping)
-// return nil;
if (lex_class & (NOTNAME)) {
// if (lex_class & ENDOFFILE)
// clearerr (f);
@@ -403,6 +401,10 @@ pop_read_stack(int cons)
read_cons_tail && read_cons_tail->cdr;
read_cons_tail = ao_lisp_poly_cons(read_cons_tail->cdr))
;
+ } else {
+ read_cons = 0;
+ read_cons_tail = 0;
+ read_stack = 0;
}
return in_quote;
}
@@ -420,6 +422,7 @@ ao_lisp_read(void)
ao_lisp_root_add(&ao_lisp_cons_type, &read_cons);
ao_lisp_root_add(&ao_lisp_cons_type, &read_cons_tail);
ao_lisp_root_add(&ao_lisp_cons_type, &read_stack);
+ been_here = 1;
}
parse_token = lex();