How?
Just realized that could use a more direct link (will add), here is the relevant section from our post on pg_query:
https://pganalyze.com/blog/pg-query-2-0-postgres-query-parse...
The quick summary: Call libclang using the Ruby FFI bindings to parse C code into AST and locate function/symbol definitions, build a tree of dependent code, remove all code that is not referenced + add a few stubs where there is direct disk access.
How?