Skip to content
Snippets Groups Projects
Commit a52098c0 authored by Dominic Daniel Krämer's avatar Dominic Daniel Krämer
Browse files

implemented better text output for the ParserExceptions

parent 49cea458
No related branches found
No related tags found
1 merge request!6Dominicsbranch
......@@ -84,7 +84,7 @@ public class Parser {
//parses a list of tokens into a value
private Optional<Expression> parseValue(List<Lexer.Token> ts) throws ParserException {
if (ts.isEmpty()) {
throw new ParserException("SyntaxError: expected a number");
throw new ParserException("RuntimeException: empty token list");
}
if (ts.get(0).getType() != Lexer.TokenType.NUMBER) {
return Optional.empty();
......@@ -114,13 +114,13 @@ public class Parser {
//parses a decimal of a list of tokens & a string
private Expression parseDecimal(List<Lexer.Token> ts, String data) throws ParserException {
if(ts.size()<1) {
throw new ParserException("SyntaxError: ");
throw new ParserException("RuntimeException: empty token list");
}
if(ts.get(0).getType() != Lexer.TokenType.SPECIAL) {
throw new ParserException("");
throw new ParserException("SyntaxException: expected a comma");
}
if(ts.get(1).getType() != Lexer.TokenType.NUMBER) {
throw new ParserException("");
throw new ParserException("SyntaxException: expected a number after a comma");
}
Number beforeDot = (Number) parseNumber(data);
ts.remove(0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment