Skip to content

Commit

Permalink
wip errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ghewgill committed Feb 13, 2024
1 parent 6835c7a commit 239dea2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,10 @@ std::unique_ptr<Expression> Parser::parseArithmetic()
default:
return left;
}
auto &t = tokens[i].type;
if (t == PLUS || t == MINUS || t == TIMES || t == DIVIDE || t == INTDIV || t == MOD || t == EXP) {
error_a(2145, left->get_start_token(), left->get_end_token(), "use more parentheses to disambiguate");
}
return left;
}

Expand Down Expand Up @@ -932,7 +936,6 @@ std::unique_ptr<Expression> Parser::parseMembership()
std::unique_ptr<Expression> Parser::parseLogical()
{
std::unique_ptr<Expression> left = parseMembership();
auto &tok_op = tokens[i];
switch (tokens[i].type) {
case AND:
while (tokens[i].type == AND) {
Expand All @@ -953,6 +956,10 @@ std::unique_ptr<Expression> Parser::parseLogical()
default:
return left;
}
auto &t = tokens[i].type;
if (t == AND || t == OR) {
error_a(2146, left->get_start_token(), left->get_end_token(), "use more parentheses to disambiguate");
}
return left;
}

Expand Down
2 changes: 2 additions & 0 deletions t/errors/N2145.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LET a := 4 * 5 + 6
--<
2 changes: 2 additions & 0 deletions t/errors/N2146.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LET a := TRUE AND TRUE OR TRUE
--<

0 comments on commit 239dea2

Please sign in to comment.