Generating lezer grammar from tree-sitter grammar? #9

Open
opened 2019-08-20 15:18:32 +02:00 by ubolonton · 2 comments
ubolonton commented 2019-08-20 15:18:32 +02:00 (Migrated from github.com)

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.

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 2019-09-05 14:28:33 +02:00 (Migrated from github.com)

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.

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 2020-10-28 11:36:53 +01:00 (Migrated from github.com)

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.

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.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lezer/lezer#9
No description provided.