- `parseTypedDeclaration()`  will no longer consume the SEMICOLON after a vardec
- `parseTypedDeclaration()` will no longer consume theSEMICOLON after an assignment
- `parseName()` will expect a semicolon if the returned object from `parseTypedDeclaration()` is of type `Variable`. If of type `Function` then nothing will be expected
This commit is contained in:
Tristan B. Velloza Kildaire 2023-01-19 08:45:06 +02:00
parent d3e15e7a2f
commit 75e2fc2e68
1 changed files with 19 additions and 12 deletions

View File

@ -450,6 +450,24 @@ public final class Parser
{
previousToken();
ret = parseTypedDeclaration();
/* If it is a function definition, then do nothing */
if(cast(Function)ret)
{
// The ending `}` would have already been consumed
}
/* If it is a variable declaration then */
else if(cast(Variable)ret)
{
/* Expect a semicolon and consume it */
expect(SymbolType.SEMICOLON, getCurrentToken());
nextToken();
}
/* This should never happen */
else
{
assert(false);
}
}
/* Assignment */
else if(type == SymbolType.ASSIGN)
@ -462,7 +480,6 @@ public final class Parser
{
gprintln(getCurrentToken);
expect("Error expected ( for var/func def");
}
@ -1352,7 +1369,6 @@ public final class Parser
/* Check for semi-colon (var dec) */
else if (symbolType == SymbolType.SEMICOLON)
{
nextToken();
gprintln("ParseTypedDec: VariableDeclaration: (Type: " ~ type ~ ", Identifier: " ~ identifier ~ ")",
DebugType.WARNING);
@ -1361,6 +1377,7 @@ public final class Parser
/* Check for `=` (var dec) */
else if (symbolType == SymbolType.ASSIGN)
{
/* Consume the `=` token */
nextToken();
/* Now parse an expression */
@ -1368,14 +1385,6 @@ public final class Parser
VariableAssignment varAssign = new VariableAssignment(expression);
/**
* The symbol that returned us from `parseExpression` must
* be a semi-colon
*/
expect(SymbolType.SEMICOLON, getCurrentToken());
nextToken();
gprintln("ParseTypedDec: VariableDeclarationWithAssingment: (Type: "
~ type ~ ", Identifier: " ~ identifier ~ ")", DebugType.WARNING);
@ -1391,8 +1400,6 @@ public final class Parser
expect("Expected one of the following: (, ; or =");
}
/* TODO: If we outta tokens we should not call this */
// gprintln(getCurrentToken());
gprintln("parseTypedDeclaration(): Leave", DebugType.WARNING);
return generated;