Skip to content

Commit

Permalink
Parser
Browse files Browse the repository at this point in the history
- Added `getWorkingDirectory()`
- `parse()` is now `parse(string)` with a default argument
  • Loading branch information
deavmi committed Aug 27, 2023
1 parent c94c3f1 commit ab4ddc7
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions source/tlang/compiler/parsing/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -2223,12 +2223,29 @@ public final class Parser
/* Expect a semi-colon and consume it */
expect(SymbolType.SEMICOLON, lexer.getCurrentToken());
lexer.nextToken();

// TODO: Add support for multi-imports on one line (i.e. `import <module1>, <module2>;`)

import tlang.compiler.core : gibFileData;

// TODO: Read in here
string workDir = getWorkingDirectory();
gprintln("Current working directory is: '"~workDir~"'");




gprintln("parseImport(): Leave", DebugType.WARNING);
}

import std.path;

private static string getWorkingDirectory()
{
// TOOD: look at lazy, seems cool
string workDir = absolutePath(".");
return workDir;
}


/* Almost like parseBody but has more */
/**
Expand All @@ -2237,7 +2254,7 @@ public final class Parser
* one to define classes within functions
*/
/* TODO: Variables should be allowed to have letters in them and underscores */
public Module parse()
public Module parse(string moduleFilePath = "")
{
gprintln("parse(): Enter", DebugType.WARNING);

Expand All @@ -2258,6 +2275,9 @@ public final class Parser
/* Initialize Module */
modulle = new Module(programName);

/* Set the file system path of this module */
modulle.setFilePath(moduleFilePath);

/* TODO: do `lexer.hasTokens()` check */
/* TODO: We should add `lexer.hasTokens()` to the `lexer.nextToken()` */
/* TODO: And too the `getCurrentTokem()` and throw an error when we have ran out rather */
Expand Down

0 comments on commit ab4ddc7

Please sign in to comment.