diff --git a/source/tlang/compiler/parser.d b/source/tlang/compiler/parser.d index d4c7ac8..c1a6af2 100644 --- a/source/tlang/compiler/parser.d +++ b/source/tlang/compiler/parser.d @@ -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 */ diff --git a/source/tlang/compiler/symbols.d b/source/tlang/compiler/symbols.d index 950e319..fe9afcf 100644 --- a/source/tlang/compiler/symbols.d +++ b/source/tlang/compiler/symbols.d @@ -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;