Expect now throws an exception

exception_except
Tristan B. Kildaire 2021-03-17 10:05:56 +02:00
parent 5330ee95f1
commit 9763a85478
2 changed files with 24 additions and 2 deletions

View File

@ -6,6 +6,12 @@ import std.string : isNumeric, cmp;
import compiler.symbols;
import compiler.lexer : Token;
import core.stdc.stdlib;
import misc.exceptions : TError;
// public final class ParserError : TError
// {
// }
public final class Parser
{
@ -39,8 +45,9 @@ public final class Parser
*/
public static void expect(string message)
{
gprintln(message, DebugType.ERROR);
exit(0); /* TODO: Exit code */ /* TODO: Version that returns or asserts for unit tests */
throw new TError(message);
//gprintln(message, DebugType.ERROR);
//exit(0); /* TODO: Exit code */ /* TODO: Version that returns or asserts for unit tests */
}
/**

View File

@ -0,0 +1,15 @@
module misc.exceptions;
import gogga : generateMessage;
public class TError : Exception
{
this(string message)
{
/* Generate eerror message using gogga */
byte[] messageBytes = generateMessage(message, DebugType.ERROR);
/* TODO: Check the vnode for path of fd 0, dont vt100 is not tty device */
super(messageBytes);
}
}