Invited talk: Parsing Unpreprocessed C Code - The TypeChef Experience
In this talk I will give an overview of our work on parsing and analyzing unpreprocessed C code. In addition, I will show how the same technology can be applied in completely different contexts, such as HTML while it is still embedded in PHP code.
Typically any parsing or analysis of C code happens either after running the C preprocessor (resolving macros, includes, and ifdefs) or using unsound heuristics-based parsers. The C preprocessor, based on token rewriting before parsing, is a major hurdle in developing many forms of tool support for C code. Even though developers are aware of the potential problems, real-world C code contains lots of difficult to parse preprocessor directives.
In the TypeChef project, we have developed variability-aware parsers (based on parser combinators) that can soundly parse C code in all configurations, including all branches of ifdef directions, without resorting to a brute-force strategy. I will show how this lead to the ability to build a type system that can check all compile-time configurations of the Linux kernel, a refactoring engine that can soundly rewrite C code, and even developer support for PHP code.