bnfc icon indicating copy to clipboard operation
bnfc copied to clipboard

Generate syntax highlighters

Open masaeedu opened this issue 2 years ago • 4 comments

Hi there. I was wondering if it would be considered part of the scope of this project to deal with syntax highlighting in a language agnostic way. For example, would it make sense to generate a TextMate grammar (or something akin to it)?

masaeedu avatar Apr 25 '22 05:04 masaeedu

There is the pygments backend to that end. Other backends would be thinkable. Caveat: there is a reimplementation of BNFC in progress, so extending the present implementation by a new backend would then need a port to the new implementation. If you are very keen to get to work, I could give you access to the new repo so you can make a proposal.

andreasabel avatar Apr 25 '22 06:04 andreasabel

Hi @andreasabel. Interesting, does the reimplementation significantly depart from or augment the LBNF language as specified in the docs?

I was thinking about this a bit more today and realized you would need some additional metadata to ascribe syntactic categories to productions.

masaeedu avatar Apr 27 '22 20:04 masaeedu

The reimplementation aims at being conservative in the first step, meaning, backwards-compatible. So the LBNF language stays the same.

andreasabel avatar Apr 28 '22 10:04 andreasabel

I was also curious about this in the context of generating VSCode grammars (which use TextMate grammars, as detailed here). Though if you are planning on writing an LSP, you may be able to have your LSP process emit semantic highlighting information.

ejconlon avatar Mar 15 '23 01:03 ejconlon