Question

Is there a tool that translates a PEG.js grammar to a TextMate grammar?

I am building my own language and would like to have syntax highlighting for it in my preferred editor, TextMate. The grammar of my language is built with PEG.js. According to the TextMate documentation for this use-case, I have to write the TextMate grammar in a form that is incompatible with PEG.js.

I started writing a new TextMate grammar, but I quickly noticed that it takes quite a while to translate the whole grammar, or even the subset relevant for an acceptable syntax highlighting. Since I am incredibly lazy and don't want to do all this tedious work, I thought about automating this task.

Can anyone give me any clues how to automate, or at least speed up, the generation of TextMate grammar from a PEG.js grammar?

Was it helpful?

Solution

Can anyone give me any clues how to automate, or at least speed up, the generation of TextMate grammar from a PEG.js grammar?

Use the following process:

  • Understand Regular Expressions
  • Understand Parsing Expression Grammars
  • Create a mapping table based on the similarities
  • Create functions based on the differences

References

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top