Added requirement for having a module header at the beginning of each source file
Updated test cases accordinglydevelop_before_lexer_parser_merge_parseName
parent
85ab9bde02
commit
8bde36d586
|
@ -672,6 +672,18 @@ public final class Parser
|
||||||
|
|
||||||
/* TODO: Do parsing here */
|
/* 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 */
|
/* We can have an import or vardef or funcdef */
|
||||||
while (hasTokens())
|
while (hasTokens())
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,7 @@ public enum SymbolType
|
||||||
COMMA,
|
COMMA,
|
||||||
OCURLY,
|
OCURLY,
|
||||||
CCURLY,
|
CCURLY,
|
||||||
|
MODULE,
|
||||||
IF,
|
IF,
|
||||||
ELSE,
|
ELSE,
|
||||||
WHILE,
|
WHILE,
|
||||||
|
@ -229,6 +230,11 @@ public static SymbolType getSymbolType(Token tokenIn)
|
||||||
{
|
{
|
||||||
return SymbolType.DELETE;
|
return SymbolType.DELETE;
|
||||||
}
|
}
|
||||||
|
/* module keyword */
|
||||||
|
else if(cmp(token, "module") == 0)
|
||||||
|
{
|
||||||
|
return SymbolType.MODULE;
|
||||||
|
}
|
||||||
/* Identifier check (TODO: Track vars) */
|
/* Identifier check (TODO: Track vars) */
|
||||||
else if (isIdentifier(token))
|
else if (isIdentifier(token))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
module bababoioey;
|
||||||
|
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
ubyte y;
|
ubyte y;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
module bababoioey;
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
ubyte y;
|
ubyte y;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
module bababoioey;
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
ubyte y;
|
ubyte y;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
module bababoioey;
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
ubyte y;
|
ubyte y;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
module bababoioey;
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
ubyte y;
|
ubyte y;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
module bababoioey;
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
ubyte y;
|
ubyte y;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue