From fed70f3ac817ed4943a230cb901fcd65dc6fdd0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gassmann?= Date: Fri, 11 Jun 2021 20:55:12 +0200 Subject: [~] First totaly functional Calculator, reorganised the files, verified and added error messages --- .../src/main/java/ch/bfh/parser/StatementParser.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'calculator-java/src/main/java/ch/bfh/parser/StatementParser.java') diff --git a/calculator-java/src/main/java/ch/bfh/parser/StatementParser.java b/calculator-java/src/main/java/ch/bfh/parser/StatementParser.java index c85398b..482ef34 100644 --- a/calculator-java/src/main/java/ch/bfh/parser/StatementParser.java +++ b/calculator-java/src/main/java/ch/bfh/parser/StatementParser.java @@ -1,8 +1,7 @@ package ch.bfh.parser; -import ch.bfh.CalculatorLexer; -import ch.bfh.Token; -import ch.bfh.exceptions.ParserException; +import ch.bfh.lexer.CalculatorLexer; +import ch.bfh.lexer.Token; public class StatementParser extends Parser{ @@ -27,15 +26,15 @@ public class StatementParser extends Parser{ switch (token.type) { case Token.LET: if (lastToken != null) - throw new ParserException("The keyword 'let' cannot be placed anywhere else than at the beginning of an expression."); + throw new ParserException("The keyword 'let' can only be placed at the beginning of an expression."); break; case Token.EQU: if (lastToken == null || lastToken.type != Token.LET || variableName == null) - throw new ParserException("The inputted token '=' can only be placed in a variable declaration context (let variable = Expression)."); + throw new ParserException("The token '=' can only be placed in a variable declaration context (let var = Expression)."); break; case Token.END: if (lastToken != null) - throw new ParserException("The keyword 'exit' cannot be placed anywhere else than at the beginning of an expression."); + throw new ParserException("The keyword 'exit' can only be placed at the beginning of an expression."); else System.exit(0); case Token.ID: @@ -58,7 +57,7 @@ public class StatementParser extends Parser{ if (lastToken == null) return; if (lastToken.type == Token.LET || lastToken.type == Token.EQU) - throw new ParserException("Incomplete variable declaration"); + throw new ParserException("Incomplete variable declaration. Expected: let var = Expression."); } @Override -- cgit v1.2.3