From 94f15af031cfbe7dad1b14e81e88f11a5a7a9e33 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Fri, 5 Mar 2021 11:40:06 +0200 Subject: [PATCH] Made token movement for `parseIf` and `parseWhile` self-contained --- source/tlang/compiler/parser.d | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/tlang/compiler/parser.d b/source/tlang/compiler/parser.d index ad1df02..b6c921f 100644 --- a/source/tlang/compiler/parser.d +++ b/source/tlang/compiler/parser.d @@ -63,6 +63,9 @@ public final class Parser private void parseIf() { + /* Pop off the `if` */ + nextToken(); + /* Expect an opening brace `(` */ expect(SymbolType.LBRACE, getCurrentToken()); nextToken(); @@ -85,6 +88,9 @@ public final class Parser private void parseWhile() { + /* Pop off the `while` */ + nextToken(); + /* Expect an opening brace `(` */ expect(SymbolType.LBRACE, getCurrentToken()); nextToken(); @@ -141,13 +147,11 @@ public final class Parser /* If it is a branch */ else if(symbol == SymbolType.IF) { - nextToken(); parseIf(); } /* If it is a while loop */ else if(symbol == SymbolType.WHILE) { - nextToken(); parseWhile(); } /* If it is a function call */