Show HN: A preprocessor, similar to a C preprocessor, for arbitrary text inputs
In the scope of the sqlite project&#x27;s new JavaScript builds, we need a way to conditionally include, or not, sections of JavaScript code depending on whether the build is for an ES6 module (ESM) or not. Though JS&#x27;s own introspection is normally suitable for determining such things at runtime, the ESM designers chose to include keywords which are not legal to reference from non-ESM code, which rules out a single-source-file solution for ESM and vanilla JS code. Attempts at using a C preprocessor (CPP) to achieve that unveiled several quirks which make CPP ill-suited for processing JavaScript code.<p>Necessity being the mother of invention, c-pp, the C-Minus Preprocessor, was born as a weekend side-project. It is conceptually and syntactically like a C preprocessor but:<p>- Has only a subset of CPP&#x27;s features.<p>- Is suitable for use with essentially arbitrary text inputs.<p>- Has a configurable keyword prefix rather than being hard-coded to &quot;#&quot; like CPP is.<p>Specifically, it supports a feature subset useful to us in the sqlite project plus a few other low-hanging fruits which just seemed relevant at the time.<p>c-pp is itself implemented in a single file of portable, dependency-free C. It &quot;should&quot; build with any C89-capable compiler.