CHeaderSyntax

Extracts function prototypes from a header file using the vendored ANTLR grammars-v4 C11/C++14 grammars (see specification/cheader/support/NOTICE.md) -- not a full compiler: no macro expansion, no #include resolution, no type checking, and (for C++) no class-member or template extraction, only free/namespace-scope and extern "C" functions. If a header fails to parse under the grammar (e.g. heavy conditional-compilation/macro use this importer does not expand), parsing falls back to a plain-text regex scan of the same declarative shape the grammar looks for -- resilience against one malformed header, not a substitute for the grammar's own accuracy.

C requires knowing which identifiers are type names to resolve the classic Foo * bar; declaration-vs-expression ambiguity; since headers routinely use types defined in another, #include-only header, COMMON_TYPEDEFS plus every typedef ... name; line found in siblingHeaders are pre-registered before parsing (see SymbolTable.defineTypeName).

Functions

Link copied to clipboard
fun parse(file: File, language: CHeaderLanguage = CHeaderLanguage.C, siblingHeaders: List<File> = emptyList()): List<CHeaderFunction>
Generated with STIG