3 ms·
This is what I was going to suggest. C is even pretty easy to parse - you can just take the ready ANTLR grammar and use it to generate a parser in whatever lang
by anon4 11y ago
This is what I was going to suggest. C is even pretty easy to parse - you can just take the ready ANTLR grammar and use it to generate a parser in whatever language you want.
Of course, he might go even one step further and specify the structs in some other language, then generate C source files from them, which would also allow you to easily generate consumers for that data format in other languages and now you're reinventing Cap'n Proto.
- DannyBee 11y agoErrr, he doesn't even need to use ANTLR, he can use clang, as a library. It can be linked into an app, has a nice AST, and matching abilities: http://clang.llvm.org/docs/LibASTMatchersReference.html http://clang.llvm.org/docs/LibASTMatchersReference.html Now he has the actual compiler doing the work for him.
- comex 11y agoSure, and now everyone who wants to compile your program has to install clang, which might take forever to compile for someone on a source-based distro, or require PITA manual work such as on Windows. Not to mention that you have to figure out how to configure your build system to (a) depend on clang and (b) build a helper program (including overriding the normal target architecture choice) - the difficulty of which depends on your setup, but if you follow the common practice of maintaining separate Visual Studio and CMake/etc. project files, in order to cater to IDE users while still being cross-platform, you have to do it twice! I hate build systems.