Function calls implemented

This commit is contained in:
Tristan B. Velloza Kildaire 2021-03-03 18:34:38 +02:00
parent da79f7f1d5
commit 0abfbf0b9e
1 changed files with 28 additions and 0 deletions

View File

@ -106,6 +106,12 @@ public final class Parser
nextToken();
parseIf();
}
/* If it is a function call */
else if(symbol == SymbolType.IDENTIFIER)
{
parseFuncCall();
}
/* If it is closing the body `}` */
else if(symbol == SymbolType.CCURLY)
{
// gprintln("Error");
@ -262,6 +268,28 @@ public final class Parser
gprintln("ParseTypedDec: Je suis fini");
}
private void parseFuncCall()
{
gprintln("parseFuncCall(): Doing function call parsing");
nextToken();
/* Expect an opening brace `(` */
expect(SymbolType.LBRACE, getCurrentToken());
nextToken();
/* Parse an expression AND end on closing brace (expect) */
parseExpression();
expect(SymbolType.RBRACE, getCurrentToken());
nextToken();
/* Expect a semi-colon */
expect(SymbolType.SEMICOLON, getCurrentToken());
nextToken();
}
/* Almost like parseBody but has more */
public void parse()
{