BPP+ Preprocessor¶
Modern toolchain for Commodore 64 BASIC v2 cross-development
BPP+ is a source-to-source compiler that transpiles enhanced BASIC syntax into standard Commodore BASIC v2.
It provides label-based control flow, lexical scoping, modular compilation, and comprehensive static analysis. Extended from the original BPP preprocessor by Henning Liebenau.
Part of the C*Base Larry Mod v3.1 development package.
Quick example¶
Source - Enhanced syntax with labels, scopes and statement chaining (.bpp)
goto main
screen: {
init:
poke 53280,0\
poke 53281,0\
return
}
screen: {
welcome:
print "{wht}hello bpp+"\
return
}
main:
gosub screen.init
gosub screen.welcome
Target - Standard BASIC v2 with line numbers (.bas)
1 goto 4
2 poke53280,0:poke53281,0:return
3 print"{wht}hello bpp+":return
4 gosub2
5 gosub3
Getting started¶
New to BPP+? Start here:
- Installation - Set up BPP+ and verify your environment
- Compilation pipeline - Learn the build workflow
Documentation structure¶
- Language Specification - Syntax, scopes, labels, directives, and PETSCII codes
- Advanced Topics - Symbol resolution, debugging, and validation
- Reference - API, build integration, and error handling
Related tools¶
- BPP+ Syntax Highlighting - Visual Studio Code extension with syntax highlighting and code snippets for Commodore 64 BASIC v2 and the BPP+ preprocessor.
GitHub repository¶
The BPP+ source code, issue tracking, and release packages are available on GitHub.
Technical overview¶
Problem domain¶
BASIC v2 (Commodore BASIC 2.0) is a line-number-based interpreted language with these limitations:
- No symbolic addressing: All control flow uses numeric line references
- No scoping: Single global namespace with no encapsulation
- No modularity: No include mechanism or separate compilation
- Limited readability: Minimal whitespace, single-statement-per-line constraint
- Fragile refactoring: Inserting lines requires manual renumbering of all references
Solution architecture¶
BPP+ implements a preprocessing layer that:
- Converts PETSCII characters to ASCII equivalents (£→\, ←→_, ↑→^)
- Tokenizes enhanced BASIC syntax with symbolic labels
- Parses hierarchical scope structures and include directives
- Resolves label references to line numbers via static analysis
- Validates symbol tables for duplicates and undefined references
- Transpiles to standard BASIC v2 with generated line numbers
- Maintains source mapping for debugging compiled programs
The output is standard BASIC v2 that can be tokenized by Petcat and executed on C64 hardware or emulators. For production use, compile the generated BASIC with the Blitz! compiler for 4x faster execution.
Design principles¶
- Zero runtime overhead: All preprocessing happens at compile time
- Lossless compilation: Transpiled code is functionally identical to hand-written line-numbered BASIC
- Source fidelity: Line mapping preserves debugging capability
- Unix philosophy: Composable tool that works with standard pipes and build systems
- Blitz compatibility: Full support for Blitz! compiler directives and optimizations