Symbols, keywords, and tags reject Unicode characters above U+10FF and `|`

Open Beginner friendly
#25 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
clojure, javascript
Domain
compilers, tooling

Research direction

Open src/clojure.grammar and look at the identStart, readerTagIdentStart and javaIdentStart character sets, which currently cap non-ASCII at \u{a1}-\u{10ff}; widen them toward U+10FFFF while still excluding the characters in std.whitespace, and add | to the first two. Save the issue's script as repro.mjs, run it against the local build, and confirm every line yields the expected tree with no ⚠ nodes. Then rebuild the grammar and run the project's test suite so existing symbol/keyword cases still pass.

Written by the indexing model from the issue text.

Description

parser.parse() produces error nodes (⚠) on valid Clojure symbols, keywords, and reader tags containing non-ASCII characters above U+10FF (such as 'こんにちは, model₁, num★ in Clerk's notebooks/viewers/in_text_eval.clj, (ℕ-blabla 42) from nextjournal/clojure-mode#18, or ::options.𝕨𝕚𝕝𝕕) or | (such as HoneySQL's :|| operator).

Save as repro.mjs and run npm install @nextjournal/[email protected] && node repro.mjs:

import { parser } from "@nextjournal/lezer-clojure";

for (const src of [
  "(def greeting 'こんにちは)",
  "(let [model₁ 1] model₁)",
  "(defonce num★ (atom 20))",
  "(ℕ-blabla 42)",
  "::options.𝕨𝕚𝕝𝕕",
  "[:|| :a :b]",
  "(def ok 'αβγ)",
]) {
  console.log(`${src} => ${parser.parse(src).toString()}`);
}

Actual output:

(def greeting 'こんにちは) => Program(List("(",DefLike,VarName(Symbol),Quote("'",⚠),")"))
(let [model₁ 1] model₁) => Program(List("(",Operator(Symbol),Vector("[",Symbol,⚠,Number,"]"),Symbol,⚠,")"))
(defonce num★ (atom 20)) => Program(List("(",DefLike,VarName(Symbol),⚠,List("(",Operator(Symbol),Number,")"),")"))
(ℕ-blabla 42) => Program(List("(",⚠,Operator(Symbol),Number,")"))
::options.𝕨𝕚𝕝𝕕 => Program(Keyword,⚠)
[:|| :a :b] => Program(Vector("[",Keyword,⚠,Keyword,Keyword,"]"))
(def ok 'αβγ) => Program(List("(",DefLike,VarName(Symbol),Quote("'",Symbol),")"))

Expected output (Clojure's reader accepts every line without error):

(def greeting 'こんにちは) => Program(List("(",DefLike,VarName(Symbol),Quote("'",Symbol),")"))
(let [model₁ 1] model₁) => Program(List("(",Operator(Symbol),Vector("[",Symbol,Number,"]"),Symbol,")"))
(defonce num★ (atom 20)) => Program(List("(",DefLike,VarName(Symbol),List("(",Operator(Symbol),Number,")"),")"))
(ℕ-blabla 42) => Program(List("(",Operator(Symbol),Number,")"))
::options.𝕨𝕚𝕝𝕕 => Program(Keyword)
[:|| :a :b] => Program(Vector("[",Keyword,Keyword,Keyword,"]"))
(def ok 'αβγ) => Program(List("(",DefLike,VarName(Symbol),Quote("'",Symbol),")"))

In src/clojure.grammar, identStart, readerTagIdentStart, and javaIdentStart cap non-ASCII characters at \u{a1}-\u{10ff} instead of reaching U+10FFFF (excluding Unicode whitespace in std.whitespace), and identStart/readerTagIdentStart omit |.

Versions tested: @nextjournal/[email protected] (npm latest) and main (519ed97), Node.js v26.13.0.

Credit: https://ucsbplse.github.io/

Dominant language
JavaScript
Stars
27
Forks
5
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nextjournal/lezer-clojure

All issues in nextjournal/lezer-clojure

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.