From 12eeefcdba1ee392f033f51e6b9826eaae3c4de6 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 13 Jun 2016 23:16:54 +0300 Subject: Add tokenizer, parser and support for certain operations --- main/exception/InterpreterException.java | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 main/exception/InterpreterException.java (limited to 'main/exception/InterpreterException.java') diff --git a/main/exception/InterpreterException.java b/main/exception/InterpreterException.java new file mode 100644 index 0000000..8129012 --- /dev/null +++ b/main/exception/InterpreterException.java @@ -0,0 +1,33 @@ +package com.jantuomi.interpreter.main.exception; + + +import java.util.HashMap; +import java.util.Map; + +/** + * Created by jan on 12.6.2016. + */ +public class InterpreterException { + + public enum Exception { + IllegalTokenException, + UnknownOperatorException + } + + public static Map errorTexts = new HashMap<>(); + + static { + errorTexts.put(Exception.IllegalTokenException, "Illegal token %s found."); + errorTexts.put(Exception.UnknownOperatorException, "Unknown operator %s found."); + } + + private Exception exception; + + public InterpreterException(Exception e) { + exception = e; + } + + public String what() { + return errorTexts.get(exception); + } +} -- cgit v1.3