[HN Gopher] Lezer: A parsing system for CodeMirror, inspired by ...
___________________________________________________________________
Lezer: A parsing system for CodeMirror, inspired by Tree-sitter
Author : goranmoomin
Score : 71 points
Date : 2024-03-24 07:17 UTC (15 hours ago)
(HTM) web link (marijnhaverbeke.nl)
(TXT) w3m dump (marijnhaverbeke.nl)
| lewisjoe wrote:
| I'm always amazed by Marijn's brilliance (Author of Lezer,
| CodeMirror and the awesome ProseMirror toolkit)
|
| The level of depth he dives into to perfect his projects is
| insane. For example, lezer is a parser generator( which by itself
| is not a trivial feat with novel ideas like incremental
| computations applied to parsing) to power his mainstream project
| which is CodeMirror.
|
| Like this Prosemirror too has some insane levels of engineering
| underneath married with thoughtful architectural decisions.
|
| Apparently, a big fan of his works.
| AlexErrant wrote:
| He's incredibly responsive too. He just answered my question
| about an hour after it was asked... on a Sunday evening.
|
| Slightly off topic; is anyone aware of any Lezer grammar for
| regex? I've not been able to find any in the FOSS world. I
| suspect Regex101 has one, bit it's sadly closed source.
| lewisjoe wrote:
| Yeah, this happened to us too a couple of times. Once, we
| asked for a clarification and he took it as a sensible
| requirement, made the changes and took it to master in just
| over an evening.
|
| The next day we just had to update our package to the latest
| version and marvel at his response time.
| simonw wrote:
| He's also the author of a really great JavaScript book:
| https://eloquentjavascript.net/ - which he's been
| intermittently updating since 2007!
| RyanHamilton wrote:
| Massively agree. Code mirror 5 was excellent. Code mirror 6 was
| a big enough improvement to justify the upgrade. I've used it
| as part of 2 large projects and it's handled every expanding
| use case I've needed it to. It supports themes, sql,js and 2
| weeks ago I used its diff functionality. Really great library I
| can fully recommend.
| bpev wrote:
| I jusy used this recently for making Traindown syntax
| highlighting! It was pretty intuitive, even though I haven't done
| this kind of thing before!
|
| https://github.com/inro-digital/lang-traindown
|
| https://traindown.com/
|
| I did notice that it seems (rightfully) very focused on the exact
| usecase of syntax highlighting. Do people also use this kind of
| system for quickly building ways to parse data from arbitrary
| text syntaxes?
| timenova wrote:
| (2019)
| jitl wrote:
| On one hand, it's a nice framework. I customized the Typescript
| one a bunch for a lil side project and enjoyed myself. On the
| other hand, it would be great if CodeMirror could just work with
| Tree-sitter or similar. There's a lot of ecosystem around other
| parsing systems, and needing to figure out Lezer stuff is a big
| friction for adopting CodeMirror 6 for me. There are not a lot of
| language packages listed: https://codemirror.net/docs/community/
|
| There's a kind of importer thingy here but it doesn't work well
| for complex grammars: https://github.com/lezer-parser/import-
| tree-sitter
| AlexErrant wrote:
| > Unfortunately, tree-sitter is written in C, which is still
| awkward to run in the browser (and CodeMirrror targets non-WASM
| browsers). It also generates very hefty grammar files because
| it makes the size/speed trade-off in a different way than a web
| system would.
|
| I would be curious if there's been an effort to get tree-sitter
| working on the web.
| gushogg-blake wrote:
| Tree-sitter does run on the web. I got it working for my
| editor, but it did involve several days' worth of effort and
| getting into the weeds with emscripten. Details here -
| https://gushogg-blake.com/p/emscripten-web-modules/.
| jitl wrote:
| I learned from a google search that these days upstream tree-
| sitter provides WebAssembly bindings.
|
| Source: https://github.com/tree-sitter/tree-
| sitter/tree/master/lib/b...
|
| NPM: https://www.npmjs.com/package/web-tree-sitter
|
| Download from the latest Github release: js file
| (https://github.com/tree-sitter/tree-
| sitter/releases/download...) and wasm file
| (https://github.com/tree-sitter/tree-
| sitter/releases/download...)
|
| It's great to see upstream maintaining the bindings. I
| maintain a Typescript/Empscripten/WebAssembtly binding for
| quickjs and it's more involved than I would like.
| timhh wrote:
| I attempted to use this but was disheartened but the fact that it
| doesn't statically type node names. Tree Sitter doesn't either
| but it has much more of an excuse given that it targets C.
|
| https://github.com/lezer-parser/lezer/issues/8
|
| The dev seems mildly hostile to outside involvement too, so I
| moved on. These days I use Chumsky which is Rust rather than
| Typescript, but also way more awesome, if you can deal with the
| often incomprehensible compilation errors at least!
|
| https://github.com/zesterer/chumsky
___________________________________________________________________
(page generated 2024-03-24 23:00 UTC)