From 81a4c0537b6bab903beed6f13c733422464dc8d4 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Tue, 16 Mar 2021 10:57:04 +0200 Subject: [PATCH] Multiple function declarations can now be parsed, previous error was due to exiting only when we were out of tokens, now we exit after consuming `}` after the call to parseBody() --- source/tlang/compiler/parser.d | 4 +++- source/tlang/testing/basic1.t | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/tlang/compiler/parser.d b/source/tlang/compiler/parser.d index dab8a75..5ea2da8 100644 --- a/source/tlang/compiler/parser.d +++ b/source/tlang/compiler/parser.d @@ -243,6 +243,8 @@ public final class Parser /* Parse the body (and it leaves ONLY when it gets the correct symbol, no expect needed) */ parseBody(); nextToken(); + + break; } else if (getSymbolType(getCurrentToken()) == SymbolType.COMMA) { @@ -256,9 +258,9 @@ public final class Parser gprintln("ParseFuncDef: ParameterDec: (Type: " ~ type ~ ", Identifier: " ~ identifier ~ ")", DebugType.WARNING); - gprintln("ParseFuncDef: Parameter count: " ~ to!(string)(parameterCount)); } + gprintln("ParseFuncDef: Parameter count: " ~ to!(string)(parameterCount)); gprintln("parseFuncDef(): Leave", DebugType.WARNING); } diff --git a/source/tlang/testing/basic1.t b/source/tlang/testing/basic1.t index ecf27d8..815af4e 100644 --- a/source/tlang/testing/basic1.t +++ b/source/tlang/testing/basic1.t @@ -73,7 +73,7 @@ void main(int hello, byte d) } } -void k(int j) +void k(int j, int k) { }