Convert Yacc grammar to BNF/Flex


I am trying to learn IntelliJ IDEA plugin development and want to add one for Zig language. I do not have much experience with parsers/lexers development, so I am looking for your help, community.

Zig language defines its grammar here I believe it is a YACC grammar. Now I want to adopt this grammar for my IntelliJ plugin. This will help me to minimize my efforts, avoid redevelopment and make future updates from upstream easier.

Thus my questions are:

  • What is the best way to reuse this upstream grammar file for my plugin?
  • Are there any tools to convert YACC to BNF/Flex?
  • Any examples/resources on how to deal with YACC grammar in an IntelliJ Plugin project?

Thank you for your help.

1 comment

Hi Antony,

I don't know any solutions that adapt Yacc grammar to the IntelliJ Platform infrastructure.

There is support for ANTLR grammars:, but I don't think following a similar approach is worth the effort in your case, if you need to implement a single language.

I'm not familiar with Yacc, but skimming through the Zig grammar, it doesn't look like a complex task to convert it to BNF, so I suggest converting it manually. It also seems to be pretty stable grammar.

You can also ask on our community Slack:

Maybe someone else had experience with solving a similar problem.


Please sign in to leave a comment.