From 941622c50ee48eba59de1a882256483147d6523d Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Mon, 26 Oct 2026 17:10:41 +0000 Subject: [PATCH] raz(1) states the form of raz -S's listing, and a test holds it --- diff --git a/doc/raz.1 b/doc/raz.1 index 47903c2..2d78770 100644 --- a/doc/raz.1 +++ b/doc/raz.1 @@ -200,6 +200,30 @@ .Nm .Cm run exits as the program does. +.Sh LISTING +The listing of +.Fl S +is in lines of three kinds, which a tool may read: +.Bl -bullet -offset indent +.It +a blank line, then a procedure's name as +.Ql Module.name: ; +.It +a source line: its number, right-aligned in 6 columns, two spaces, and +the line's text as it is in the file; +.It +an instruction: its offset in the procedure, right-aligned in 14 +columns, two spaces, and the instruction as an assembler would read it; +a jump within the procedure gives its target as an offset in the same +way, and a call of a procedure names it. +.El +.Pp +The listing is of the main module's live procedures, those the program +uses, in the order their code was made. +Nothing is disassembled: each instruction is the one the compiler meant +to write. +A source line comes before the first instruction made for it, and is +not repeated until the line changes. .Sh EXAMPLES Compile and run hello, world: .Bd -literal -offset indent diff --git a/test/check.sh b/test/check.sh index f982d29..d13a4e8 100755 --- a/test/check.sh +++ b/test/check.sh @@ -160,6 +160,21 @@ if $raz -S $f 2>&1 | cmp -s $want -; then pass=$((pass + 1)) else echo "FAIL raz -S $f"; $raz -S $f 2>&1 | diff $want - | head; fail=$((fail + 1)); fi done +# raz -S's form, as raz(1) states it: every line is blank, a procedure's +# name (after a blank line), a source line (number to column 6, two spaces, +# text) or an instruction (offset to column 14, two spaces, text); a jump +# gives its target as a number +if $raz -S test/list/Listing.raz 2>&1 | awk ' + NR == 1 && $0 != "" { bad = "first line not blank" } + $0 == "" { blank = 1; next } + /^[A-Za-z0-9]+\.[A-Za-z0-9.]+:$/ { if (!blank) bad = "name after no blank: " $0; blank = 0; next } + { blank = 0 } + match($0, /^ *[0-9]+/) && (RLENGTH == 6 || RLENGTH == 14) && substr($0, RLENGTH + 1, 2) == " " { + if (RLENGTH == 14 && $0 ~ /^ *[0-9]+ j[a-z]* / && $0 !~ / j[a-z]* [0-9]+$/) bad = "jump with no offset: " $0 + next } + { bad = "no form: " $0 } + END { if (bad != "") { print bad; exit 1 } }'; then pass=$((pass + 1)) +else echo "FAIL raz -S: a line not of raz(1)'s form"; fail=$((fail + 1)); fi # the report's version is the one the compiler says it follows # the version the compiler follows: the report's, or one it names while # the compiler catches up