Added `parseClass()` function, `class` keyword support - for future class support
This commit is contained in:
parent
14aafe7097
commit
a493ecc2a9
|
@ -271,7 +271,12 @@ public final class Parser
|
|||
/* If the symbol is `(` then function call */
|
||||
if(getSymbolType(getCurrentToken()) == SymbolType.LBRACE)
|
||||
{
|
||||
/* TODO: Implement function call */
|
||||
/* TODO: Implement function call parsing */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: Leave the token here */
|
||||
/* TODO: Just leave it, yeah */
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -342,6 +347,36 @@ public final class Parser
|
|||
gprintln("ParseTypedDec: Je suis fini");
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a class definition
|
||||
*
|
||||
* This is called when there is an occurrence of
|
||||
* a token `class`
|
||||
*
|
||||
* STATUS: Not integrated
|
||||
* STATUS: Not tested
|
||||
*/
|
||||
private void parseClass()
|
||||
{
|
||||
/* Pop off the `class` */
|
||||
nextToken();
|
||||
|
||||
/* Get the class's name */
|
||||
expect(SymbolType.IDENTIFIER, getCurrentToken());
|
||||
string className = getCurrentToken().getToken();
|
||||
gprintln("parseClass(): Class name found '"~className~"'");
|
||||
|
||||
/* Expect a `{` */
|
||||
nextToken();
|
||||
expect(SymbolType.OCURLY, getCurrentToken());
|
||||
|
||||
/* Parse a body */
|
||||
parseBody();
|
||||
|
||||
|
||||
/* TODO: Ending here, expect closing `}`? */
|
||||
}
|
||||
|
||||
private void parseStatement()
|
||||
{
|
||||
/* TODO: Implement parse statement */
|
||||
|
|
|
@ -25,6 +25,9 @@ public enum SymbolType
|
|||
CCURLY,
|
||||
IF,
|
||||
WHILE,
|
||||
CLASS,
|
||||
INHERIT_OPP,
|
||||
TILDE,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
|
@ -107,6 +110,11 @@ public static SymbolType getSymbolType(Token tokenIn)
|
|||
{
|
||||
return SymbolType.WHILE;
|
||||
}
|
||||
/* class keyword */
|
||||
else if(cmp(token, "class") == 0)
|
||||
{
|
||||
return SymbolType.CLASS;
|
||||
}
|
||||
/* Identifier check (TODO: Track vars) */
|
||||
else if (isAlpha(token))
|
||||
{
|
||||
|
@ -147,6 +155,19 @@ public static SymbolType getSymbolType(Token tokenIn)
|
|||
{
|
||||
return SymbolType.COMMA;
|
||||
}
|
||||
/* Inheritance operator check */
|
||||
else if (token[0] == ':')
|
||||
{
|
||||
return SymbolType.INHERIT_OPP;
|
||||
}
|
||||
/* Tilde operator check */
|
||||
else if (token[0] == '~')
|
||||
{
|
||||
return SymbolType.TILDE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return SymbolType.UNKNOWN;
|
||||
|
|
Loading…
Reference in New Issue