breuleux / earl-grey

Programming language compiling to JavaScript
http://breuleux.github.io/earl-grey/
MIT License
467 stars 6 forks source link

Syntax Highlighting #6

Open davej opened 9 years ago

davej commented 9 years ago

Is there any syntax highlighting definitions available? Or is there a language that earl grey shares similar syntax with, so I can piggy-back on the syntax highlighting defined for that language?

breuleux commented 9 years ago

I made an earl-mode for emacs here. I also have a CodeMirror module here which is currently embedded in repple, the engine behind this page (I'll try to find the time to make a pull request to include it in CodeMirror, but I'd probably need to rewrite it in JS to get it accepted). Then I also have a mode for highlight.js here. So, yeah, there are some definitions around, but it's kind of messy and scattered.

EG is a bit tricky to highlight as well since it's not keyword-based: alice bob: charlie should highlight alice as a keyword, for example, because of its positioning.

I believe Python might work okay as an alternative mode since most control structures have the same syntax.

davej commented 9 years ago

Thanks, did a bit of trial and error and python works ok but I found CoffeeScript works best. I quickly added dot-strings and ;; comments so it works quite well now.

breuleux commented 9 years ago

Yeah, now that I think of it, CoffeeScript would work well too. What editor are you using? If you do end up tweaking a decent mode for EG, put it up somewhere and I'll link to it when I end up adding a section on editor support.

davej commented 9 years ago

Will do. Using Atom. Highlighting goes a bit horrible when using dash-er-ized variable names but I'll post it here if I get it working well.

breuleux commented 9 years ago

For those who are interested, I have written a guide on syntax highlighting for Earl Grey:

http://breuleux.github.io/earl-grey/contrib.html

Also, someone is developing an Atom mode here: https://github.com/MadcapJake/language-earl-grey. Probably best not to make more than one :)