diff --git a/source/tlang/compiler/parser.d b/source/tlang/compiler/parser.d index 6e2d251..8765a90 100644 --- a/source/tlang/compiler/parser.d +++ b/source/tlang/compiler/parser.d @@ -672,6 +672,18 @@ public final class Parser /* TODO: Do parsing here */ + /* Expect `module` and module name and consume them (and `;`) */ + expect(SymbolType.MODULE, getCurrentToken()); + nextToken(); + expect(SymbolType.IDENTIFIER, getCurrentToken()); + nextToken(); + expect(SymbolType.SEMICOLON, getCurrentToken()); + nextToken(); + + /* TODO: do `hasTokens()` check */ + /* TODO: We should add `hasTokens()` to the `nextToken()` */ + /* TODO: And too the `getCurrentTokem()` and throw an error when we have ran out rather */ + /* We can have an import or vardef or funcdef */ while (hasTokens()) { diff --git a/source/tlang/compiler/symbols.d b/source/tlang/compiler/symbols.d index 5264dbe..56e12a4 100644 --- a/source/tlang/compiler/symbols.d +++ b/source/tlang/compiler/symbols.d @@ -23,6 +23,7 @@ public enum SymbolType COMMA, OCURLY, CCURLY, + MODULE, IF, ELSE, WHILE, @@ -229,6 +230,11 @@ public static SymbolType getSymbolType(Token tokenIn) { return SymbolType.DELETE; } + /* module keyword */ + else if(cmp(token, "module") == 0) + { + return SymbolType.MODULE; + } /* Identifier check (TODO: Track vars) */ else if (isIdentifier(token)) { diff --git a/source/tlang/testing/basic1.t b/source/tlang/testing/basic1.t index b1d877f..ffaacea 100644 --- a/source/tlang/testing/basic1.t +++ b/source/tlang/testing/basic1.t @@ -1,3 +1,6 @@ +module bababoioey; + + int x; ubyte y; diff --git a/source/tlang/testing/basic1_invalid.t b/source/tlang/testing/basic1_invalid.t index d0a55e9..3d3e6f9 100644 --- a/source/tlang/testing/basic1_invalid.t +++ b/source/tlang/testing/basic1_invalid.t @@ -1,3 +1,5 @@ +module bababoioey; + int x; ubyte y; diff --git a/source/tlang/testing/basic1_invalid_2.t b/source/tlang/testing/basic1_invalid_2.t index 95a47d7..3d975af 100644 --- a/source/tlang/testing/basic1_invalid_2.t +++ b/source/tlang/testing/basic1_invalid_2.t @@ -1,3 +1,5 @@ +module bababoioey; + int x; ubyte y; diff --git a/source/tlang/testing/basic2_mega_fucked.t b/source/tlang/testing/basic2_mega_fucked.t index bed7fb8..1b3ca22 100644 --- a/source/tlang/testing/basic2_mega_fucked.t +++ b/source/tlang/testing/basic2_mega_fucked.t @@ -1,3 +1,5 @@ +module bababoioey; + int x; ubyte y; diff --git a/source/tlang/testing/else_if_without_if.pl b/source/tlang/testing/else_if_without_if.pl index 6112cef..6f7db79 100644 --- a/source/tlang/testing/else_if_without_if.pl +++ b/source/tlang/testing/else_if_without_if.pl @@ -1,3 +1,5 @@ +module bababoioey; + int x; ubyte y; diff --git a/source/tlang/testing/else_without_if.pl b/source/tlang/testing/else_without_if.pl index 0670ffb..1cfec37 100644 --- a/source/tlang/testing/else_without_if.pl +++ b/source/tlang/testing/else_without_if.pl @@ -1,3 +1,5 @@ +module bababoioey; + int x; ubyte y;