authorchloe caruso <git@paperclover.net> 2024-09-11 22:41:20-07:00
committerchloe caruso <git@paperclover.net> 2024-09-11 22:41:20-07:00
log8880b270fac6fed25ebafc2aa2a49ac89622ade6
tree46e02fba89c5444c25b27da10a2f2fa795c02148
parent69ab21f0183d56865aa56b6879162e3918a5eba7

chore: setup basic ci script


8 files changed, 34 insertions(+), 39 deletions(-)

build.zig+1-1
......@@ -273,7 +273,7 @@ pub fn build(b: *Build) !void {
273273 std.math.maxInt(usize),
274274 );
275275 const first_header = std.mem.indexOf(u8, text, "## ") orelse @panic("Invalid changelog");
276 var tokenizer = std.mem.tokenizeAny(u8, text[first_header + 2 ..], " \t\n");
276 var tokenizer = std.mem.tokenizeAny(u8, text[first_header + 2 ..], " \t\r\n");
277277 const version_text = tokenizer.next() orelse @panic("Invalid changelog");
278278 var version = std.SemanticVersion.parse(version_text) catch
279279 std.debug.panic("Invalid version: {s}", .{version_text});
build.zig.zon+1-1
......@@ -2,7 +2,7 @@
22 .name = "",
33 .version = "0.0.0",
44
5 .minimum_zig_version = "0.14.0-dev.1472+3929cac15",
5 .minimum_zig_version = "0.14.0-dev.1511+54b668f8a",
66
77 .dependencies = .{
88 // Used to determine unicode properties to tokenize identifiers
ci created+25
......@@ -0,0 +1,25 @@
1#!/bin/sh
2# Continuous Integration Script
3# By default, this will run a release build and checks
4# locally. When run by CI, it will upload artifacts and
5# deploy the language reference web page.
6set -e
7
8commit=$(git rev-parse HEAD)
9commit_short=$(echo "$commit" | cut -c -9)
10
11typos
12dprint check
13./build test package --summary all
14
15if [ -n "$UPLOAD_RELEASE_ARTIFACTS" ]; then
16 pushd zig-out/package
17 zip compiler-$commit.zip *
18 buildkite-agent artifact upload compiler-$commit.zip
19 popd
20
21 rm -fr zig-out/site
22 mkdir zig-out/site
23 cp zig-out/package/README.html zig-out/site/index.html
24 npx wrangler pages deploy zig-out/site --commit-hash "$commit" --no-bundle --project-name language-manual
25fi
doc/architecture.md+3-3
......@@ -27,9 +27,9 @@ Aside from tests written using Zig's test runner, there are a large set of tests
2727within `test` which are ran using a custom test runner binary. It categorizes
2828compiler tests into these categories:
2929
30- **Analysis Tests** (`test/analysis/*`) verify the semantic analysis
31 engine, and must not emit any runtime `Air`. Some analysis tests may
32 expect certain compile errors.
30- **Analysis Tests** (`test/analysis/*`) verify the semantic analysis engine,
31 and must not emit any runtime `Air`. Some analysis tests may expect certain
32 compile errors.
3333- **Behavior Tests** (`test/behavior/*`) generate code to be executed at
3434 runtime, testing both the semantic analysis pass as well as the code
3535 generation backend.
hello deleted-6
......@@ -1,6 +0,0 @@
1fn runtime() -> int {
2 542
3}
4
5var abc: int = 0;
6abc = runtime();
out.js deleted-21
......@@ -1,21 +0,0 @@
1// Language Compiler v0.1.6. Alpha quality software.
2let addFloat = (v0, v1) => v0 + v1;
3let f = v0 => v0;
4let subFloat = (v0, v1) => v0 - v1;
5let mulFloat = (v0, v1) => v0 * v1;
6let divFloat = (v0, v1) => v0 / v1;
7let addInt = (v0, v1) => v0 + v1;
8let i = v0 => v0;
9let subInt = (v0, v1) => v0 - v1;
10assertEqual(addFloat(1, 2), f(3));
11assertEqual(addFloat(1.5, 2.2), f(3.7));
12assertEqual(subFloat(1, 2), f(-1));
13assertEqual(subFloat(1.5, 2.2), f(-0.7000000000000002));
14assertEqual(mulFloat(1, 2), f(2));
15assertEqual(mulFloat(1.5, 2.2), f(3.3000000000000003));
16assertEqual(divFloat(1, 2), f(0.5));
17assertEqual(divFloat(1.5, 2.2), f(0.6818181818181818));
18assertEqual(addInt(1, 2), i(3));
19assertEqual(addInt(-421, 592), i(171));
20assertEqual(subInt(1, 2), i(-1));
21assertEqual(subInt(528, -43), i(571));
src/core/Tokenizer.zig+2-2
......@@ -1318,10 +1318,10 @@ test "field access" {
13181318 var tokenizer = Tokenizer{ .code = source };
13191319 for (expected_tokens) |tok| {
13201320 tokenizer.skipWhitespace();
1321 try testing.expectEqual(tok, (try tokenizer.next()).?);
1321 try testing.expectEqual(tok, tokenizer.next());
13221322 }
13231323 tokenizer.skipWhitespace();
1324 try testing.expectEqual(null, (try tokenizer.next()));
1324 try testing.expectEqual(null, tokenizer.next());
13251325}
13261326
13271327test "string escapes" {
src/manual/generate-man.zig+2-5
......@@ -575,10 +575,7 @@ fn writeTokenizedCode(gpa: Allocator, code: []const u8, writer: anytype) !void {
575575 var last: usize = 0;
576576 while (true) {
577577 t.skipWhitespace();
578 const tok = t.next() catch {
579 t.pos += 1;
580 continue;
581 } orelse break;
578 const tok = t.next() orelse break;
582579 try writeHtmlEscapedSlice(t.code[last..tok.offset], writer, false);
583580 try writer.print("<span class='tok-{s}{s}'>{s}</span>", .{
584581 @tagName(tok.tag),
......@@ -649,7 +646,7 @@ fn replaceInTemplate(alloc: Allocator, template: []const u8, replacements: anyty
649646 const Map = std.StringArrayHashMapUnmanaged([]const u8);
650647
651648 var map: Map = .{};
652 inline for (@typeInfo(Replacements).Struct.fields) |field| {
649 inline for (@typeInfo(Replacements).@"struct".fields) |field| {
653650 try map.put(alloc, field.name, @field(replacements, field.name));
654651 }
655652