From 85f4b88cc59a35c86b95c067e6e36684716abca5 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Sun, 11 Oct 2026 12:11:30 +0100 Subject: [PATCH] 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. --- diff --git a/CLAUDE.md b/CLAUDE.md index 636b13a..4f1bda4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,7 +10,7 @@ make raz # the compiler, ./raz; its library is lib/ make check # every example and test against its expected output make bench # must report at least 400,000 lines a second - make loc # lines of the compiler; the code column is the budget + make loc # lines of the compiler, by rloc; the last, code, is the budget make tests # the small Pascal tests of scan, x64, link and elf make gdb # gdb stops at a line of a test and names it make stress # 40,000 native threads; make check runs a small version diff --git a/Makefile b/Makefile index 8a09b4c..6ad027b 100644 --- a/Makefile +++ b/Makefile @@ -68,9 +68,11 @@ build/Pretty $$f | cmp -s - $$f || { echo "not formatted: $$f"; fail=1; }; \ done; test $$fail = 0 -# lines of the compiler: all of them, and those that aren't blank or comments +# lines of the compiler, by rloc: each file's blank, comment and code, +# then the lines of code in all loc: - @python3 test/loc.py src/*.pas + @rloc -f src/*.pas + @rloc -c src/*.pas # raz and its library go together under $(PREFIX)/lib/raz; the link # on PATH works since raz finds lib/ beside its real path. diff --git a/test/loc.py b/test/loc.py deleted file mode 100644 index 49caf2a..0000000 --- a/test/loc.py +++ /dev/null @@ -1,16 +0,0 @@ -"""Counts the lines of the compiler's units, or of raz modules: all of -them, and the lines of code, those that are neither blank nor only -comment. In raz, { and } are literals, not comments.""" -import re, sys - -total = code = 0 -for path in sys.argv[1:]: - text = open(path).read() - comment = r"\(\*.*?\*\)" if path.endswith(".raz") else r"\{[^}]*\}|\(\*.*?\*\)" - bare = re.sub(comment, "", text, flags=re.S) - n = text.count("\n") - c = sum(1 for line in bare.split("\n") if line.strip()) - print(f"{path:18} {n:6} {c:6}") - total += n - code += c -print(f"{'total':18} {total:6} {code:6}")