Developing language support plugin for language with preprocessor

Hi!

First of all I would like to express appreciation to all Intellij authors! It is a great development tool.

About the subject. I am developing a Vala support plugin for Intellij (source: https://github.com/gregorej/vala-intellij-plugin). So far I was able to harness the Grammar-Kit plugin (another great tool) to implement quite a bunch of features.Unfortunately I do not know how to implement support for Vala's preprocessor. Perhaps someone from this forum will be able to help me.

The preprocessor works the same way as in C but is much simpler and consists of only four directives (#if, #elif, #else, #endif). However, it looks like the preprocesor is more a separate language rather than an element of Vala language. And I am not sure if Grammar-Kit supports such case (multi-language file). One of potential solutions I am considering is just treat the directives as comments (completely ignored for parsing Vala grammar) and highlight them accordingly by annotator. Another is trying to implement the parser by hand (get rid of automatically generated by Grammar-Kit) but obviously this would take a huge amount of work that I did not plan at the beginning.


So the question is anyone knows if perhaps Grammar-Kit can handle such case? Maybe someone has knowledge how preprocessor is handled by C/C++ support? Or could I get some tips on how a proper parser should work (I was thinking keeping separate state for language and preprocessor itself)?

Thanks!

EDIT: link to related issue on github: https://github.com/gregorej/vala-intellij-plugin/issues/29

Please sign in to leave a comment.