Added new `expect(string)` method for custom messages for panic

Also made `expect(SymbolType, Token)` use said new method
expression_parsing.sync-conflict-20210316-090018-O3W7KWN
Tristan B. V. Kildaire 2021-03-05 12:01:57 +02:00
parent 88a5c0e482
commit 4ed0b385cf
1 changed files with 8 additions and 5 deletions

View File

@ -25,14 +25,17 @@ public final class Parser
/* TODO: Crash program if not */
if (!isFine)
{
gprintln("Expected symbol of type " ~ to!(string)(symbol) ~ " but got " ~ to!(
string)(actualType) ~ " with " ~ token.toString(), DebugType.ERROR);
import core.stdc.stdlib;
exit(0);
expect("Expected symbol of type " ~ to!(string)(symbol) ~ " but got " ~ to!(
string)(actualType) ~ " with " ~ token.toString());
}
}
public static void expect(string message)
{
gprintln(message, DebugType.ERROR);
exit(0);
}
this(Token[] tokens)
{
this.tokens = tokens;