From 26963df1b3798f9eb13625561e3f1f9dbcce37c6 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sat, 11 Jan 2020 11:39:28 -0500 Subject: improved error message for too many (s --- parse.c | 8 ++++++++ test.toc | 9 --------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/parse.c b/parse.c index cfc66c9..dcc5531 100644 --- a/parse.c +++ b/parse.c @@ -1286,16 +1286,24 @@ static bool parse_expr(Parser *p, Expression *e, Token *end) { if (paren_level > 0) { t->token = start; + while (!token_is_kw(t->token, KW_LPAREN)) + ++t->token; + tokr_err(t, "Too many opening parentheses (."); return false; } if (brace_level > 0) { t->token = start; + while (!token_is_kw(t->token, KW_LBRACE)) + ++t->token; + tokr_err(t, "Too many opening braces {."); return false; } if (square_level > 0) { t->token = start; + while (!token_is_kw(t->token, KW_LSQUARE)) + ++t->token; tokr_err(t, "Too many opening square brackets [."); return false; } diff --git a/test.toc b/test.toc index 165b41f..10d2385 100644 --- a/test.toc +++ b/test.toc @@ -12,17 +12,8 @@ putf ::= fn(x: float) { // point ::= pkg "point"; -main ::= fn() { - s ::= struct { x,y,z:int; f:f32; }; - puti(#alignof(s)); - puti(#sizeof(s)); - -}; -/* -something's wrong (should be too few opening parentheses!) main ::= fn() { puti(#alignof(struct { x,y,z:int; f:f64; }); puti(#sizeof(struct { x,y,z:int; f:f64; }); }; -*/ \ No newline at end of file -- cgit v1.2.3