commit f1bf60f7185f2ed41f88454d5ace8d0ffb80b934
parent 7800fe233d69bf2bed1f4e6a1841e660e46f2583
Author: Lou Woell <lou.woell@posteo.de>
Date:   Fri,  5 Sep 2025 02:39:33 +0200

Whitespace

Diffstat:
Mcmd/harehelper/find.ha | 18+++++++++---------
Mcmd/harehelper/helper.ha | 44++++++++++++++++++++++----------------------
Mcmd/harehelper/list_symbols.ha | 9++++-----
Mcmd/harehelper/locate.ha | 14+++++++-------
Mcmd/harehelper/util.ha | 10+++++-----
5 files changed, 47 insertions(+), 48 deletions(-)

diff --git a/cmd/harehelper/find.ha b/cmd/harehelper/find.ha @@ -13,15 +13,15 @@ fn resolve(cmd: getopt::command) void = { let id = parse::identstr(cmd.args[0])!; - let file = if(len(cmd.args) > 1){ + let file = if (len(cmd.args) > 1) { yield cmd.args[1]; } else { printident(id); return void; }; - match(find_uid(id, file)) { - case let id_exp: ast::ident => + match (find_uid(id, file)) { + case let id_exp: ast::ident => printident(id_exp); ast::ident_free(id_exp); case => void; @@ -55,30 +55,30 @@ fn find_uid (id: ast::ident, path: str) (void | ast::ident) = { let ns = ident_ns(id); let interned = false; - match(i.bindings){ + match (i.bindings) { case let a: ast::import_alias => ident = [a]; case let members: ast::import_members => - if(len(id) > 1) continue; + if (len(id) > 1) continue; for (let s .. members) { check = (s == id[0]); interned = true; break; }; case ast::import_wildcard => - // todo check all symbols; - void; + // todo check all symbols; + void; case void => void; }; - if(!check){ + if (!check) { check = ast::ident_eq(ns, ident) || ast::ident_eq(ns, ident_last(ident)); }; if (check) { let id_exp = ast::ident_dup(i.ident); - if(len(id) > 1 || interned){ + if (len(id) > 1 || interned) { let end = ident_last(id); let id_end = ast::ident_dup(end); append(id_exp, id_end[0])!; diff --git a/cmd/harehelper/helper.ha b/cmd/harehelper/helper.ha @@ -11,26 +11,26 @@ use strings; def HAREPATH = "/usr/src/hare/stdlib/:/usr/src/hare/third-party:."; const help: []getopt::help = [ - "help with hare", - ('h', "show help"), - ('p', "path", "append to harepath"), - ('P', "return harepath"), - ("list", [ - "list symbols in module", - "module" - ]: []getopt::help ), - ("resolve", [ - "resolve namespace for identifier", - "identifier", - "file" - ]: []getopt::help), - ("locate", [ - "return location of declaration for identifier", - "identifier", - ]: []getopt::help), - ("list-modules", [ - "list all modules in current harepath", - ]: []getopt::help), + "help with hare", + ('h', "show help"), + ('p', "path", "append to harepath"), + ('P', "return harepath"), + ("list", [ + "list symbols in module", + "module" + ]: []getopt::help ), + ("resolve", [ + "resolve namespace for identifier", + "identifier", + "file" + ]: []getopt::help), + ("locate", [ + "return location of declaration for identifier", + "identifier", + ]: []getopt::help), + ("list-modules", [ + "list all modules in current harepath", + ]: []getopt::help), ]; export fn main () void = { @@ -52,7 +52,7 @@ export fn main () void = { }; for (let (k, v) .. cmd.opts) { - switch(k){ + switch (k) { case 'h' => getopt::printhelp(os::stdout, "harehelper", help)!; os::exit(0); @@ -69,7 +69,7 @@ export fn main () void = { os::exit(0); }; - match(cmd.subcmd){ + match (cmd.subcmd) { case void => void; case let c: (str, *getopt::command) => switch (c.0) { diff --git a/cmd/harehelper/list_symbols.ha b/cmd/harehelper/list_symbols.ha @@ -10,7 +10,7 @@ fn list (cmd: getopt::command, ctx: *module::context) void = { defer ast::ident_free(id); let list = list_symbols(ctx, id); - for(let i .. list) { + for (let i .. list) { printident(i); ast::ident_free(i); }; @@ -23,11 +23,11 @@ fn list_symbols (ctx: *module::context, id: ast::ident) []ast::ident = { let res: []ast::ident = []; - for(let s .. src.ha) { + for (let s .. src.ha) { let decls = scan(s)!; for (let d .. decls) { - if(!d.exported) continue; - match(d.decl){ + if (!d.exported) continue; + match (d.decl) { case let d: []ast::decl_const => void; for (let t .. d) { append(res, ast::ident_dup(t.ident))!; @@ -51,4 +51,3 @@ fn list_symbols (ctx: *module::context, id: ast::ident) []ast::ident = { return res; }; - diff --git a/cmd/harehelper/locate.ha b/cmd/harehelper/locate.ha @@ -30,12 +30,12 @@ fn locate_symbol ( ) (lex::location | void) = { let ns: module::location = ident_ns(id); - if(len(id) <= 1){ + if (len(id) <= 1) { let p = path::init(os::getcwd())!; ns = &p; }; - let (path, src) = match(module::find(ctx, ns)) { + let (path, src) = match (module::find(ctx, ns)) { case module::error => return void; case let r: (str, module::srcset) => @@ -51,27 +51,27 @@ fn locate_symbol ( }; for (let decl .. decls) { - match(decl.decl){ + match (decl.decl) { case let d: []ast::decl_const => for (let t .. d) { - if(ast::ident_eq(id, t.ident)){ + if (ast::ident_eq(id, t.ident)) { return decl.start; }; }; case let d: []ast::decl_global => for (let t .. d) { - if(ast::ident_eq(id, t.ident)){ + if (ast::ident_eq(id, t.ident)) { return decl.start; }; }; case let d: []ast::decl_type => for (let t .. d) { - if(ast::ident_eq(id, t.ident)){ + if (ast::ident_eq(id, t.ident)) { return decl.start; }; }; case let d: ast::decl_func => - if(ast::ident_eq(id, d.ident)){ + if (ast::ident_eq(id, d.ident)) { return decl.start; }; case => void; diff --git a/cmd/harehelper/util.ha b/cmd/harehelper/util.ha @@ -1,12 +1,12 @@ +use bufio; +use fmt; +use fs; use hare::ast; +use hare::lex; use hare::parse; use hare::unparse; -use hare::lex; use io; -use fs; use os; -use fmt; -use bufio; fn printident(i: ast::ident) void = { unparse::ident(os::stdout, i)!; @@ -21,7 +21,7 @@ fn ident_last(id: ast::ident) ast::ident = { fn ident_ns(id: ast::ident) ast::ident = { let l = len(id); - if(l > 1) return id[..l - 1] else return id; + if (l > 1) return id[..l - 1] else return id; }; fn scan(path: str) ([]ast::decl | parse::error) = {