Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating lezer grammar from tree-sitter grammar? #9

Open
ubolonton opened this issue Aug 20, 2019 · 2 comments
Open

Generating lezer grammar from tree-sitter grammar? #9

ubolonton opened this issue Aug 20, 2019 · 2 comments

Comments

@ubolonton
Copy link

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
Copy link
Contributor

marijnh commented Sep 5, 2019

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
Copy link
Contributor

marijnh commented Oct 28, 2020

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.

@marijnh marijnh transferred this issue from lezer-parser/lr Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants