raz / commit 85f4b88c

commit
85f4b88cc59a35c86b95c067e6e36684716abca5
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
78d11873
make loc counts with rloc; test/loc.py goes

rloc (github ldiaz94/rloc) knows Pascal's // and { } comments and
strings, so { in '{' is no comment. The compiler counts 6,096 lines of
code, where loc.py said 6,060: still within the budget.

patch · log

3 files changed, +5 -19

CLAUDE.md modified +1 -1

@@ -10,7 +10,7 @@
1010 make raz # the compiler, ./raz; its library is lib/
1111 make check # every example and test against its expected output
1212 make bench # must report at least 400,000 lines a second
13- make loc # lines of the compiler; the code column is the budget
13+ make loc # lines of the compiler, by rloc; the last, code, is the budget
1414 make tests # the small Pascal tests of scan, x64, link and elf
1515 make gdb # gdb stops at a line of a test and names it
1616 make stress # 40,000 native threads; make check runs a small version

Makefile (history) modified +4 -2

@@ -68,9 +68,11 @@
6868 build/Pretty $$f | cmp -s - $$f || { echo "not formatted: $$f"; fail=1; }; \
6969 done; test $$fail = 0
7070
71-# lines of the compiler: all of them, and those that aren't blank or comments
71+# lines of the compiler, by rloc: each file's blank, comment and code,
72+# then the lines of code in all
7273 loc:
73- @python3 test/loc.py src/*.pas
74+ @rloc -f src/*.pas
75+ @rloc -c src/*.pas
7476
7577 # raz and its library go together under $(PREFIX)/lib/raz; the link
7678 # on PATH works since raz finds lib/ beside its real path.

test/loc.py deleted +0 -16

@@ -1,16 +0,0 @@
1-"""Counts the lines of the compiler's units, or of raz modules: all of
2-them, and the lines of code, those that are neither blank nor only
3-comment. In raz, { and } are literals, not comments."""
4-import re, sys
5-
6-total = code = 0
7-for path in sys.argv[1:]:
8- text = open(path).read()
9- comment = r"\(\*.*?\*\)" if path.endswith(".raz") else r"\{[^}]*\}|\(\*.*?\*\)"
10- bare = re.sub(comment, "", text, flags=re.S)
11- n = text.count("\n")
12- c = sum(1 for line in bare.split("\n") if line.strip())
13- print(f"{path:18} {n:6} {c:6}")
14- total += n
15- code += c
16-print(f"{'total':18} {total:6} {code:6}")