mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
sync
This commit is contained in:
parent
797b2b01b2
commit
89adf9cf5c
@ -6,7 +6,7 @@ const std = @import("std.zig");
|
||||
const tokenizer = @import("zig/tokenizer.zig");
|
||||
const assert = std.debug.assert;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const Writer = std.io.Writer;
|
||||
const Writer = std.Io.Writer;
|
||||
|
||||
pub const ErrorBundle = @import("zig/ErrorBundle.zig");
|
||||
pub const Server = @import("zig/Server.zig");
|
||||
@ -426,7 +426,7 @@ pub const FormatId = struct {
|
||||
};
|
||||
|
||||
/// Print the string as a Zig identifier, escaping it with `@""` syntax if needed.
|
||||
fn render(ctx: FormatId, writer: *std.io.Writer) std.io.Writer.Error!void {
|
||||
fn render(ctx: FormatId, writer: *Writer) Writer.Error!void {
|
||||
const bytes = ctx.bytes;
|
||||
if (isValidId(bytes) and
|
||||
(ctx.flags.allow_primitive or !std.zig.isPrimitive(bytes)) and
|
||||
@ -464,7 +464,7 @@ test fmtChar {
|
||||
}
|
||||
|
||||
/// Print the string as escaped contents of a double quoted string.
|
||||
pub fn stringEscape(bytes: []const u8, w: *std.io.Writer) std.io.Writer.Error!void {
|
||||
pub fn stringEscape(bytes: []const u8, w: *Writer) Writer.Error!void {
|
||||
for (bytes) |byte| switch (byte) {
|
||||
'\n' => try w.writeAll("\\n"),
|
||||
'\r' => try w.writeAll("\\r"),
|
||||
@ -481,7 +481,7 @@ pub fn stringEscape(bytes: []const u8, w: *std.io.Writer) std.io.Writer.Error!vo
|
||||
}
|
||||
|
||||
/// Print the string as escaped contents of a single-quoted string.
|
||||
pub fn charEscape(bytes: []const u8, w: *std.io.Writer) std.io.Writer.Error!void {
|
||||
pub fn charEscape(bytes: []const u8, w: *Writer) Writer.Error!void {
|
||||
for (bytes) |byte| switch (byte) {
|
||||
'\n' => try w.writeAll("\\n"),
|
||||
'\r' => try w.writeAll("\\r"),
|
||||
|
||||
@ -12,7 +12,7 @@ const Token = std.zig.Token;
|
||||
const Ast = @This();
|
||||
const Allocator = std.mem.Allocator;
|
||||
const Parse = @import("Parse.zig");
|
||||
const Writer = std.io.Writer;
|
||||
const Writer = std.Io.Writer;
|
||||
|
||||
/// Reference to externally-owned data.
|
||||
source: [:0]const u8,
|
||||
@ -205,8 +205,8 @@ pub fn parse(gpa: Allocator, source: [:0]const u8, mode: Mode) Allocator.Error!A
|
||||
/// Caller owns the returned slice of bytes, allocated with `gpa`.
|
||||
pub fn renderAlloc(tree: Ast, gpa: Allocator) error{OutOfMemory}![]u8 {
|
||||
var aw: std.io.Writer.Allocating = .init(gpa);
|
||||
errdefer aw.deinit();
|
||||
render(tree, gpa, &aw.interface, .{}) catch |err| switch (err) {
|
||||
defer aw.deinit();
|
||||
render(tree, gpa, &aw.writer, .{}) catch |err| switch (err) {
|
||||
error.WriteFailed => return error.OutOfMemory,
|
||||
};
|
||||
return aw.toOwnedSlice();
|
||||
@ -214,8 +214,8 @@ pub fn renderAlloc(tree: Ast, gpa: Allocator) error{OutOfMemory}![]u8 {
|
||||
|
||||
pub const Render = @import("Ast/Render.zig");
|
||||
|
||||
pub fn render(tree: Ast, gpa: Allocator, bw: *Writer, fixups: Render.Fixups) Render.Error!void {
|
||||
return Render.tree(gpa, bw, tree, fixups);
|
||||
pub fn render(tree: Ast, gpa: Allocator, w: *Writer, fixups: Render.Fixups) Render.Error!void {
|
||||
return Render.tree(gpa, w, tree, fixups);
|
||||
}
|
||||
|
||||
/// Returns an extra offset for column and byte offset of errors that
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user