zig fmt pass

This commit is contained in:
Luna 2020-04-01 16:09:52 -03:00
parent 7976b64cf6
commit 5ae47fb962
5 changed files with 32 additions and 32 deletions

View file

@ -45,18 +45,18 @@ pub const Analyzer = struct {
fn doError(self: *@This(), comptime fmt: []const u8, args: ...) void {
self.hadError = true;
std.debug.warn("analysis error" , .{ });
std.debug.warn("analysis error", .{});
if (self.err_tok) |tok| {
std.debug.warn(" at line {}" , .{ tok.line });
std.debug.warn(" at line {}", .{tok.line});
}
if (self.err_ctx) |ctx| {
std.debug.warn(" on {}" , .{ ctx });
std.debug.warn(" on {}", .{ctx});
}
std.debug.warn("\n\t" , .{ });
std.debug.warn("\n\t", .{});
std.debug.warn(fmt, args);
std.debug.warn("\n" , .{ });
std.debug.warn("\n", .{});
}
/// Resolve a type in global scope
@ -108,7 +108,7 @@ pub const Analyzer = struct {
) !void {
var actual_enum = @as(comp.SymbolUnderlyingTypeEnum, symbol_type);
if (actual_enum != wanted_type_enum) {
std.debug.warn("Expected {}, got {}\n" , .{ wanted_type_enum, actual_enum });
std.debug.warn("Expected {}, got {}\n", .{ wanted_type_enum, actual_enum });
return CompileError.TypeError;
}
}
@ -122,7 +122,7 @@ pub const Analyzer = struct {
.Integer32, .Integer64, .Double => {},
else => {
var actual_enum = @as(comp.SymbolUnderlyingTypeEnum, symbol_type);
std.debug.warn("Expected numeric, got {}\n" , .{ actual_enum });
std.debug.warn("Expected numeric, got {}\n", .{actual_enum});
return CompileError.TypeError;
},
}
@ -158,7 +158,7 @@ pub const Analyzer = struct {
const expected_enum = @as(comp.SymbolUnderlyingTypeEnum, expected_type);
if (symbol_enum != expected_enum) {
std.debug.warn("Expected {}, got {}\n" , .{ expected_enum, symbol_enum });
std.debug.warn("Expected {}, got {}\n", .{ expected_enum, symbol_enum });
return CompileError.TypeError;
}
@ -292,7 +292,7 @@ pub const Analyzer = struct {
var target = get.target.*;
const target_type = @as(ast.ExprType, target);
if (target_type != .Variable) {
std.debug.warn("Expected Variable as get target, got {}\n" , .{ target_type });
std.debug.warn("Expected Variable as get target, got {}\n", .{target_type});
return CompileError.TypeError;
}
@ -475,7 +475,7 @@ pub const Analyzer = struct {
self.setErrContext("function {}", name);
var ret_type = self.resolveGlobalType(ctx, decl.return_type.lexeme);
std.debug.warn("start analysis of fn {}, ret type: {}\n" , .{ decl.func_name.lexeme, ret_type });
std.debug.warn("start analysis of fn {}, ret type: {}\n", .{ decl.func_name.lexeme, ret_type });
var parameters = comp.TypeList.init(self.allocator);
for (decl.params.toSlice()) |param| {

View file

@ -158,7 +158,7 @@ pub const VariableMetadata = struct {
typ: SymbolUnderlyingType,
) !*VariableMetadata {
var meta = try allocator.create(VariableMetadata);
std.debug.warn("VARMETA create from scope={}, meta={}\n" , .{ @ptrToInt(scope), @ptrToInt(meta) });
std.debug.warn("VARMETA create from scope={}, meta={}\n", .{ @ptrToInt(scope), @ptrToInt(meta) });
meta.* = VariableMetadata{ .typ = typ, .from_scope = scope, .using = .Scope };
return meta;
}
@ -169,7 +169,7 @@ pub const VariableMetadata = struct {
typ: SymbolUnderlyingType,
) !*VariableMetadata {
var meta = try allocator.create(VariableMetadata);
std.debug.warn("VARMETA create from fndecl={}, meta={}\n" , .{ @ptrToInt(func), @ptrToInt(meta) });
std.debug.warn("VARMETA create from fndecl={}, meta={}\n", .{ @ptrToInt(func), @ptrToInt(meta) });
meta.* = VariableMetadata{ .typ = typ, .from_function = func, .using = .Function };
return meta;
}
@ -204,7 +204,7 @@ pub const CompilationContext = struct {
@panic("can't bump scope from null");
}
std.debug.warn("==scope bump== '{}'\n" , .{ scope_id });
std.debug.warn("==scope bump== '{}'\n", .{scope_id});
var child = try self.current_scope.?.createChild(scope_id);
self.current_scope = child;
@ -212,7 +212,7 @@ pub const CompilationContext = struct {
/// Set a given scope as the current scope.
pub fn setScope(self: *@This(), scope: *Scope) void {
std.debug.warn("==set== set scope to {}\n" , .{ scope.id });
std.debug.warn("==set== set scope to {}\n", .{scope.id});
self.current_scope = scope;
}
@ -349,7 +349,7 @@ pub const CompilationContext = struct {
) !*SymbolData {
var sym_kv = self.symbol_table.get(identifier);
if (sym_kv == null) {
std.debug.warn("Unknown {} '{}'\n" , .{ typ, identifier });
std.debug.warn("Unknown {} '{}'\n", .{ typ, identifier });
return CompilationError.TypeError;
}
@ -357,7 +357,7 @@ pub const CompilationContext = struct {
var sym_typ = @as(SymbolType, value.*);
if (sym_typ != typ) {
std.debug.warn("Expected {}, got {}\n" , .{ sym_typ, typ });
std.debug.warn("Expected {}, got {}\n", .{ sym_typ, typ });
return CompilationError.TypeError;
}
@ -417,7 +417,7 @@ pub const CompilationContext = struct {
}
}
std.debug.warn("Unknown name {}\n" , .{ name });
std.debug.warn("Unknown name {}\n", .{name});
return CompilationError.UnknownName;
}

View file

@ -2,9 +2,9 @@ const std = @import("std");
pub fn report(line: usize, where: []const u8, ctx_opt: ?[]const u8, message: []const u8) void {
if (ctx_opt) |ctx| {
std.debug.warn("[line {}] Error{} on {}: {}" , .{ line, where, ctx, message });
std.debug.warn("[line {}] Error{} on {}: {}", .{ line, where, ctx, message });
} else {
std.debug.warn("[line {}] Error{}: {}" , .{ line, where, message });
std.debug.warn("[line {}] Error{}: {}", .{ line, where, message });
}
}
@ -14,11 +14,11 @@ pub fn reportN(line: usize, message: []const u8) void {
pub fn reportFmt(line: usize, ctx_opt: ?[]const u8, comptime fmt: []const u8, args: ...) void {
if (ctx_opt) |ctx| {
std.debug.warn("[line {}] Error on {}" , .{ line, ctx });
std.debug.warn("[line {}] Error on {}", .{ line, ctx });
} else {
std.debug.warn("[line {}] Error" , .{ line });
std.debug.warn("[line {}] Error", .{line});
}
std.debug.warn(fmt, args);
std.debug.warn("\n" , .{ });
std.debug.warn("\n", .{});
}

View file

@ -32,7 +32,7 @@ pub fn run(allocator: *std.mem.Allocator, slice: []const u8) !Result {
if (tok.typ == .EOF) break;
// TODO remove
std.debug.warn("{x}\n" , .{ tok });
std.debug.warn("{x}\n", .{tok});
}
}
@ -47,13 +47,13 @@ pub fn run(allocator: *std.mem.Allocator, slice: []const u8) !Result {
var root = root_opt.?;
std.debug.warn("parse tree\n" , .{ });
std.debug.warn("parse tree\n", .{});
printer.printNode(root, 0);
var solver = try analysis.Analyzer.init(allocator);
var ctx = try solver.pass(root);
std.debug.warn("symbol table\n" , .{ });
std.debug.warn("symbol table\n", .{});
printer.printContext(ctx);
var cgen = codegen.llvm.Codegen.init(allocator, &ctx);
@ -94,7 +94,7 @@ pub fn main() anyerror!void {
.ParseError,
.CompileError,
=> {
std.debug.warn("error: {}\n" , .{ result });
std.debug.warn("error: {}\n", .{result});
std.os.exit(1);
},
}

View file

@ -107,15 +107,15 @@ pub const Parser = struct {
fn doError(self: *Parser, comptime fmt: []const u8, args: ...) ParseError {
self.hadError = true;
std.debug.warn("parser error at line {}" , .{ self.scanner.line });
std.debug.warn("parser error at line {}", .{self.scanner.line});
if (self.err_ctx) |ctx| {
std.debug.warn(" on {}" , .{ ctx });
std.debug.warn(" on {}", .{ctx});
}
std.debug.warn("\n\t" , .{ });
std.debug.warn("\n\t", .{});
std.debug.warn(fmt, args);
std.debug.warn("\n" , .{ });
std.debug.warn("\n", .{});
return ParseError.CompileError;
}
@ -146,7 +146,7 @@ pub const Parser = struct {
}
fn tokenError(self: *Parser, token: Token, msg: []const u8) ParseError {
std.debug.warn("ctx: '{}'\n" , .{ self.err_ctx });
std.debug.warn("ctx: '{}'\n", .{self.err_ctx});
if (token.typ == .EOF) {
ereport.report(token.line, " at end", self.err_ctx, msg);
} else {
@ -177,7 +177,7 @@ pub const Parser = struct {
}
try self.tokens.append(token);
std.debug.warn("skip to {}\n" , .{ token });
std.debug.warn("skip to {}\n", .{token});
return token;
}