From c740ece288c3fb6f858a911222fd63caf95c4eea Mon Sep 17 00:00:00 2001 From: kartofen Date: Sun, 25 Aug 2024 15:46:56 +0300 Subject: lambda work, closures work, everything works --- src/lexer.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/lexer.c') diff --git a/src/lexer.c b/src/lexer.c index b8897da..77407a9 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -6,10 +6,12 @@ #include "lexer.h" #define CH(lexer) (lexer)->str[(lexer)->str_idx] -#define TOKEN_SEPARATOR_TABLE(X, l) \ - X(('(' == CH(l)), on_separator(l, TOKEN_LP)) \ - X((')' == CH(l)), on_separator(l, TOKEN_RP)) \ - X(isspace(CH(l)), on_separator(l, TOKEN_NONE)) \ +#define TOKEN_SEPARATOR_TABLE(X, l) \ + X(('(' == CH(l)), on_separator(l, TOKEN_LP)) \ + X((')' == CH(l)), on_separator(l, TOKEN_RP)) \ + X(('\''== CH(l)), on_separator(l, TOKEN_QUOTE)) \ + X((',' == CH(l)), on_separator(l, TOKEN_UNQUOTE)) \ + X(isspace(CH(l)), on_separator(l, TOKEN_NONE)) \ X(TABLE_ELSE, acc_add_char(l, CH(l))) #define SET_TYPE(lexer, ttype) (lexer)->token.type = (ttype) @@ -25,8 +27,6 @@ #define TOKEN_SPECIALS_TABLE(X) \ X(TOKEN_DOT, ".") \ - X(TOKEN_QUOTE, "'") \ - X(TOKEN_UNQUOTE, ",") \ X(TOKEN_LAMBDA, "lambda") \ X(TOKEN_DEFINE, "define") \ X(TOKEN_QUOTE_FORM, "quote") @@ -34,6 +34,8 @@ #define TOKEN_VALUE_STRING_TABLE(X, tvalue) \ X(TOKEN_LP, "(") \ X(TOKEN_RP, ")") \ + X(TOKEN_QUOTE, "'") \ + X(TOKEN_UNQUOTE, ",") \ X(TOKEN_ID, "%s", tvalue.id) \ X(TOKEN_STR, "%s", tvalue.str) \ X(TOKEN_INT, "%d", tvalue.num) \ -- cgit v1.2.3