Reader records source line/column on list forms

The reader stamps 1-based :line/:column metadata on every list form (plus
:file when load-jolt-file is reading a file), and jolt.host/form-position
reads it back so the analyzer's :pos scaffold finally gets real data. A
left-to-right cursor counts newlines over the delta between successive forms,
so it stays O(n). Vector/map/set literals are untouched (their metadata is a
runtime value the analyzer would have to wrap in with-meta); empty () can't
carry meta. ^meta now merges onto the position keys instead of clobbering them.

Re-mint is byte-identical (the backend doesn't emit :pos), so this is a pure
scaffold for the error-location work that follows.
This commit is contained in:
Yogthos 2026-06-25 21:12:01 -04:00
parent bdf436e242
commit 824fb347a3
4 changed files with 85 additions and 16 deletions

View file

@ -331,6 +331,14 @@
{:suite "reader" :expr "(nil? (read-string \" , ,\"))" :expected "true"}
{:suite "reader" :expr "(:tag (meta (read-string \"^String x\")))" :expected "String"}
{:suite "reader" :expr "(:foo (meta (read-string \"^:foo x\")))" :expected "true"}
{:suite "reader" :expr "(:line (meta (read-string \"(foo bar)\")))" :expected "1"}
{:suite "reader" :expr "(:column (meta (read-string \"(foo bar)\")))" :expected "1"}
{:suite "reader" :expr "(:line (meta (read-string \"\\n\\n (x)\")))" :expected "3"}
{:suite "reader" :expr "(:column (meta (read-string \"\\n\\n (x)\")))" :expected "3"}
{:suite "reader" :expr "(nil? (meta (read-string \"[1 2]\")))" :expected "true"}
{:suite "reader" :expr "(nil? (meta (read-string \"()\")))" :expected "true"}
{:suite "reader" :expr "(:foo (meta (read-string \"^:foo (x y)\")))" :expected "true"}
{:suite "reader" :expr "(:line (meta (read-string \"^:foo (x y)\")))" :expected "1"}
{:suite "reader" :expr "(= 42 (with-in-str \"42\" (read)))" :expected "true"}
{:suite "reader" :expr "(= (quote (+ 1 2)) (with-in-str \"(+ 1 2)\" (read)))" :expected "true"}
{:suite "reader" :expr "(with-in-str \"1 2\" [(read) (read)])" :expected "[1 2]"}