From 35132be9d6e20841a4cfc85ee73b4f4bde2b524b Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Sat, 20 Mar 2021 18:41:26 +0200 Subject: [PATCH] If statement parsing completed Also on unknown symbol in `parseBody` remember to error out and exit --- source/tlang/compiler/parser.d | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/source/tlang/compiler/parser.d b/source/tlang/compiler/parser.d index 71be27f1..a83e6de6 100644 --- a/source/tlang/compiler/parser.d +++ b/source/tlang/compiler/parser.d @@ -169,23 +169,9 @@ public final class Parser } } - /* Error out if an else was simply placed */ - else if(getSymbolType(getCurrentToken()) == SymbolType.ELSE && !hasIf) - { - expect("Else placed without previous if"); - } - // /* If we get another `if` but already had one then exit, it's a new one to process */ - // else if (getSymbolType(getCurrentToken()) == SymbolType.IF && hasIf) - // { - // /* Leave this parseIf, it will be called again by caller (`parseBody()`) */ - // break; - // } - /* If we get an unknown, not an `if` or `else` */ + /* If we get anything else, then we are done with if statement */ else { - /* TODO: Add error */ - import std.stdio; - writeln("Bruh"~to!(string)(getCurrentToken())); break; } } @@ -282,8 +268,8 @@ public final class Parser /* Error out */ else { - gprintln("parseBody(): Unknown symbol: " ~ getCurrentToken() - .getToken(), DebugType.ERROR); + expect("parseBody(): Unknown symbol: " ~ getCurrentToken() + .getToken()); } }