CompilerX32 v0.1.0 ALPHA
Multi-Sprach Frontend — Unified IR — Native x86
A native x86-32 compiler for PowerBASIC-compatible BASIC with a complete multi-pass preprocessor (macros, equates, conditionals, MACROTEMP). Four syntax worlds — BASIC, C, ASM, PILOT — coexist in the same source file through a language-switching stack. No GCC. No LLVM. Just pure native machine code.
PBWin host compile: 1,118,208 bytes
Multi-pass preprocessor (6 modules)
Macro expansion with MACROTEMP
Built-in macros (__LINE__, __COUNTER__, ...)
C-preprocessor features (##, #, #undef)
635 PB11 keywords in lexer
Self-hosting: in progress
What Changed in This Update
Multi-Pass Preprocessor Complete
The Pass 2 EXPAND engine is fully implemented with a stability loop that repeats until the source no longer changes. Macros can reference macros defined later in the source. No artificial limits. No phase errors. Line continuation (_), equate expansion, built-in macros, and full MACROTEMP support.
Macro Engine with Parameters
Parameterized macros using \1 through \16 syntax. MACROTEMP generates unique names per expansion (e.g. tmp_MT0001). MACRO FUNCTION return expressions. Recursive protection prevents infinite expansion. Nested macro expansion resolves automatically.
Built-in Macros
Eight built-in macros always available: __LINE__, __FILE__, __DATE__, __TIME__, __COUNTER__ (monotonic counter), __CX32__ ("CompilerX32"), __CX32_VERSION__ ("0.1.0"), __PBWIN__ (1).
C-Preprocessor in #CCODE Blocks
Inside #CCODE / #CINLINE blocks: ## token pasting (foo##bar → foobar), # stringification (#x → "x"), #undef, #error, #pragma, #warning, #line.
Preprocessor Architecture
The stability loop ensures that macro definition order does not matter. A macro can reference another macro defined later in the source. If macro expansion reveals new #INCLUDE directives, the entire pipeline restarts to collect and expand the newly included content.
Multi-Language Example
BASIC variables are accessible by name in both C and ASM blocks. The language-switching stack tracks nested modes automatically. Mismatched closers produce errors showing the opening line.
Macro Expansion Example
Language Frontends
| Language | Switch Into | Switch Out | Features |
|---|---|---|---|
| PowerBASIC | (default) | #CCODE, #ASM, #PILOT | Full PB11 syntax + MODULE/ENDMODULE + dynamic UDT strings |
| C | #CCODE, #CINLINE, #CINCLUDE | #ENDC | C subset: switch, unions, function pointers, casts, ternary, ## and # |
| ASM | #ASM, !line | #ENDASM | x86 inline assembly with PB variable access, Lab_ prefix for labels |
| PILOT | #PILOT, #PCODE | #ENDPILOT | Educational language: T/A/M/Y/N/C/J/U/E commands |
Current Status
Architecture — From Source to PE32
Alpha Development
CompilerX32 is in active development. The complete multi-pass preprocessor is implemented and compiles cleanly with PBWin. The self-hosting compiler, multi-language test suite, and documentation will be available for download with the first public alpha release.