X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Flisp%2Fao_lisp_read.c;fp=src%2Flisp%2Fao_lisp_read.c;h=508d16b4d821f8247d8b0db9336d1be21a49458a;hb=b3b4731fcb89cb404433f37a7704a503567c43bd;hp=550f62c2c19d94c3c5431ea2fa0eb0fedf1a330e;hpb=bd881a5b85d7cd4fb82127f92f32e089499b50cb;p=fw%2Faltos diff --git a/src/lisp/ao_lisp_read.c b/src/lisp/ao_lisp_read.c index 550f62c2..508d16b4 100644 --- a/src/lisp/ao_lisp_read.c +++ b/src/lisp/ao_lisp_read.c @@ -51,18 +51,18 @@ static const uint16_t lex_classes[128] = { PRINTABLE|WHITE, /* */ PRINTABLE, /* ! */ PRINTABLE|STRINGC, /* " */ - PRINTABLE|COMMENT, /* # */ + PRINTABLE|POUND, /* # */ PRINTABLE, /* $ */ PRINTABLE, /* % */ PRINTABLE, /* & */ - PRINTABLE|QUOTEC, /* ' */ - PRINTABLE|BRA, /* ( */ - PRINTABLE|KET, /* ) */ + PRINTABLE|SPECIAL, /* ' */ + PRINTABLE|SPECIAL, /* ( */ + PRINTABLE|SPECIAL, /* ) */ PRINTABLE, /* * */ PRINTABLE|SIGN, /* + */ PRINTABLE, /* , */ PRINTABLE|SIGN, /* - */ - PRINTABLE|DOTC, /* . */ + PRINTABLE|SPECIAL, /* . */ PRINTABLE, /* / */ PRINTABLE|DIGIT, /* 0 */ PRINTABLE|DIGIT, /* 1 */ @@ -283,27 +283,38 @@ _lex(void) continue; } - if (lex_class & (BRA|KET|QUOTEC)) { + if (lex_class & SPECIAL) { add_token(c); end_token(); switch (c) { case '(': + case '[': return OPEN; case ')': + case ']': return CLOSE; case '\'': return QUOTE; + case '.': + return DOT; } } - if (lex_class & (DOTC)) { - add_token(c); - end_token(); - return DOT; - } if (lex_class & TWIDDLE) { token_int = lexc(); return NUM; } + if (lex_class & POUND) { + for (;;) { + c = lexc(); + add_token(c); + switch (c) { + case 't': + return BOOL; + case 'f': + return BOOL; + } + } + } if (lex_class & STRINGC) { for (;;) { c = lexc(); @@ -457,6 +468,12 @@ ao_lisp_read(void) case NUM: v = ao_lisp_int_poly(token_int); break; + case BOOL: + if (token_string[0] == 't') + v = _ao_lisp_bool_true; + else + v = _ao_lisp_bool_false; + break; case STRING: string = ao_lisp_string_copy(token_string); if (string)