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 --- calculator-java/src/main/java/ch/bfh/parser/TermParser.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'calculator-java/src/main/java/ch/bfh/parser/TermParser.java') diff --git a/calculator-java/src/main/java/ch/bfh/parser/TermParser.java b/calculator-java/src/main/java/ch/bfh/parser/TermParser.java index 9a97659..9e49fa8 100644 --- a/calculator-java/src/main/java/ch/bfh/parser/TermParser.java +++ b/calculator-java/src/main/java/ch/bfh/parser/TermParser.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; class TermParser extends ExpressionParser { @@ -61,9 +60,11 @@ class TermParser extends ExpressionParser { case Token.PAR: // Going as high as possible --> possibly the end of an expression created by a Factor :) lastToken = token; break loop; - default: - //TODO - Replace default by each individual case - throw new ParserException("Malformed Expression."); + case Token.EQU: + case Token.LET: + throw new ParserException("The inputted token '"+token.str+"' can only be placed in a variable declaration context (let var = Expression)."); + case Token.END: + throw new ParserException("The keyword 'exit' can only be placed at the beginning of an expression."); } token = cl.nextToken(); } -- cgit v1.2.3