NitroPascal v0.1.0 - First Public Release
Overview
Complete implementation of a modern Pascal-to-C++ transpiler with comprehensive
language support and 376 passing tests across all major language features.
Core Architecture
Lexer (NitroPascal.Lexer.pas)
- Full tokenization of Pascal source code
- Support for all literals: integer, float, string, char, boolean
- All operators: arithmetic, comparison, logical, bitwise
- Comment handling: line (//) and block (* *) comments
- Preprocessor directives: #define, #ifdef, #ifndef, #else, #endif
- Compiler directives: $optimize, $target, $exceptions, etc.
Parser (NitroPascal.Parser.pas)
- Complete AST generation for all language constructs
- Program, Module, and Library compilation units
- Full expression parsing with proper precedence
- All statement types (if, while, for, repeat, case, etc.)
- Conditional compilation with symbol tracking
- Error recovery and detailed error reporting
Code Generator (NitroPascal.CodeGen.pas)
- Transpilation to modern, idiomatic C++ code
- Smart type mapping (string → std::string, arrays → std::array)
- Support for all parameter passing modes (value, const, var, out)
- Visibility control (public/private for modules)
- Header (.h) and implementation (.cpp) file generation
Language Features
Type System (Complete)
✅ Primitive types: int, uint, int64, uint64, int16, uint16, byte, double,
float, bool, char, string, pointer
✅ Arrays: Fixed-size, multi-dimensional (1D, 2D, 3D+)
✅ Records: Structs with field access, nested records
✅ Pointers: Declaration, dereferencing, arithmetic, function pointers
✅ Enumerations: Integer-based enums
✅ Subrange types: Type aliases with range documentation
✅ Function types: Function pointer type declarations
✅ Type aliases: Custom type definitions
Control Flow (Complete)
✅ if/then/else statements
✅ while loops
✅ for/to and for/downto loops
✅ repeat/until loops
✅ case statements with multiple values and ranges
✅ break and continue
✅ Nested control structures
Routines (Complete)
✅ Procedures and functions
✅ Parameter modes: value, const, var, out
✅ Variadic parameters (...)
✅ Local variables and nested scopes
✅ Return values
✅ Function overloading preparation
Operators (Complete)
✅ Arithmetic: +, -, *, /, div, mod
✅ Comparison: =, <>, <, >, <=, >=
✅ Logical: and, or, not, xor
✅ Bitwise: and, or, xor, not, shl, shr
✅ Pointer: ^, @
✅ String concatenation: +
External Interop (Complete)
✅ C header imports: extern <header.h>
✅ DLL imports: extern dll "name.dll" [stdcall|cdecl|fastcall]
✅ Variadic function support
✅ Type mapping for C interop
Preprocessor (Complete)
✅ Conditional compilation: #ifdef, #ifndef, #else, #endif
✅ Symbol definition: #define, #undef
✅ Nested conditionals
✅ Parser-integrated (zero runtime overhead)
Compiler Directives (Complete)
✅ $optimize: debug, release_safe, release_small, release_fast
✅ $target: Platform targeting (x86_64-windows, etc.)
✅ $exceptions: Enable/disable C++ exceptions
✅ $strip_symbols: Symbol table stripping
✅ $module_path, $include_path, $library_path
✅ $link_library: Link external libraries
Build System
✅ Zig build system integration
✅ Multi-platform support (Windows, Linux, macOS)
✅ Automatic build.zig generation
✅ C++ standard library linking
Test Coverage
376 tests - All passing across:
- Lexer Tests (10): Tokenization and scanning
- Parser Tests (12): AST construction
- CodeGen Tests (14): Basic code generation
- String Tests (36): String operations, methods, parameters
- Number Tests (51): Integer/float arithmetic, bitwise, precedence
- Array Tests (36): Indexing, multi-dim, parameters
- Record Tests (36): Fields, nesting, operations
- Pointer Tests (43): Address-of, dereference, arithmetic
- Control Flow Tests (34): All loop types, case statements
- Type Tests (40): Type system features
- Parameter Tests (44): All parameter modes
- Conditional Compilation Tests (20): Preprocessor directives
Project Structure
NitroPascal/
├── src/
│ ├── NitroPascal.Types.pas # AST node definitions
│ ├── NitroPascal.Lexer.pas # Lexical analysis
│ ├── NitroPascal.Parser.pas # Syntax analysis & AST
│ ├── NitroPascal.CodeGen.pas # C++ code generation
│ ├── NitroPascal.Compiler.pas # Main compiler orchestration
│ ├── NitroPascal.Symbols.pas # Symbol table management
│ ├── NitroPascal.Resolver.pas # Name resolution
│ └── NitroPascal.Utils.pas # Utilities
├── examples/
│ └── testbed/ # 376-test suite
├── docs/
│ └── MANUAL.md # Complete language reference
└── bin/ # Compiled executables
Documentation
- Complete language manual (MANUAL.md)
- 376 example test cases
- API documentation in source
- README with quick start guide
Known Limitations
- No dynamic arrays (fixed-size only)
- No classes with inheritance (records only)
- No generics
- No interfaces
- No inline assembly
File Integrity
Files are signed with minisign using this public key:
RWTqBYfsUOCQscb6ZeknLC0On3cvWCVzMzlHamtgXNaDOO4bNs3WCSkV