commit 0954da6d44e3f5bd7603620de14d3c48a40ef8a9
parent 1cc35875af4ad60084dc16c61fa9fc833c65d297
Author: Byron Torres <b@torresjrjr.com>
Date: Sun, 19 Feb 2023 17:35:25 +0000
add more debugging
Diffstat:
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/command.ha b/command.ha
@@ -105,10 +105,15 @@ fn exec_addrs(s: *session, cmd: *command) (void | error) = {
for (let i = 0z; i < len(cmd.addrs); i += 1) {
const addr = cmd.addrs[i];
let n = exec_addr(s, addr)?;
+ debug("exec_addrs(): offs={}", addr.lineoffset);
n = n + addr.lineoffset: size; // beware of negatives
debug("exec_addrs(): n={}", n);
append(cmd.linenums, n);
+ for (let j = 0z; j < len(cmd.linenums); j += 1) {
+ debug("exec_addrs(): cmd.linenums[{}]={}", j, cmd.linenums[j]);
+ };
+
if (addr.setcurrentline) {
s.buf.cursor = n;
};
@@ -138,7 +143,7 @@ fn get_range(s: *session, lns: *[]size, a: size, b: size) ((size, size) | invali
} else if (len(lns) == 1) {
yield (lns[0], lns[0]);
} else {
- yield (lns[len(lns)-2], lns[len(lns)-1]);
+ yield (lns[ len(lns) - 2 ], lns[ len(lns) - 1 ]);
};
debug("get_range(): (a, b)=({}, {})", a, b);
if (a < 0 || a > b || b >= len(s.buf.lines)) {
diff --git a/main.ha b/main.ha
@@ -77,6 +77,8 @@ export fn main() void = {
cmd_edit(&s, &cmd): void;
};
+ let cmd = command { ... };
+
for (true) :repl {
if (s.promptmode) {
fmt::error(s.prompt)!;
@@ -112,6 +114,7 @@ export fn main() void = {
if (execnow) {
// TODO: handle all ": void"s
execute(&s, &cmd): void;
+ //cmd = command { ... };
};
case mode::INPUT =>
if (input == ".") {
diff --git a/parse.ha b/parse.ha
@@ -208,7 +208,7 @@ fn scan_addrs(iter: *strings::iterator) []address = {
};
};
- // debug("scan_addrs(): len(addrs)={}", len(addrs))!;
+ // debug("scan_addrs(): len(addrs)={}", len(addrs));
return addrs;
};
@@ -222,7 +222,7 @@ fn scan_addr(iter: *strings::iterator) (address | void) = {
yield r;
};
- // debug("scan_addr(): r={}", r)!;
+ // debug("scan_addr(): r={}", r);
const addrtype: (addresstype | void) =
if (r == '.') {
@@ -320,7 +320,7 @@ fn scan_offset(iter: *strings::iterator) int = {
};
};
-fn scan_cmdname(iter: *strings::iterator) (rune | unknowncommand)= {
+fn scan_cmdname(iter: *strings::iterator) (rune | unknowncommand) = {
scan_blanks(iter);
let r = match (strings::next(iter)) {
case void =>