fix(syntax): skip shebangs, treat unused brackets as constituents, extend Scheme's # table - #140
Merged
Merged
Conversation
…tend Scheme's # table
Three independent reader-classification gaps, found by the same style of
corpus audit as prior PRs in this series:
- `#!/usr/bin/env sbcl --script` and other shebang lines are now skipped at
offset 0 for Common Lisp, matching the existing Emacs Lisp and Hy arms.
Without it, files starting with a shebang failed to parse at all,
including ASDF's own tools/cl-source-registry-cache.lisp.
- `[`, `]`, `{`, `}` are CLHS-reserved constituent characters in Common
Lisp, not delimiters. `is_atom_boundary` was splitting symbols like
`whitespace[2]p` and `print-mov[dq]-opcode` at the bracket, which broke
parsing outright on files including SBCL's own src/code/reader.lisp.
Scheme and Emacs Lisp are deliberately left alone: their own readers
either already handle it or reserve the character without assigning it
constituent status.
- classify_scheme's `#` dispatch table gains the R6RS lexical syntax for
`syntax`/`quasisyntax`/`unsyntax`/`unsyntax-splicing` (`#'`, `` #` ``,
`#,`, `#,@`) and Guile's `#nil`, alongside the `##name` (Gambit
namespace-qualified identifier) handling already shipped in #132. `#'`
keeps its child visible via ReaderPrefix::Function; the other three
become opaque MultiDatum forms rather than new ReaderPrefix variants,
which is the same suppressing-direction tradeoff #132 made for the rest
of this table.
The vector-width and `#:keyword` dispatch logic in this area already
shipped in #132; this only adds coverage #132 did not have, reusing its
existing scheme_uniform_vector_width and Racket-guard fix rather than
reimplementing them.
…racket bug
unused_brackets_are_constituents (this branch) makes `[`, `]`, `{` and `}`
ordinary constituent characters in Common Lisp instead of raw delimiters.
Five existing tests across three packages had pinned the *old*, buggy
behavior — a bracket-containing string failing to parse as Common Lisp —
as if it were a dialect-semantics guarantee, when it was really this bug.
`cargo test --workspace` caught all five; each is updated to assert the
CLHS-correct `.is_ok()` and, where the test's own point was rule silence
or dialect-scoped reading rather than the parse result itself, extended to
check that directly instead of relying on a parse failure as a shortcut.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three independent reader-classification gaps, in the same style as prior audits in this series:
#!/usr/bin/env sbcl --scriptnow skip the shebang line at offset 0, matching the existing Emacs Lisp/Hy arms. Without it these files failed to parse at all, including ASDF's owntools/cl-source-registry-cache.lisp.[,],{,}are CLHS-reserved constituent characters in Common Lisp, not delimiters.is_atom_boundarywas splitting symbols likewhitespace[2]pandprint-mov[dq]-opcodeat the bracket, breaking parsing outright on files including SBCL's ownsrc/code/reader.lisp. Scheme and Emacs Lisp are deliberately left alone.classify_scheme's#dispatch table gains R6RS lexical syntax (#',#`,#,,#,@) and Guile's#nil, alongside the##namehandling already shipped in fix(syntax): repair Scheme reader dispatch, 17.4% → 97.2% on Guile #132. Reuses fix(syntax): repair Scheme reader dispatch, 17.4% → 97.2% on Guile #132's existingscheme_uniform_vector_width/#:keywordfix rather than reimplementing them — this only adds coverage fix(syntax): repair Scheme reader dispatch, 17.4% → 97.2% on Guile #132 did not have.Test plan
cargo build -p paredit-core-syntaxcargo test -p paredit-core-syntax(778 passed)cargo check --workspace --all-targets