lezer-parser / lezer

Dev utils and issues for the Lezer core packages
33 stars 1 forks source link

Generating lezer grammar from tree-sitter grammar? #9

Open ubolonton opened 5 years ago

ubolonton commented 5 years ago

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.

marijnh commented 5 years ago

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.

marijnh commented 3 years ago

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.