From 0a7958a014eb746390c1e602b0e67c1a43f94a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gassmann?= Date: Sat, 12 Jun 2021 18:49:07 +0200 Subject: [~] Added empty expression error messages --- calculator-java/src/main/java/ch/bfh/parser/ExpressionParser.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'calculator-java/src/main/java/ch/bfh/parser/ExpressionParser.java') diff --git a/calculator-java/src/main/java/ch/bfh/parser/ExpressionParser.java b/calculator-java/src/main/java/ch/bfh/parser/ExpressionParser.java index e68983b..91effbd 100644 --- a/calculator-java/src/main/java/ch/bfh/parser/ExpressionParser.java +++ b/calculator-java/src/main/java/ch/bfh/parser/ExpressionParser.java @@ -71,6 +71,8 @@ class ExpressionParser extends Parser { continue loop; case Token.PAR: if (lastToken != null && lastToken.type == Token.PAL) { // if equal to '(' it means it was created by a Factor + if(parsers.size() == 0) + throw new ParserException("Empty parenthesis were found."); lastToken = token; break loop; } else -- cgit v1.2.3