diff --git a/build.zig b/build.zig index 334c4f78bcdd0ffe8c5d2957ff7486812053d2eb..5161975a0ae6f78d1396e4080eade26a0fe50771 100644 --- a/build.zig +++ b/build.zig @@ -273,7 +273,7 @@ pub fn build(b: *Build) !void { std.math.maxInt(usize), ); const first_header = std.mem.indexOf(u8, text, "## ") orelse @panic("Invalid changelog"); - var tokenizer = std.mem.tokenizeAny(u8, text[first_header + 2 ..], " \t\n"); + var tokenizer = std.mem.tokenizeAny(u8, text[first_header + 2 ..], " \t\r\n"); const version_text = tokenizer.next() orelse @panic("Invalid changelog"); var version = std.SemanticVersion.parse(version_text) catch std.debug.panic("Invalid version: {s}", .{version_text}); diff --git a/build.zig.zon b/build.zig.zon index 094d9d8c88849c186fbed4b8d9b45b5644ab8e3f..538cf310e795f86cb98eef8c489f183a6d7315ff 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -2,7 +2,7 @@ .name = "", .version = "0.0.0", - .minimum_zig_version = "0.14.0-dev.1472+3929cac15", + .minimum_zig_version = "0.14.0-dev.1511+54b668f8a", .dependencies = .{ // Used to determine unicode properties to tokenize identifiers diff --git a/ci b/ci new file mode 100755 index 0000000000000000000000000000000000000000..49e4fdee48bbf259be988af2ea9399754ad4f969 --- /dev/null +++ b/ci @@ -0,0 +1,25 @@ +#!/bin/sh +# Continuous Integration Script +# By default, this will run a release build and checks +# locally. When run by CI, it will upload artifacts and +# deploy the language reference web page. +set -e + +commit=$(git rev-parse HEAD) +commit_short=$(echo "$commit" | cut -c -9) + +typos +dprint check +./build test package --summary all + +if [ -n "$UPLOAD_RELEASE_ARTIFACTS" ]; then + pushd zig-out/package + zip compiler-$commit.zip * + buildkite-agent artifact upload compiler-$commit.zip + popd + + rm -fr zig-out/site + mkdir zig-out/site + cp zig-out/package/README.html zig-out/site/index.html + npx wrangler pages deploy zig-out/site --commit-hash "$commit" --no-bundle --project-name language-manual +fi diff --git a/doc/architecture.md b/doc/architecture.md index 80ef3c1f4022d0ad7654b0f7a95f318d8a396d2f..de45d0b46a315d16d7b5ebeb7fba01e5f3a11762 100644 --- a/doc/architecture.md +++ b/doc/architecture.md @@ -27,9 +27,9 @@ Aside from tests written using Zig's test runner, there are a large set of tests within `test` which are ran using a custom test runner binary. It categorizes compiler tests into these categories: -- **Analysis Tests** (`test/analysis/*`) verify the semantic analysis - engine, and must not emit any runtime `Air`. Some analysis tests may - expect certain compile errors. +- **Analysis Tests** (`test/analysis/*`) verify the semantic analysis engine, + and must not emit any runtime `Air`. Some analysis tests may expect certain + compile errors. - **Behavior Tests** (`test/behavior/*`) generate code to be executed at runtime, testing both the semantic analysis pass as well as the code generation backend. diff --git a/hello b/hello deleted file mode 100644 index 819f2ba9c0b4c64700ee77c7158277b1c5097262..0000000000000000000000000000000000000000 --- a/hello +++ /dev/null @@ -1,6 +0,0 @@ -fn runtime() -> int { - 542 -} - -var abc: int = 0; -abc = runtime(); diff --git a/out.js b/out.js deleted file mode 100644 index b9c2a616db7dff7cf5e3b8ab1957c395f179da81..0000000000000000000000000000000000000000 --- a/out.js +++ /dev/null @@ -1,21 +0,0 @@ -// Language Compiler v0.1.6. Alpha quality software. -let addFloat = (v0, v1) => v0 + v1; -let f = v0 => v0; -let subFloat = (v0, v1) => v0 - v1; -let mulFloat = (v0, v1) => v0 * v1; -let divFloat = (v0, v1) => v0 / v1; -let addInt = (v0, v1) => v0 + v1; -let i = v0 => v0; -let subInt = (v0, v1) => v0 - v1; -assertEqual(addFloat(1, 2), f(3)); -assertEqual(addFloat(1.5, 2.2), f(3.7)); -assertEqual(subFloat(1, 2), f(-1)); -assertEqual(subFloat(1.5, 2.2), f(-0.7000000000000002)); -assertEqual(mulFloat(1, 2), f(2)); -assertEqual(mulFloat(1.5, 2.2), f(3.3000000000000003)); -assertEqual(divFloat(1, 2), f(0.5)); -assertEqual(divFloat(1.5, 2.2), f(0.6818181818181818)); -assertEqual(addInt(1, 2), i(3)); -assertEqual(addInt(-421, 592), i(171)); -assertEqual(subInt(1, 2), i(-1)); -assertEqual(subInt(528, -43), i(571)); diff --git a/src/core/Tokenizer.zig b/src/core/Tokenizer.zig index c14f19c26ca622d5b3b0e7504536fac7d8f2d467..2ed112a4e62969157e0190d5fcb6f0da3e1520b3 100644 --- a/src/core/Tokenizer.zig +++ b/src/core/Tokenizer.zig @@ -1318,10 +1318,10 @@ test "field access" { var tokenizer = Tokenizer{ .code = source }; for (expected_tokens) |tok| { tokenizer.skipWhitespace(); - try testing.expectEqual(tok, (try tokenizer.next()).?); + try testing.expectEqual(tok, tokenizer.next()); } tokenizer.skipWhitespace(); - try testing.expectEqual(null, (try tokenizer.next())); + try testing.expectEqual(null, tokenizer.next()); } test "string escapes" { diff --git a/src/manual/generate-man.zig b/src/manual/generate-man.zig index f1f956ed124af50e1d82d4eff37a367dc5f1fa76..73cfa40f8bf17cf81ce53007267ef87360e0d54e 100644 --- a/src/manual/generate-man.zig +++ b/src/manual/generate-man.zig @@ -575,10 +575,7 @@ fn writeTokenizedCode(gpa: Allocator, code: []const u8, writer: anytype) !void { var last: usize = 0; while (true) { t.skipWhitespace(); - const tok = t.next() catch { - t.pos += 1; - continue; - } orelse break; + const tok = t.next() orelse break; try writeHtmlEscapedSlice(t.code[last..tok.offset], writer, false); try writer.print("{s}", .{ @tagName(tok.tag), @@ -649,7 +646,7 @@ fn replaceInTemplate(alloc: Allocator, template: []const u8, replacements: anyty const Map = std.StringArrayHashMapUnmanaged([]const u8); var map: Map = .{}; - inline for (@typeInfo(Replacements).Struct.fields) |field| { + inline for (@typeInfo(Replacements).@"struct".fields) |field| { try map.put(alloc, field.name, @field(replacements, field.name)); }