aboutsummaryrefslogtreecommitdiff
path: root/calculator-java/src/main/java/ch/bfh/parser/StatementParser.java
diff options
context:
space:
mode:
authorMaël Gassmann <mael.gassmann@students.bfh.ch>2021-06-11 20:55:12 +0200
committerMaël Gassmann <mael.gassmann@students.bfh.ch>2021-06-11 20:55:12 +0200
commitfed70f3ac817ed4943a230cb901fcd65dc6fdd0c (patch)
treeaea4de81656c677d33e4af6eb11375303d1dfdda /calculator-java/src/main/java/ch/bfh/parser/StatementParser.java
parent3baa44f1c8459713a96f4db994ee9905cc4e8df1 (diff)
[~] First totaly functional Calculator, reorganised the files, verified and added error messages
Diffstat (limited to 'calculator-java/src/main/java/ch/bfh/parser/StatementParser.java')
-rw-r--r--calculator-java/src/main/java/ch/bfh/parser/StatementParser.java13
1 files changed, 6 insertions, 7 deletions
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