no-context / moo

Optimised tokenizer/lexer generator! 🐄 Uses /y for performance. Moo.
BSD 3-Clause "New" or "Revised" License
824 stars 66 forks source link

Random idea: plugin to serialize moo lexers to syntax plugins for various editors #94

Open kach opened 6 years ago

kach commented 6 years ago

I did some looking and couldn't find a tool that generated syntax highlighting plugins for Emacs/Vim/TextMate/CodeMirror/Atom/your-favorite-editor-here. It would be neat if you could take an existing moo lexer, maybe add some config, and suddenly get plugins for a bunch of editors.

Based on some quick reading, most editors have a similar format for specifying syntaxes. But there are a few gotchas that might make this infeasible (e.g. Vim doesn't support states as far as I can tell, whereas Emacs has a messy special-cased configuration for multiline comments/strings).

prodrammer commented 5 years ago

I found this recently: https://eeyo.io/iro/

mattfysh commented 2 years ago

I'm going through this exercise now, manually converting a moo-based lexer into a textmate grammar - and it does not appear that this is something you could automate. The textmate grammars don't just tokenize, but they also need the grammar rules e.g. your mylang.ne file if using nearley.js

Take a look at this javascript textmate grammar for vscode 😳 https://github.com/microsoft/vscode-textmate/blob/main/benchmark/JavaScript.tmLanguage.json