I'm looking for a syntax in Sublime Text that highlights my Flex and Bison files (or lex/yacc) in a way that makes them readable... Sublime Text automatically chooses Lisp for Flex files, but that doesn't do the trick all that well. Any suggestions to try another syntax? Or is there a plugin somewhere that's useful (haven't found anything so far)?.
-
This guy, https://github.com/Jackneill/sublime-text-packages/tree/master/Packages, seems to have packages for both Bison and Flex. I have not tried them myself. – Wolf Oct 02 '13 at 13:30
-
The Flex is actually Adobe Flex, but Bison may be interesting to add. Thx. – Lieven Cardoen Oct 02 '13 at 14:01
5 Answers
I haven't found one built specifically for Sublime, but I've found one for TextMate, which Sublime is compatible with.
Therefore, for Flex highlight, all you need to do is git clone the TextMate's syntax files to your Packages folder.
Regarding Bison, I've found a syntax for TextMate, but it didn't work very well for me. The one Vaklarados posted worked nicer with my source files.

- 3,301
- 3
- 20
- 20
-
That plugin is exactly what I need! Thank you! However the the one Vlakarados posted is not yacc-bison. Still on the lookout for that. May end up writing one soon. – nevelis Nov 28 '13 at 22:17
-
Hello, I `git clone`d this repository in `C:\Program Files\Sublime Text 3\Packages\` and ST3 still doesn't know the flex syntax, even after a restart. What did I do wrong? – Hey May 24 '18 at 07:40
-
1@Arno I had the same problem. One of the files in the git repository has a `:` in it, so it doesn't clone correctly on Windows. You'll have to download the `Syntaxes/Lex:Flex.tmLanguage` file manually (and remove the `:` from the name) and put it in the folder, and it should work then. – Entity Jul 10 '18 at 19:31
The one thalesmello posted works well for Flex. For Bison, I've found this one - it's pretty minimal but it's a start:
https://github.com/Jackneill/sublime-text-packages/tree/master/Packages/Bison
Please let me know if you find something better!
edit: I take it back - the Flex one highlights start states & C/C++ code in pink and it looks quite terrible. For basic lex files it looks okay, but it needs work. :)
edit again: as sonu kumar pointed out, the project has been removed from github. For an alternative you could try the built-in OCamlyacc highlighting (pretty decent), or another alternative: https://bitbucket.org/artyom_smirnov/sublime-text-bison-highlighter (needs some work)
I'm using Sublime a lot more & do a fair bit of work in Flex/Bison, so I might get around to writing one... one day. :D

- 736
- 6
- 17
-
1Ahh balls, looks like the project was deleted... :( I'll have to dig around for a clone. – nevelis Jan 28 '15 at 03:25
-
1@sonukumar Can't find a clone - the built-in OCamlyacc one looks pretty decent though, and there's another one here: https://bitbucket.org/artyom_smirnov/sublime-text-bison-highlighter/src/2c46905909f4ae77ba02504122dffb3052ec8171/Bison.tmLanguage?at=master but it's not as good as the OCamlyacc one. – nevelis Jan 28 '15 at 03:37
-
-
Do we have any solution for lex/flex on windows? Installation works on linux system (Ubuntu) but failed on windows with error `file name invalid` . – sonus21 Jan 31 '15 at 06:07
Indeed there are:
It's not so hard to write your own packages for non-typical languages. Just browse the source of other language syntax files and copy-paste-change what you need. Also raises your regex skills to a better level.

- 12,077
- 6
- 55
- 78
-
7I guess I'll have to write them my own as Flex is Adobe Flex and Bison is Binary JSON... – Lieven Cardoen Oct 02 '13 at 14:24
-
Sorry, looks like I didn't understand you right on this one, I was pretty sure after you replied to the comment above you were actually talking about Adobe :) – Sergey Telshevsky Oct 02 '13 at 14:39
-
-
Install Package Control for Sublime Text.
I found this there: https://sublime.wbond.net/packages/Bison
Do try it, I found it good enough for my use.

- 1,252
- 4
- 18
- 38
https://github.com/m-happy/Packages/blob/master/Flex/Flex.sublime-syntax
You can add this file to your sublime package.

- 169
- 1
- 10