Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is it easy to parse C header files ? I assume you wouldn't have been able to do this if the language was say C++ / Java ?

Did you hand write a parser or does a library already exist ?



I don't know what GP did, but you don't need to write a complete parser. You can write a subset that can find the patterns you're interested in, which is much easier.


For many languages there are mature parsers out there that can be reused (e.g. Google's Closure compiler or babel for JavaScript, or the Soot framework for Java that also simplifies more advanced code analysis). In the worst case, it's sometimes possible to interface with the standard compiler for the language directly (for example, the TypeScript compiler provides TypeScript APIs for its parser/type checker/etc.). I believe for C++ for example, a Clang plugin (https://clang.llvm.org/docs/ClangPlugins.html) would have been a plausible way to implement something like this.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: