From 6b454d0c1c49f3784e7dd55c673955cf71042a1a Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Fri, 14 Jun 2024 11:22:52 +0200 Subject: [PATCH] Update to Zig 0.13 --- .gitignore | 2 +- build.zig | 21 +++++++++++---------- build.zig.zon | 10 ++++++---- src/hyperdoc.zig | 6 +++--- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index e73c965..3389c86 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -zig-cache/ +.zig-cache/ zig-out/ diff --git a/build.zig b/build.zig index fea0353..252bd42 100644 --- a/build.zig +++ b/build.zig @@ -7,22 +7,23 @@ pub fn build(b: *std.Build) void { const parser_toolkit = b.dependency("parser_toolkit", .{}); const args = b.dependency("args", .{}); - const hyperdoc = b.addModule("hyperdoc", .{ - .source_file = .{ .path = "src/hyperdoc.zig" }, - .dependencies = &.{ - .{ .name = "parser-toolkit", .module = parser_toolkit.module("parser-toolkit") }, + const hyperdoc = b.addModule( + "hyperdoc", + .{ + .root_source_file = b.path("src/hyperdoc.zig"), }, - }); + ); + hyperdoc.addImport("parser-toolkit", parser_toolkit.module("parser-toolkit")); const exe = b.addExecutable(.{ .name = "hyperdoc", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); - exe.addModule("hyperdoc", hyperdoc); - exe.addModule("args", args.module("args")); + exe.root_module.addImport("hyperdoc", hyperdoc); + exe.root_module.addImport("args", args.module("args")); b.installArtifact(exe); @@ -36,12 +37,12 @@ pub fn build(b: *std.Build) void { run_step.dependOn(&run_cmd.step); const exe_tests = b.addTest(.{ - .root_source_file = .{ .path = "src/testsuite.zig" }, + .root_source_file = b.path("src/testsuite.zig"), .target = target, .optimize = optimize, }); - exe_tests.addModule("hyperdoc", hyperdoc); + exe_tests.root_module.addImport("hyperdoc", hyperdoc); const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&b.addRunArtifact(exe_tests).step); diff --git a/build.zig.zon b/build.zig.zon index 338deca..eec1835 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -4,12 +4,14 @@ .dependencies = .{ .parser_toolkit = .{ - .url = "https://github.com/MasterQ32/parser-toolkit/archive/7e7188bfaa46d0ba36d1ef31c1f368d264aa6876.tar.gz", - .hash = "12202ae562efbd6a4f12f1b10c5237329d19d1be15eec7fa1b0b02f5658500bfcbfd", + .url = "https://github.com/ikskuh/parser-toolkit/archive/9349d087a3216ebea27cc99b5b4bd8affe234816.tar.gz", + .hash = "12206f0ade18be8db985f6a688ca7ec9ffdbb95f033c8db91760b0d13cfe27618b61", }, .args = .{ - .url = "https://github.com/MasterQ32/zig-args/archive/bb2eced8ddf28114b3a1ff761c2d80b90b1a61e2.tar.gz", - .hash = "12208556082c280af264ca2a174fd04fc7a35f865bfe59e2c61f4a977bf7a65063e4", + .url = "https://github.com/ikskuh/zig-args/archive/872272205d95bdba33798c94e72c5387a31bc806.tar.gz", + .hash = "1220fe6ae56b668cc4a033282b5f227bfbb46a67ede6d84e9f9493fea9de339b5f37", }, }, + + .paths = .{""}, } diff --git a/src/hyperdoc.zig b/src/hyperdoc.zig index 52dde75..7579f82 100644 --- a/src/hyperdoc.zig +++ b/src/hyperdoc.zig @@ -126,10 +126,10 @@ const Parser = struct { } fn accept(parser: *Parser, token_type: TokenType) !Token { - var state = parser.save(); + const state = parser.save(); errdefer parser.restore(state); - var token = (try parser.core.nextToken()) orelse return error.EndOfFile; + const token = (try parser.core.nextToken()) orelse return error.EndOfFile; if (token.type != token_type) return error.UnexpectedToken; return token; @@ -165,7 +165,7 @@ const Parser = struct { item, }; fn acceptIdentifier(parser: *Parser) !Identifier { - var tok = try parser.accept(.identifier); + const tok = try parser.accept(.identifier); return std.meta.stringToEnum(Identifier, tok.text) orelse return error.InvalidIdentifier; }