better exception for parsing
This commit is contained in:
@ -71,11 +71,11 @@ public class LL1Parser {
|
||||
} else if (this.parsetable.getTerminals().contains(top)) {
|
||||
// Wenn das Terminal auf dem Stack nicht mit der aktuellen Eingabe übereinstimmt
|
||||
|
||||
throw new MyParseException("Invalid terminal on stack: " + top);
|
||||
throw new MyParseException("Invalid terminal on stack: " + top, tree);
|
||||
} else if (prod == null) {
|
||||
// Wenn es für das aktuelle Terminal und das Nichtterminal auf dem Stack keine Regel gibt
|
||||
|
||||
throw new MyParseException("No prod. for nonterminal " + top + ", terminal " + currentToken);
|
||||
throw new MyParseException("No prod. for nonterminal " + top + ", terminal " + currentToken, tree);
|
||||
} else {
|
||||
// Wenn das Nichtterminal auf dem Stack durch (s)eine Produktion ersetzt werden kann
|
||||
// Hier wird auch der AST aufgebaut
|
||||
|
@ -1,8 +1,18 @@
|
||||
package parser;
|
||||
|
||||
import util.ast.AST;
|
||||
|
||||
import static util.tools.Logger.log;
|
||||
|
||||
public class MyParseException extends RuntimeException {
|
||||
|
||||
public MyParseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public MyParseException(String message, AST ast) {
|
||||
super(message);
|
||||
|
||||
log("\nAST at last state:\n" + ast);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user