From 5fd1bef2a40954fc9fe3c298116497da946c47e1 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Sun, 22 Jan 2023 14:45:25 +0200 Subject: [PATCH] Lexer - Added new exception type `LexerException` - Added `LexerError` enum to support various error types of the `LexerException` exception type --- source/tlang/compiler/lexer.d | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/tlang/compiler/lexer.d b/source/tlang/compiler/lexer.d index e3e4a653..95f09875 100644 --- a/source/tlang/compiler/lexer.d +++ b/source/tlang/compiler/lexer.d @@ -5,6 +5,26 @@ import gogga; import std.conv : to; import std.string : cmp; import std.ascii : isDigit; +import misc.exceptions : TError; + +public enum LexerError +{ + EXHAUSTED_CHARACTERS, + OTHER +} + +public final class LexerException : TError +{ + public const Lexer offendingInstance; + public const LexerError errType; + + this(Lexer offendingInstance, LexerError errType = LexerError.OTHER, string msg = "") + { + super(to!(string)(errType)~(msg.length ? ": "~msg : "")); + this.offendingInstance = offendingInstance; + this.errType = errType; + } +} /* TODO: Add Token type (which matches column and position too) */ public final class Token