diff options
author | Maël Gassmann <mael.gassmann@students.bfh.ch> | 2021-06-11 20:55:12 +0200 |
---|---|---|
committer | Maël Gassmann <mael.gassmann@students.bfh.ch> | 2021-06-11 20:55:12 +0200 |
commit | fed70f3ac817ed4943a230cb901fcd65dc6fdd0c (patch) | |
tree | aea4de81656c677d33e4af6eb11375303d1dfdda /calculator-java/src/main/java/ch/bfh/parser/TermParser.java | |
parent | 3baa44f1c8459713a96f4db994ee9905cc4e8df1 (diff) |
[~] First totaly functional Calculator, reorganised the files, verified and added error messages
Diffstat (limited to 'calculator-java/src/main/java/ch/bfh/parser/TermParser.java')
-rw-r--r-- | calculator-java/src/main/java/ch/bfh/parser/TermParser.java | 13 |
1 files changed, 7 insertions, 6 deletions
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(); } |