Files
codebase-memory-mcp/tools
Edson af8bac800f fix(grammar): stop escaped Haskell char literals at the closing quote (#2439)
An escaped char literal followed by a primed definition swallowed that
definition: with

    f = '\n'

    g' = 2

the `char` token ran from '\n through g', so f spanned three lines, g'
got no node and the valid module reported has_error. On one line
['\n','\t'] lexed as a single char token, silently.

Root cause is upstream tree-sitter-haskell (the pin we vendor): the
escape branch of the `char` token is /'\\[^ ]*'/, and [^ ]* also
matches newlines and quotes, so the lexer's longest match runs on to the
last ' before the next space. The external scanner is not involved. The
regex is unchanged on upstream master, so there is no fix to pull.

Fix: haskell becomes a self-maintained fork of the pin we already vendor
(tree-sitter/tree-sitter-haskell @ 7fa19f195803, v0.23.1), following the
javascript/tsx and pascal model. One patch
(tools/tree-sitter-haskell/patches/escaped-char-literal.patch) narrows
that one regex in grammar/literal.js to /'\\('|[^'\s]+)'/: a backslash,
then either a quote ('\'') or a run of non-quote, non-whitespace
characters, then the closing quote. '\\', '\x41', '\SOH', '\^A', '\1234'
and MagicHash '\n'# lex as before; a stray ' after a literal is now an
ERROR node instead of being absorbed. Node types are unchanged.
Regenerated with tree-sitter-cli 0.25.10 (ABI 15, as before; scanner.c,
unicode.h and tree_sitter/*.h untouched); parser.c has 0 non-ASCII bytes
and the same state/symbol/token/field/production counts.

Fidelity: regenerating the UNPATCHED grammar with 0.25.10 reproduces the
previously vendored parser.c byte-for-byte (apart from the trailing
newline). The patched parser passes all 724 cases of upstream's corpus
and gives a tree identical to the unpatched one on upstream's
examples/Basic.hs.

Registered like pascal: MANIFEST.md fork row + note, audit FORKS map,
THIRD_PARTY.md, vendored checksums. LICENSE stays upstream's MIT,
byte-identical.

Tests: the two reproduce-first extraction tests from the previous commit
are unchanged (the #2439 repro, and the one-line list of seven escapes);
the fork carries test/corpus/escaped_char_literal.txt; test_impact maps
the fork's parser.c as repo-data like pascal's.

Signed-off-by: Edson <zhuoxi2000@gmail.com>
2026-10-25 21:30:10 -04:00
..