aboutsummaryrefslogtreecommitdiff
path: root/src/parser.c
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-06-27 21:21:42 +0800
committerMistivia <i@mistivia.com>2025-06-27 21:21:42 +0800
commit878a056f3accafaa797446eb3a3b1a66b36d0d07 (patch)
treef56330127b96bdff11f2bd37b7229a94d02fcacc /src/parser.c
parent0ba662762023b7e3788690d9990ab39e89fd6f34 (diff)
add more funcs
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/parser.c b/src/parser.c
index d8fda82..ec21b44 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -350,12 +350,20 @@ static ParseResult parse_token(Parser *parser, const char *token) {
if (len < 2) return ParseErr(parser, "Expect boolean or character.\n");
if (token[1] == '\'') {
if (len < 3) return ParseErr(parser, "Expect a symbol.\n");
+ if (len == 3) {
+ if (token[2] == '+' || token[2] == '-') {
+ goto funcmacro;
+ }
+ }
if (!is_symbol_init(token[2])) return ParseErr(parser, "Expect a symbol.\n");
for (int i = 3; i < len; i++) {
if (!is_symbol_subsequent(token[i])) return ParseErr(parser, "Expect a symbol.\n");
}
- SExpRef funcsym = new_symbol(parser->ctx, "function");
- SExpRef sym = new_symbol(parser->ctx, token+2);
+ SExpRef funcsym;
+ SExpRef sym;
+ funcmacro:
+ funcsym = new_symbol(parser->ctx, "function");
+ sym = new_symbol(parser->ctx, token+2);
return ParseOk(lisp_cons(parser->ctx, funcsym, lisp_cons(parser->ctx, sym, parser->ctx->nil)));
}
if (token[1] == 't') return ParseOk(new_boolean(parser->ctx, true));