{"_id":"@codincod/codemirror-lang-befunge","_rev":"2-fe037247a6ac25f62dc47c9f1fe9ffb8","name":"@codincod/codemirror-lang-befunge","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@codincod/codemirror-lang-befunge","version":"0.1.0","keywords":["befunge","code","codemirror","editor","esolang"],"author":{"name":"CodinCod","email":"hello@codincod.com"},"license":"MIT","_id":"@codincod/codemirror-lang-befunge@0.1.0","maintainers":[{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"}],"homepage":"https://codincod.com/","dist":{"shasum":"b4492246e2281f1644dd61655c48721ebedd1f06","tarball":"https://registry.npmjs.org/@codincod/codemirror-lang-befunge/-/codemirror-lang-befunge-0.1.0.tgz","fileCount":12,"integrity":"sha512-9uaBGvLWi2cVMuSWy2xRRt9CjAt0L534ybkc2lmFKEO6zevkZrRyz2NIG1sVbuJZ3aZnFnNJI/r5qjZ1B1vm8g==","signatures":[{"sig":"MEUCIEu0OhRAL0ydQgrpOskGIenqqPzZqmxGhiIdGu6APEXGAiEAiZ0pTXcx0rdpyHiZNpIBdhbAF7MBvtDptJT8tyqiDCc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19812},"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":"5fb3b09cd38c90d558d14317d08b9d72411fe306","scripts":{"gaps":"npm run build && node ../lezer-survey/src/cli.ts gaps --group top","test":"npm run build && node --test \"test/*.test.ts\"","build":"rm -rf dist && lezer-generator src/befunge.grammar -o src/parser.js && cm-buildhelper src/befunge.ts","corpus":"npm run build && node ../lezer-survey/src/cli.ts measure --group top","prepare":"npm run build","build-debug":"lezer-generator src/befunge.grammar --names -o src/parser.js && cm-buildhelper src/befunge.ts"},"_npmUser":{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"},"repository":{"url":"https://codeberg.org/reeven/codemirror-lang-befunge","type":"git"},"_npmVersion":"11.6.2","description":"Befunge 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-befunge_0.1.0_1786042871979_0.410482877561668","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@codincod/codemirror-lang-befunge","version":"0.2.0","description":"Befunge language support for the CodeMirror code editor","keywords":["befunge","code","codemirror","editor","esolang"],"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/befunge.grammar -o src/parser.js && cm-buildhelper src/befunge.ts","build-debug":"lezer-generator src/befunge.grammar --names -o src/parser.js && cm-buildhelper src/befunge.ts","prepare":"npm run build","test":"npm run build && node --test \"test/*.test.ts\"","corpus":"npm run build && node ../lezer-survey/src/cli.ts measure --group top","gaps":"npm run build && node ../lezer-survey/src/cli.ts gaps --group top"},"dependencies":{"@codemirror/language":"^6.0.0","@lezer/common":"^1.0.0","@lezer/highlight":"^1.0.0","@lezer/lr":"^1.0.0"},"devDependencies":{"@codemirror/buildhelper":"^1.0.2","@codemirror/state":"^6.7.1","@lezer/generator":"^1.7.0","typescript":"^5.6.0"},"homepage":"https://codincod.com/","repository":{"type":"git","url":"https://codeberg.org/reeven/codemirror-lang-befunge"},"gitHead":"e8c3d3d8e4e394a1e1af22c0fa7db5f02f3eccad","_id":"@codincod/codemirror-lang-befunge@0.2.0","_nodeVersion":"25.0.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-bpyFhho7qUb/bah1HjdyrtgfJDwKOOcxXX9yawuBFDXFk6qqhFWxQcoeYhmnALyIH/PXLtMUCAH8Kezc1BmCzQ==","shasum":"0014c7e4b0a275c0f098001976a2ab0993679360","tarball":"https://registry.npmjs.org/@codincod/codemirror-lang-befunge/-/codemirror-lang-befunge-0.2.0.tgz","fileCount":12,"unpackedSize":20886,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDB5G9MjuISnEQ6t2zH+1Uc+NBDIhiA7fSH+XnunAgdRQIgRDCugaaNmwN1VXaI+D4dP+qRnPpQkf/6m3vUcLC59xk="}]},"_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-befunge_0.2.0_1786044341405_0.5673539625067343"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-06T19:01:11.825Z","modified":"2026-08-06T19:25:41.688Z","0.1.0":"2026-08-06T19:01:12.174Z","0.2.0":"2026-08-06T19:25:41.529Z"},"author":{"name":"CodinCod","email":"hello@codincod.com"},"license":"MIT","homepage":"https://codincod.com/","keywords":["befunge","code","codemirror","editor","esolang"],"repository":{"type":"git","url":"https://codeberg.org/reeven/codemirror-lang-befunge"},"description":"Befunge language support for the CodeMirror code editor","maintainers":[{"name":"juicemitapfelndrin","email":"juicemitapfelndrin@gmail.com"}],"readme":"# @codincod/codemirror-lang-befunge\n\nThis package implements [Befunge-93](https://esolangs.org/wiki/Befunge)\nlanguage support for the [CodeMirror](https://codemirror.net/) code editor: a\n[Lezer](https://lezer.codemirror.net/) grammar and highlighting.\n\nNo CodeMirror grammar for Befunge existed anywhere before this one, in either\nthe Lezer generation or the CodeMirror 5 modes.\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-befunge/src/branch/master/LICENSE).\n\n## Usage\n\n```javascript\nimport {EditorView, basicSetup} from \"codemirror\"\nimport {befunge} from \"@codincod/codemirror-lang-befunge\"\n\nconst view = new EditorView({\n  parent: document.body,\n  doc: `>25*\"!dlroW ,olleH\":v\n                  v:,_@\n                  >  ^\n`,\n  extensions: [basicSetup, befunge()]\n})\n```\n\n## What it reads\n\nA Befunge program is a grid, and the instruction pointer walks it in whichever\ndirection the last arrow sent it. None of that is a tree, so the tree this\nbuilds is flat and its error count is worth nothing. Feed this parser a C\nprogram, a JSON document or a page of English and it returns a tree with no\nerror in it, because every character in a Befunge grid is either an\ninstruction or a cell holding something else, and there is no third answer it\ncould give. A package that quoted a clean percentage here would be quoting the\nfact that it never says no. Do not read one into the tables below; they are\nabout colour.\n\nOn CodinCod's language-guessing pool, 168 snippets of Befunge from Rosetta\nCode:\n\n| | Tagged | Colours | Busiest colour |\n| --- | --: | --: | --: |\n| this | 100.00% | 10 | 21.38% |\n| plain text, which is what it had | 0.00% | 0 | – |\n\nA fifth of the characters on the busiest colour is the least concentrated\nreading of any language in that pool. Befunge earns it: the language really\ndoes spend its characters on ten different jobs.\n\nThe tenth of them is the commentary. Sorted by how often each appears, the\ncharacters that are not instructions open `e t a o n i r s h d`, which is\nEnglish letter frequency: it is the prose people write in the half of the grid\nthe pointer never reaches. Befunge-93 has no comment syntax and does not need\none, because a cell holding a character the language never defined is inert.\nThose cells are the language's comments and they are coloured as comments.\n\n114 files of Befunge parse as well, from\n[Chris Pressey's own collection](https://github.com/catseye/Befunge-93) and\n[Mycology](https://github.com/Deewiant/Mycology), the Funge-98 conformance\nsuite.\n\n## What took the work\n\nThree decisions, and all three are about where a run of cells stops.\n\n* **A string stops at the end of its line.** A quote turns string mode on, and\n  the text between two of them is where every legible word in a Befunge\n  program lives. But a program that runs upwards can open a string on one row\n  and close it on another, and ten of the pool's nine hundred lines do exactly\n  that. Reading to the next quote wherever it is would paint the rest of the\n  program as a string. A quote with no partner on its line is left as one\n  ordinary cell, which is wrong about one character instead of wrong about\n  four hundred.\n* **A digit does not join the digit beside it.** `55` in Befunge is two pushes\n  and then a `+` makes ten. Grouping the run into one node would put a number\n  in the tree that the language never had.\n* **Befunge-93, not 98.** This is the decision the colour rests on. Funge-98\n  gives nearly every letter of the alphabet an instruction, so reading a\n  program as 98 lights up every word of the commentary people write in the\n  empty half of the grid. Reading it as 93 leaves the letters alone. The one\n  thing that costs is 98's `;…;` comment, which is read as an ordinary inert\n  cell; the pool holds 123 semicolons against 2404 cells of prose, and the\n  prose wins.\n\nThe exception nobody can remove: `v`, `<`, `>` and `^` are instructions and\nthey are also letters and punctuation people write. The `v` in \"over\" really\nwould send the pointer downward if it ever arrived there, so it is coloured\nlike the instruction it is.\n\n## Development\n\n```bash\nnpm install\nnpm test            # the parse specs and the colours\nnpm run corpus      # how much of a directory of Befunge parses clean\nnpm run gaps        # what it could not parse, grouped by shape\n```\n\n`corpus` and `gaps` delegate to\n[lezer-survey](https://codeberg.org/reeven/lezer-survey), which is expected to\nsit beside this checkout.\n","readmeFilename":"README.md"}