✓
Passing This code compiles and runs correctly.
Code
// Test: Parser accepts ANY characters in event names (except unbalanced braces)
//
// The parser should be PERMISSIVE about event name syntax.
// Transform passes enforce conventions, not the parser.
//
// Valid event names (parser accepts all of these):
// ring.new[T:i32] ← bracket style generics
// ring.new<T:i32> ← angle bracket style generics
// ring.new{T:i32} ← NOT valid (brace starts body)
// log.* ← glob pattern
// math.add<A,B> ← multiple type params
// weird.name$with#chars ← arbitrary characters
//
// The parser counts:
// () parentheses - must balance
// [] brackets - must balance
// <> angle brackets - must balance
// {} braces - STOP at opening brace (starts event body)
//
// Everything before the `{` is the event name + params.
// The transform decides if the syntax makes sense.
// These should ALL parse successfully and land on the test.* glob, which
// consumes each site (replaces it with a comment) so nothing reaches emit.
~[comptime|transform]pub tor test.* {
event_name: string,
item: *const std/compiler:Item,
program: *const std/compiler:Program,
} -> SiteResult
~proc test.*|zig {
const ast = @import("ast");
const allocator = @import("std").heap.page_allocator;
const flow = if (item.* == .flow) &item.flow else return .{};
const inline_code_item = ast.Item{
.inline_code = .{
.code = "// permissive-name site claimed",
.location = flow.location,
.module = allocator.dupe(u8, flow.module) catch return .{},
},
};
return .{ .replacement = inline_code_item };
}
// Bracket style (like Zig generics)
~test.generic[T:u32;N:1024]()
// Angle bracket style (like C++/Rust generics)
~test.generic<T:u32;N:1024>()
// Mixed brackets (parser allows, transform can reject)
~test.weird<A>[B](C)()
// Glob-with-brackets name, still claimed by test.*
~test.ring.*[T:u32]()
// Special characters (parser allows anything)
~test.name$with#special@chars()
Flows
flow ~test.generic[T:u32;N:1024] click a branch to expand · @labels scroll to their anchor
test.generic[T:u32;N:1024]
flow ~test.generic<T:u32;N:1024> click a branch to expand · @labels scroll to their anchor
test.generic<T:u32;N:1024>
flow ~test.weird<A>[B] click a branch to expand · @labels scroll to their anchor
test.weird<A>[B] (C)
flow ~test.ring.*[T:u32] click a branch to expand · @labels scroll to their anchor
test.ring.*[T:u32]
flow ~test.name$with#special@chars click a branch to expand · @labels scroll to their anchor
test.name$with#special@chars
Test Configuration
COMPILE_ONLY