diff options
| author | 2022-08-16 05:28:18 +0200 | |
|---|---|---|
| committer | 2022-08-16 05:28:18 +0200 | |
| commit | 73f68a9c5ed4c8139cc1c4f7695da29e5a3fb4c8 (patch) | |
| tree | b2cebcf1f6b6073eeeb0595710d6fdf05fcb06fb /bootstrap/parse.c | |
| parent | b3159bfd93c8bdce71f7437abdc521b5ccb72367 (diff) | |
stuff
Diffstat (limited to 'bootstrap/parse.c')
| -rw-r--r-- | bootstrap/parse.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/bootstrap/parse.c b/bootstrap/parse.c index aeb8124..b113618 100644 --- a/bootstrap/parse.c +++ b/bootstrap/parse.c @@ -273,6 +273,7 @@ readstrlit(struct parser *P, u8 delim, char *s, size_t n) { case 't': s[i++] = '\t'; break; case 'v': s[i++] = '\v'; break; case 'f': s[i++] = '\f'; break; + case 'e': s[i++] = '\x1b'; break; case '0': s[i++] = '\0'; break; default: fatal(P, P->tokspan, "unknown escape sequence '\\%c'", c); @@ -952,11 +953,11 @@ parsestructini(struct parser *P, const struct type *ty) { } fld = structidx2fld(ty, idx++); - P->targty = fld->ty; - e = parseexpr(P); if (!fld) - fatal(P, e.span, + fatal(P, P->tokspan, "excess elements in struct initializer"); + P->targty = fld->ty; + e = parseexpr(P); if (!typematchestarg(fld->ty, e.ty)) fatal(P, e.span, "incompatible element `%s` type in %s initializer (%t, expected %t)", @@ -1157,6 +1158,7 @@ pexprimary(struct parser *P) { } } else { ex = parseexpr(P); + P->used_targty = 0; } lexexpect(P, ')'); } else if (lexmatch(P, &tok, ':')) { @@ -1404,7 +1406,7 @@ pexpostfix(struct parser *P) { if ((exptr = ty->t == TYptr)) ty = ty->child; if (ty->t == TYstruct || ty->t == TYunion) { - struct decl *decl = findaggdecl(ty, fnam); + struct decl *decl = findaggdecl(unconstify(ty), fnam); if (!decl) fatal(P, tok.span, "%t has no such method `%s'", ty, fnam); if (decl->t != Dfn) @@ -1771,7 +1773,7 @@ pexcond(struct parser *P) { return ex; } -static bool +static int matchassignop(struct parser *P, struct tok *tokp) { struct tok tok = lexpeek(P); if (tokp) @@ -1780,10 +1782,10 @@ matchassignop(struct parser *P, struct tok *tokp) { case '=': lex(P); return 1; - case '+=': case '-=': case '*=': case '/=': case '%=': + case '+=': case '-=': case '*=': case '/=': lex(P); return 2; - case '&=': case '|=': case '^=': case '<<=': case '>>=': + case '%=': case '&=': case '|=': case '^=': case '<<=': case '>>=': lex(P); return 3; } |