lezer-parser/lezer

Generating lezer grammar from tree-sitter grammar?

ubolonton opened this issue · 2 comments

Is there an automatic (or semi-automatic) way to convert a tree-sitter grammar into a lezer grammar, assuming it doesn't use dynamic precedence and external scanner?

The context is making a web editor for an in-house mini-language, where the parser and interpreter were already written based on tree-sitter.

No, unfortunately now. Grammar compatibility was a goal at the start, but as my generator and grammar definition drifted further from tree-sitter's approach, I gave that up. Manual translation should be relatively straightforward for most grammars, and there's only a handful of tree-sitter grammars in existence at the moment, which will hopefully all be ported in due time, so I'm not sure a tool like this would be worthwhile to write.

There's now a (crude) script at https://github.com/lezer-parser/import-tree-sitter . It won't give you a working grammar, in most cases, but can do most of the mechanical syntax rewriting for you.