restructure

This commit is contained in:
nazrin 2025-05-29 15:33:12 +00:00
parent b466717c6e
commit 2de4381fae
6 changed files with 26 additions and 10 deletions

View file

@ -5,3 +5,10 @@ copyright "Copyright © 2025, tanya"
license "MPL-2.0"
dependency "commandr" version="~>1.1.0"
dependency "taggedalgebraic" version="~>0.11.23"
targetType "executable"
buildRequirements "requireBoundsCheck" "requireContracts"
configuration "jlox" {
sourcePaths "src/jlox"
}

View file

@ -1,11 +1,13 @@
module jlox.expr;
import std.conv;
import std.stdio;
import std.meta : AliasSeq;
import taggedalgebraic;
import token;
import tokentype;
import jlox.token;
import jlox.tokentype;
abstract class Expr{
interface Visitor(R){

View file

@ -1,3 +1,5 @@
module jlox.main;
import std.stdio;
import std.file;
import std.conv;
@ -5,9 +7,9 @@ import std.exception;
import commandr;
import token;
import tokentype;
import scanner;
import jlox.token;
import jlox.tokentype;
import jlox.scanner;
static bool hadError = false;
@ -45,7 +47,7 @@ void runPrompt(){
writeln();
}
int main(string[] argv){
version(unittest) {} else int main(string[] argv){
auto args = new Program("lox")
.add(new Argument("path").optional.acceptsFiles)
.parse(argv);

View file

@ -1,9 +1,11 @@
module jlox.scanner;
import std.ascii;
import std.conv;
import token;
import tokentype;
import main : error, report;
import jlox.token;
import jlox.tokentype;
import jlox.main : error, report;
private bool isAlpha_(dchar c) => c.isAlpha || c == '_';
private bool isAlphaNum_(dchar c) => c.isAlphaNum || c == '_';

View file

@ -1,8 +1,10 @@
module jlox.token;
import std.conv;
import taggedalgebraic;
import tokentype;
import jlox.tokentype;
struct TokenValue{
string str;

View file

@ -1,3 +1,4 @@
module jlox.tokentype;
enum TokenType {
// Single-character tokens.