{"_id":"@codincod/codemirror-lang-j","_rev":"4-d75c6bcd3425b6a593c744063b436960","name":"@codincod/codemirror-lang-j","dist-tags":{"latest":"0.4.0"},"versions":{"0.2.0":{"name":"@codincod/codemirror-lang-j","version":"0.2.0","keywords":["editor","code","j","jsoftware","codemirror"],"author":{"name":"CodinCod","email":"hello@codincod.com"},"license":"MIT","_id":"@codincod/codemirror-lang-j@0.2.0","maintainers":[{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"}],"homepage":"https://codincod.com/","dist":{"shasum":"1ecb2dbfbf91b8f8ea9c02e4d6fe2574128090c5","tarball":"https://registry.npmjs.org/@codincod/codemirror-lang-j/-/codemirror-lang-j-0.2.0.tgz","fileCount":14,"integrity":"sha512-d+EaPVbgfEo/TUTW42xXfIXgZXt6PinjFPvpIzC9wM4qTtCiNqdkGKjtAaXZ5EOmr//o/69IeSwW+LBMus1XBQ==","signatures":[{"sig":"MEYCIQCpXKLYSBnWMNexdFVwtCUeVTOjlqyf23LdkynajpUO2wIhALD01vnsVOJbwHf6AKBpwaClfSxIElVU4DktK4msJhci","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":85692},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{"import":"./dist/index.js","require":"./dist/index.cjs"},"gitHead":"0c0a7e52b5d8cd6a4043fd64aff4cbaecb6ede6b","scripts":{"gaps":"npm run build && node ../lezer-survey/src/cli.ts gaps --group parent","test":"npm run build && node --test \"test/*.test.ts\"","build":"rm -rf dist && lezer-generator src/j.grammar -o src/parser.js && cm-buildhelper src/j.ts","corpus":"npm run build && node ../lezer-survey/src/cli.ts measure --group parent","prepare":"npm run build","build-debug":"lezer-generator src/j.grammar --names -o src/parser.js && cm-buildhelper src/j.ts"},"_npmUser":{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"},"repository":{"url":"git+https://codeberg.org/reeven/codemirror-lang-j.git","type":"git"},"_npmVersion":"11.6.2","description":"J language support for the CodeMirror code editor","directories":{},"sideEffects":false,"_nodeVersion":"25.0.0","dependencies":{"@lezer/lr":"^1.0.0","@lezer/common":"^1.0.0","@lezer/highlight":"^1.0.0","@codemirror/language":"^6.0.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.0","@lezer/generator":"^1.7.0","@codemirror/state":"^6.7.1","@codemirror/buildhelper":"^1.0.2"},"_npmOperationalInternal":{"tmp":"tmp/codemirror-lang-j_0.2.0_1785961553189_0.049697158822915144","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@codincod/codemirror-lang-j","version":"0.2.1","keywords":["editor","code","j","jsoftware","codemirror"],"author":{"name":"CodinCod","email":"hello@codincod.com"},"license":"MIT","_id":"@codincod/codemirror-lang-j@0.2.1","maintainers":[{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"}],"homepage":"https://codincod.com/","dist":{"shasum":"7799b71150f13e6e84ed5cabc335de66f5d6c5d9","tarball":"https://registry.npmjs.org/@codincod/codemirror-lang-j/-/codemirror-lang-j-0.2.1.tgz","fileCount":14,"integrity":"sha512-TRnCejQtIzsJKrE5cpG/zG1//lmhBV+trDXotHAfZ4OStDbGAGmqXIZpe62PLr/QUn++MhYOAqMJoulYFvMHsg==","signatures":[{"sig":"MEUCIQDTyVtJmx6G+bTudo0fx3HWyW6mYc24COI3fsHu8UtTEwIgKAwyh5GkAVVyPBGwSAC8qisaTKf829GZAiazKpWt4nc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":85684},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{"import":"./dist/index.js","require":"./dist/index.cjs"},"gitHead":"0c0a7e52b5d8cd6a4043fd64aff4cbaecb6ede6b","scripts":{"gaps":"npm run build && node ../lezer-survey/src/cli.ts gaps --group parent","test":"npm run build && node --test \"test/*.test.ts\"","build":"rm -rf dist && lezer-generator src/j.grammar -o src/parser.js && cm-buildhelper src/j.ts","corpus":"npm run build && node ../lezer-survey/src/cli.ts measure --group parent","prepare":"npm run build","build-debug":"lezer-generator src/j.grammar --names -o src/parser.js && cm-buildhelper src/j.ts"},"_npmUser":{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"},"repository":{"url":"https://codeberg.org/reeven/codemirror-lang-j","type":"git"},"_npmVersion":"11.6.2","description":"J language support for the CodeMirror code editor","directories":{},"sideEffects":false,"_nodeVersion":"25.0.0","dependencies":{"@lezer/lr":"^1.0.0","@lezer/common":"^1.0.0","@lezer/highlight":"^1.0.0","@codemirror/language":"^6.0.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.0","@lezer/generator":"^1.7.0","@codemirror/state":"^6.7.1","@codemirror/buildhelper":"^1.0.2"},"_npmOperationalInternal":{"tmp":"tmp/codemirror-lang-j_0.2.1_1785970460763_0.295236209008217","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@codincod/codemirror-lang-j","version":"0.3.0","keywords":["editor","code","j","jsoftware","codemirror"],"author":{"name":"CodinCod","email":"hello@codincod.com"},"license":"MIT","_id":"@codincod/codemirror-lang-j@0.3.0","maintainers":[{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"}],"homepage":"https://codincod.com/","dist":{"shasum":"6409f0a55d89dfa6318340c58c26436c5bfe536b","tarball":"https://registry.npmjs.org/@codincod/codemirror-lang-j/-/codemirror-lang-j-0.3.0.tgz","fileCount":14,"integrity":"sha512-Ip312LaApq003bkuEGcU3emyC+81K6ByWojKXwSPq/Umbfyr/y9QuEC/3YEbh2cn6WiZJC7LBGClQZv2PZR0uA==","signatures":[{"sig":"MEQCIC66cDiG54NOf266EGYfKCU5sBJCdUsa5FpVWl/faKzpAiAHMNT0gz59oF31djWXUniStZRoUZb0VqHnrtlefILYiw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":87876},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{"import":"./dist/index.js","require":"./dist/index.cjs"},"gitHead":"79569b994ca6fbb2504fd2e955049261b043d948","scripts":{"fuzz":"npm run build && node ../lezer-survey/src/cli.ts fuzz","gaps":"npm run build && node ../lezer-survey/src/cli.ts gaps --group parent","test":"npm run build && node --test \"test/*.test.ts\"","build":"rm -rf dist && lezer-generator src/j.grammar -o src/parser.js && cm-buildhelper src/j.ts","measure":"npm run build && node ../lezer-survey/src/cli.ts measure --group parent","prepare":"npm run build","build-debug":"lezer-generator src/j.grammar --names -o src/parser.js && cm-buildhelper src/j.ts"},"_npmUser":{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"},"repository":{"url":"https://codeberg.org/reeven/codemirror-lang-j","type":"git"},"_npmVersion":"11.6.2","description":"J language support for the CodeMirror code editor","directories":{},"sideEffects":false,"_nodeVersion":"25.0.0","dependencies":{"@lezer/lr":"^1.0.0","@lezer/common":"^1.0.0","@lezer/highlight":"^1.0.0","@codemirror/state":"^6.7.1","@codemirror/language":"^6.0.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.0","@lezer/generator":"^1.7.0","@codemirror/buildhelper":"^1.0.2"},"_npmOperationalInternal":{"tmp":"tmp/codemirror-lang-j_0.3.0_1786659565502_0.9072264369023297","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@codincod/codemirror-lang-j","version":"0.4.0","description":"J language support for the CodeMirror code editor","keywords":["editor","code","j","jsoftware","codemirror"],"author":{"name":"CodinCod","email":"hello@codincod.com"},"license":"MIT","type":"module","main":"dist/index.cjs","exports":{"import":"./dist/index.js","require":"./dist/index.cjs"},"module":"dist/index.js","types":"dist/index.d.ts","sideEffects":false,"scripts":{"build":"rm -rf dist && lezer-generator src/j.grammar -o src/parser.js && cm-buildhelper src/j.ts","build-debug":"lezer-generator src/j.grammar --names -o src/parser.js && cm-buildhelper src/j.ts","prepare":"npm run build","test":"npm run build && node --test \"test/*.test.ts\"","measure":"npm run build && node ../lezer-survey/src/cli.ts measure --group parent","fuzz":"npm run build && node ../lezer-survey/src/cli.ts fuzz","gaps":"npm run build && node ../lezer-survey/src/cli.ts gaps --group parent"},"dependencies":{"@codemirror/language":"^6.0.0","@codemirror/state":"^6.7.1","@lezer/common":"^1.0.0","@lezer/highlight":"^1.0.0","@lezer/lr":"^1.0.0"},"devDependencies":{"@codemirror/buildhelper":"^1.0.2","@lezer/generator":"^1.7.0","typescript":"^5.6.0"},"homepage":"https://codincod.com/","repository":{"type":"git","url":"https://codeberg.org/reeven/codemirror-lang-j"},"gitHead":"79569b994ca6fbb2504fd2e955049261b043d948","_id":"@codincod/codemirror-lang-j@0.4.0","_nodeVersion":"25.0.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-TUfHP8IzxWHfz/Qp6b3hJDUr1lvVUnKKBA3HG6vmc30fnH5CsCsg9Pj3xkRqMrxaFCWI1A2S3gPbQ0bIxbgQKg==","shasum":"bed7f111e8c474b8cdb9ae1b1390ca768c30c32a","tarball":"https://registry.npmjs.org/@codincod/codemirror-lang-j/-/codemirror-lang-j-0.4.0.tgz","fileCount":14,"unpackedSize":87876,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCAzzJuOEHnWEn47egtqGJTGMMnaeeb+usUxDnXwWK6CgIgDSRef+kEnBBELDCa/e1etyniMC68zVAnJquwVRNWCDI="}]},"_npmUser":{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"},"directories":{},"maintainers":[{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/codemirror-lang-j_0.4.0_1786759671662_0.8062104642583316"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-05T20:25:52.927Z","modified":"2026-08-15T02:07:52.063Z","0.2.0":"2026-08-05T20:25:53.349Z","0.2.1":"2026-08-05T22:54:20.927Z","0.3.0":"2026-08-13T22:19:25.678Z","0.4.0":"2026-08-15T02:07:51.893Z"},"author":{"name":"CodinCod","email":"hello@codincod.com"},"license":"MIT","homepage":"https://codincod.com/","keywords":["editor","code","j","jsoftware","codemirror"],"repository":{"type":"git","url":"https://codeberg.org/reeven/codemirror-lang-j"},"description":"J language support for the CodeMirror code editor","maintainers":[{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"}],"readme":"# @codincod/codemirror-lang-j\n\nThis package implements [J](https://jsoftware.com) language support for the\n[CodeMirror](https://codemirror.net/) code editor: a\n[Lezer](https://lezer.codemirror.net/) grammar, highlighting, indentation and\nfolding.\n\nIt is a fork of [Jared Hughes's\n`codemirror-lang-j`](https://github.com/jared-hughes/codemirror-lang-j), which\nwas the only J grammar anybody had written, and which read a script as a flat\nrun of words. What a J script is made of is not words but sentences, and the\ntwo structures that decide where a sentence ends are the explicit definition,\nwhose body is every line under it down to a `)`, and the control words inside\nit. Neither was there. This fork adds both, follows the interpreter's own word\nformation, and gives every primitive the part of speech the interpreter's\ntables give it.\n\nWritten in part for [CodinCod](https://codincod.com/), a competitive coding\nplatform, where it colours the editor people solve puzzles in.\n\nThis code is released under an\n[MIT license](https://codeberg.org/reeven/codemirror-lang-j/src/branch/master/LICENSE).\n\n## Usage\n\n```javascript\nimport {EditorView, basicSetup} from \"codemirror\"\nimport {j} from \"@codincod/codemirror-lang-j\"\n\nconst view = new EditorView({\n  parent: document.body,\n  doc: `mean =: +/ % #\n\nstats =: verb define\n  NB. y is a list of numbers\n  if. 0 = # y do.\n    'no data' return.\n  end.\n  (mean y) , (<./ y) , (>./ y)\n)\n\nstats 2 3 5 7 11\n`,\n  extensions: [basicSetup, j()]\n})\n```\n\n## What it reads\n\nMeasured against 2836 files of J from CodinCod's language-guessing pool, which\nis Rosetta Code: **98.73%** parse with no error node, against **76.41%** under\nversion 0.1.1 of the package this forks. The tree is a tree rather than a list:\nthe mean byte of that corpus is placed 3.01 nodes deep across 57 kinds of node,\nwhere it was 1.21 deep across 12.\n\nHighlighting carries a tag on 92.89% of the text in 10 colours, the busiest of\nthem taking 33.83%, against 93.88% in 5 colours with 47.85% in the busiest.\nEvery character left untagged is one outside ASCII. In this corpus those are\nthe box-drawing characters of J's own display output, pasted under the code\nthat produced it, and they are output rather than code.\n\n## What a tokenizer has to settle\n\nMost of J is words, and the words are a state machine. Four things are not.\n\n* **The body of an explicit definition.** `f =: 3 : 0` and `f =: verb define`\n  are ordinary sentences: what makes the lines under them a body is that the\n  interpreter, on reaching a `:` whose right argument is `0`, reads lines until\n  one holds a `)` and nothing else. Nothing in the text of the head says so, so\n  the head sets a flag, the next newline spends it, and a count of open bodies\n  decides whether a lone `)` closes one or is an unmatched bracket.\n\n* **Which bodies are text.** `0 : 0` and `noun define` open a body that is not\n  J and must not be read as J: half the noun definitions in the corpus are\n  English prose, and prose has apostrophes in it. So the head is read as one\n  token that knows whether it opened a noun, and a noun body arrives as a\n  single string token.\n\n* **A numeral list is one word.** `2 3 5` is a single noun rather than three of\n  them, because the interpreter's lexer keeps a numeric field open across the\n  blanks that follow it. A colon closes the run, which is what makes `1:` one\n  word and `1:2` two, and `3 : 0` a definition where `3:0` is a constant verb\n  applied to zero.\n\n* **`{{`, `}}` and the inflection after them.** `{{` opens a direct definition\n  unless a `.` or `:` follows it, in which case it is a brace and an inflected\n  brace. A noun direct definition, `{{)n`, ends at the first `}}` on the line\n  it opened on, and after that only at a `}}` that begins a line, which is what\n  lets one hold the text of another.\n\n## Where the parts of speech come from\n\nA J primitive's part of speech is fixed: `+` is always a verb, `/` always an\nadverb, `&` always a conjunction. A name's is not known until it has been\nassigned, and can change afterwards. So the primitives are coloured apart from\none another and every name shares a colour, which is as much as anything can\nsay about a J script before it runs.\n\nThe lists are the interpreter's own. `jsrc/ws.c` spells every primitive as a\ncharacter and up to two inflections; `jsrc/t.c` files each under VERB, ADV or\nCONJ. A name a copula is about to give a meaning to is coloured as a\ndefinition, which is the one place a reader is told which names are the\nprogram's own.\n\n## What it does not do\n\n* **A definition head that is somebody's own word.** `f =: 3 : 0` is text the\n  parser can see. `is =: verb define` followed by `eating is` is not: the head\n  is now a name, and only running the program says so. Six files of the corpus\n  do this and none of them parse clean.\n\n* **Trains.** Whether `(+/ % #)` is a fork is decided by the parts of speech of\n  its three elements, and two of them are names whose meaning arrives at run\n  time. The parse says what the words are; it does not say what they compose\n  into.\n\n* **A verb body is J, but it is not checked.** The body of `13 : 0` is the same\n  sentences as any other, and nothing here knows that a tacit definition may\n  not contain a control word.\n\n## Development\n\n```bash\nnpm test                       # the parse specs and the editor tests\nnpm run corpus -- path/to/j    # error nodes over a directory of real J\nnpm run gaps -- path/to/j      # what is left, grouped by shape\n```\n\n`corpus` and `gaps` delegate to\n[lezer-survey](https://codeberg.org/reeven/lezer-survey), which has to be\ncloned beside this repository. No corpus ships here: Rosetta Code is under the\nGNU Free Documentation License 1.2 and not ours to redistribute.\n\n## API reference\n\n<dl>\n  <dt><code>j(): LanguageSupport</code></dt>\n  <dd>J language support.</dd>\n\n  <dt><code>jLanguage: LRLanguage</code></dt>\n  <dd>The language provider, for reaching the parser directly.</dd>\n</dl>\n","readmeFilename":"README.md"}