highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.56k stars 3.58k forks source link

Explain how to go from lex + yacc to syntax #721

Closed wmertens closed 9 years ago

wmertens commented 9 years ago

if you already have a lexer and yacc/bison parser definition or perhaps a BNF definion, what would be the easiest way to make a highlightjs compatible grammar?

Case in point, I used https://github.com/NixOS/nixpkgs/issues/4952#issuecomment-65074661 as inspiration for https://github.com/wmertens/sublime-nix/blob/master/nix.YAML-tmLanguage which is what github can use for highlighting.

So anything that can make me use any of these data points to get a highlightjs compatible grammar would be great.

isagalaev commented 9 years ago

Unfortunately there's probably no way to do it more or less automatically because our parser is not very traditional (or even downright weird). The only way to "borrow" another highlighting implementation is to manually re-implementing it in highlight.js syntax. Sorry!

isagalaev commented 9 years ago

Closing the issue as there's probably nothing we can do anyway. Feel free to continue discussion if necessary!