commit 894c642b4d9c59a602305306f9ac8800d4108871 parent 1b34a0bc4690256fa3a4f42244856bc6c81c2461 Author: Szymon Mikulicz <szymon.mikulicz@posteo.net> Date: Fri, 21 Oct 2022 23:40:48 +0200 Add zlox template Diffstat:
30 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/dlox/.gitignore diff --git a/bacon.lox b/dlox/bacon.lox diff --git a/boston.lox b/dlox/boston.lox diff --git a/count.lox b/dlox/count.lox diff --git a/dub.json b/dlox/dub.json diff --git a/dub.selections.json b/dlox/dub.selections.json diff --git a/fib.lox b/dlox/fib.lox diff --git a/gaze.lox b/dlox/gaze.lox diff --git a/scopebug.lox b/dlox/scopebug.lox diff --git a/source/app.d b/dlox/source/app.d diff --git a/source/ast.d b/dlox/source/ast.d diff --git a/source/astgen.d b/dlox/source/astgen.d diff --git a/source/astprinter.d b/dlox/source/astprinter.d diff --git a/source/callable.d b/dlox/source/callable.d diff --git a/source/cls.d b/dlox/source/cls.d diff --git a/source/environment.d b/dlox/source/environment.d diff --git a/source/error.d b/dlox/source/error.d diff --git a/source/fun.d b/dlox/source/fun.d diff --git a/source/instance.d b/dlox/source/instance.d diff --git a/source/interpreter.d b/dlox/source/interpreter.d diff --git a/source/keywords.d b/dlox/source/keywords.d diff --git a/source/parser.d b/dlox/source/parser.d diff --git a/source/resolver.d b/dlox/source/resolver.d diff --git a/source/scanner.d b/dlox/source/scanner.d diff --git a/source/token.d b/dlox/source/token.d diff --git a/source/tokentype.d b/dlox/source/tokentype.d diff --git a/thrice.lox b/dlox/thrice.lox diff --git a/zlox/.gitignore b/zlox/.gitignore @@ -0,0 +1,2 @@ +zig-cache/ +zig-out/ diff --git a/zlox/build.zig b/zlox/build.zig @@ -0,0 +1,34 @@ +const std = @import("std"); + +pub fn build(b: *std.build.Builder) void { + // Standard target options allows the person running `zig build` to choose + // what target to build for. Here we do not override the defaults, which + // means any target is allowed, and the default is native. Other options + // for restricting supported target set are available. + const target = b.standardTargetOptions(.{}); + + // Standard release options allow the person running `zig build` to select + // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. + const mode = b.standardReleaseOptions(); + + const exe = b.addExecutable("zlox", "src/main.zig"); + exe.setTarget(target); + exe.setBuildMode(mode); + exe.install(); + + const run_cmd = exe.run(); + run_cmd.step.dependOn(b.getInstallStep()); + if (b.args) |args| { + run_cmd.addArgs(args); + } + + const run_step = b.step("run", "Run the app"); + run_step.dependOn(&run_cmd.step); + + const exe_tests = b.addTest("src/main.zig"); + exe_tests.setTarget(target); + exe_tests.setBuildMode(mode); + + const test_step = b.step("test", "Run unit tests"); + test_step.dependOn(&exe_tests.step); +} diff --git a/zlox/src/main.zig b/zlox/src/main.zig @@ -0,0 +1,9 @@ +const std = @import("std"); + +pub fn main() anyerror!void { + std.log.info("All your codebase are belong to us.", .{}); +} + +test "basic test" { + try std.testing.expectEqual(10, 3 + 7); +}