diff --git a/source/tlang/compiler/modman/modman.d b/source/tlang/compiler/modman/modman.d index 96c82eee..fae22538 100644 --- a/source/tlang/compiler/modman/modman.d +++ b/source/tlang/compiler/modman/modman.d @@ -467,7 +467,7 @@ public final class ModuleManager if(actualType != expected) { // TODO: Make SyntaxError have a parser-less version for null-safety in the future - throw new SyntaxError(null, expected, got); + throw new SyntaxError(expected, got); } } diff --git a/source/tlang/compiler/parsing/core.d b/source/tlang/compiler/parsing/core.d index 943147d7..207861ab 100644 --- a/source/tlang/compiler/parsing/core.d +++ b/source/tlang/compiler/parsing/core.d @@ -1,3 +1,8 @@ +/** + * Core parser implementation + * + * Authors: Tristan Brice Velloza Kildaire (deavmi) + */ module tlang.compiler.parsing.core; import tlang.misc.logging; @@ -17,7 +22,9 @@ import tlang.compiler.symbols.typing.enums; import tlang.compiler.symbols.comments; import tlang.compiler.symbols.strings : StringExpression; -// TODO: Technically we could make a core parser etc +/** + * The parser + */ public final class Parser { /** @@ -51,7 +58,7 @@ public final class Parser /* TODO: Crash program if not */ if (!isFine) { - throw new SyntaxError(this, symbol, token); + throw new SyntaxError(symbol, token); // expect("Expected symbol of type " ~ to!(string)(symbol) ~ " but got " ~ to!( // string)(actualType) ~ " with " ~ token.toString()); } @@ -68,7 +75,7 @@ public final class Parser { ERROR(message); - throw new ParserException(this, ParserException.ParserErrorType.GENERAL_ERROR, message); + throw new ParserException(message); } /** @@ -1213,7 +1220,7 @@ public final class Parser } catch(ConvException e) { - throw new ParserException(this, ParserException.ParserErrorType.LITERAL_OVERFLOW, "Literal '"~numberLiteralStr~"' would overflow"); + throw new ParserException("Literal '"~numberLiteralStr~"' would overflow"); } } diff --git a/source/tlang/compiler/parsing/exceptions.d b/source/tlang/compiler/parsing/exceptions.d index 7003e0d9..57425d28 100644 --- a/source/tlang/compiler/parsing/exceptions.d +++ b/source/tlang/compiler/parsing/exceptions.d @@ -9,18 +9,9 @@ import std.conv : to; public class ParserException : TError { - private Parser parser; - - public enum ParserErrorType + this(string message) { - GENERAL_ERROR, - LITERAL_OVERFLOW - } - - this(Parser parser, ParserErrorType errType = ParserErrorType.GENERAL_ERROR, string message = "") - { - super("ParserException("~to!(string)(errType)~"): "~message); - this.parser = parser; + super("ParserException: "~message); } } @@ -30,14 +21,12 @@ public final class SyntaxError : ParserException private SymbolType provided; private Token providedToken; - this(Parser parser, SymbolType expected, Token providedToken) + this(SymbolType expected, Token providedToken) { this.expected = expected; this.provided = getSymbolType(providedToken); this.providedToken = providedToken; - super(parser); - - msg = "Syntax error: Expected "~to!(string)(expected)~" but got "~to!(string)(provided)~", see "~providedToken.toString(); + super("Syntax error: Expected "~to!(string)(expected)~" but got "~to!(string)(provided)~", see "~providedToken.toString()); } } \ No newline at end of file