raz / commit 941622c5

commit
941622c50ee48eba59de1a882256483147d6523d
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
013c05d6
raz(1) states the form of raz -S's listing, and a test holds it

patch · log

2 files changed, +39 -0

doc/raz.1 (history) modified +24 -0

@@ -200,6 +200,30 @@
200200 .Nm
201201 .Cm run
202202 exits as the program does.
203+.Sh LISTING
204+The listing of
205+.Fl S
206+is in lines of three kinds, which a tool may read:
207+.Bl -bullet -offset indent
208+.It
209+a blank line, then a procedure's name as
210+.Ql Module.name: ;
211+.It
212+a source line: its number, right-aligned in 6 columns, two spaces, and
213+the line's text as it is in the file;
214+.It
215+an instruction: its offset in the procedure, right-aligned in 14
216+columns, two spaces, and the instruction as an assembler would read it;
217+a jump within the procedure gives its target as an offset in the same
218+way, and a call of a procedure names it.
219+.El
220+.Pp
221+The listing is of the main module's live procedures, those the program
222+uses, in the order their code was made.
223+Nothing is disassembled: each instruction is the one the compiler meant
224+to write.
225+A source line comes before the first instruction made for it, and is
226+not repeated until the line changes.
203227 .Sh EXAMPLES
204228 Compile and run hello, world:
205229 .Bd -literal -offset indent

test/check.sh (history) modified +15 -0

@@ -160,6 +160,21 @@
160160 if $raz -S $f 2>&1 | cmp -s $want -; then pass=$((pass + 1))
161161 else echo "FAIL raz -S $f"; $raz -S $f 2>&1 | diff $want - | head; fail=$((fail + 1)); fi
162162 done
163+# raz -S's form, as raz(1) states it: every line is blank, a procedure's
164+# name (after a blank line), a source line (number to column 6, two spaces,
165+# text) or an instruction (offset to column 14, two spaces, text); a jump
166+# gives its target as a number
167+if $raz -S test/list/Listing.raz 2>&1 | awk '
168+ NR == 1 && $0 != "" { bad = "first line not blank" }
169+ $0 == "" { blank = 1; next }
170+ /^[A-Za-z0-9]+\.[A-Za-z0-9.]+:$/ { if (!blank) bad = "name after no blank: " $0; blank = 0; next }
171+ { blank = 0 }
172+ match($0, /^ *[0-9]+/) && (RLENGTH == 6 || RLENGTH == 14) && substr($0, RLENGTH + 1, 2) == " " {
173+ if (RLENGTH == 14 && $0 ~ /^ *[0-9]+ j[a-z]* / && $0 !~ / j[a-z]* [0-9]+$/) bad = "jump with no offset: " $0
174+ next }
175+ { bad = "no form: " $0 }
176+ END { if (bad != "") { print bad; exit 1 } }'; then pass=$((pass + 1))
177+else echo "FAIL raz -S: a line not of raz(1)'s form"; fail=$((fail + 1)); fi
163178 # the report's version is the one the compiler says it follows
164179 # the version the compiler follows: the report's, or one it names while
165180 # the compiler catches up