commit 7050dd6360f842963ccfb4858765bb5faa4da337
parent 8480c7bcaea20aae2597b6a20387405ceba7d4b3
Author: m21c <ho*******@gmail.com>
Date: Sat, 2 Oct 2021 14:20:32 +0200
fixed getunary() and isdelimiter() + fixed defer type decl check
Diffstat:
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/compiler.c b/compiler.c
@@ -1404,10 +1404,8 @@ isbasicdelimiter(Kind kind)
}
static Kind
-getunary(Source *source)
+getunary(Kind kind)
{
- Kind kind = source->tok.kind;
-
if (getprec(kind) == PUNARY)
return kind;
@@ -1893,7 +1891,7 @@ checkend(Source *source, bool hastail, int needindent,
}
}
- if (isdelimiter(source))
+ if (isdelimiter(source->tok.kind))
return true;
if (hastail && source->lastkind != '\n' && source->lastkind != ';')
@@ -2163,7 +2161,7 @@ readident(Source *source, int flags)
gettok(source);
if (source->currenv->kind == SRECORD && !decl) {
- if (isbasicdelimiter(getkind(source))) {
+ if (!isbasicdelimiter(getkind(source))) {
decl = defertypedeclaration(source, key);
decl->loc = loc;
}
@@ -2261,11 +2259,11 @@ readatom(Source *source, int flags)
}
/* unary prefix operators */
- if (getunary(source)) {
+ if (getunary(source->tok.kind)) {
lhs = tokennode(source, NULL);
/* TODO(m21c): remove redundant function-call */
- lhs->kind = getunary(source);
+ lhs->kind = getunary(source->tok.kind);
gettok(source);
lhs->lhs = readatom(source, 0);
@@ -2422,7 +2420,7 @@ readatom(Source *source, int flags)
}
/* if is atom */
- if (!isnotatom(source))
+ if (!isdelimiter(source->tok.kind))
lhs->rhs = exprlist(source, false, NULL);
break;