╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ migrate_langref.zig ──────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
380 fatal("unable to create file '{s}': {s}", .{ name, @errorName(err) }); 381 }; 382 defer file.close(io); 383 var file_buffer: [1024]u8 = undefined; 384 var file_writer = file.writer(io, &file_buffer); 385 const code = &file_writer.interface; 386 387 const source = tokenizer.buffer[source_token.start..source_token.end]; 388 try code.writeAll(std.mem.trim(u8, source[1..], " \t\r\n")); 389 try code.writeAll("\n\n"); 390 391 if (just_check_syntax) { 392 try code.print("// syntax\n", .{}); 393 } else switch (code_kind_id) { 394 .@"test" => try code.print("// test\n", .{}), 395 .lib => try code.print("// lib\n", .{}), 396 .test_error => |s| try code.print("// test_error={s}\n", .{s}), 397 .test_safety => |s| try code.print("// test_safety={s}\n", .{s}), 398 .exe => |s| try code.print("// exe={s}\n", .{@tagName(s)}), 399 .obj => |opt| if (opt) |s| { 400 try code.print("// obj={s}\n", .{s}); 401 } else { 402 try code.print("// obj\n", .{}); 403 }, 404 } 405 406 if (mode != .debug) 407 try code.print("// optimize={s}\n", .{@tagName(mode)}); 408 409 for (link_objects.items) |link_object| { 410 try code.print("// link_object={s}\n", .{link_object}); 411 } 412 413 if (target_str) |s| 414 try code.print("// target={s}\n", .{s}); 415 416 if (link_libc) try code.print("// link_libc\n", .{}); 417 if (disable_cache) try code.print("// disable_cache\n", .{}); 418 419 if (link_mode) |m| 420 try code.print("// link_mode={s}\n", .{@tagName(m)}); 421 422 for (additional_options.items) |o| { 423 try code.print("// additional_option={s}\n", .{o}); 424 } 425 try code.flush(); 426 try w.print("{{#code|{s}#}}\n", .{basename}); 427 } else { 428 const close_bracket = while (true) { 429 const next = tokenizer.next(); 430 if (next.id == .bracket_close) break next; 431 }; 432 try w.writeAll(tokenizer.buffer[token.start..close_bracket.end]); 433 } 434 }, 435 else => return parseError(tokenizer, token, "invalid token", .{}), 436 } 437 } 438 } 439 440 fn urlize(allocator: Allocator, input: []const u8) ![]u8 { 441 var buf = std.array_list.Managed(u8).init(allocator); 442 defer buf.deinit(); 443 444 const out = buf.writer(); 445 for (input) |c| { 446 switch (c) { 447 'a'...'z', 'A'...'Z', '_', '-', '0'...'9' => { 448 try out.writeByte(c); 449 }, 450 ' ' => { 451 try out.writeByte('-'); 452 }, 453 else => {}, 454 } 455 } 456 return try buf.toOwnedSlice(); 457 } 458