BNFC / bnfc

BNF Converter
http://bnfc.digitalgrammars.com/
582 stars 161 forks source link

Generate syntax highlighters #422

Open masaeedu opened 2 years ago

masaeedu commented 2 years ago

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)?

andreasabel commented 2 years ago

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.

masaeedu commented 2 years ago

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.

andreasabel commented 2 years ago

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

ejconlon commented 1 year ago

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.