Skip to content

Releases: tinyBigGAMES/NitroPascal

NitroPascal v0.2.0

13 Oct 00:13
Compare
Choose a tag to compare

🎯 NitroPascal v0.2.0: The RTL Wrapping Breakthrough

TL;DR

NitroPascal can now compile Delphi syntax directly to high-performance C++ through our innovative Runtime Library (RTL) wrapping strategy. Write pure Delphi, get native C++ performance.

💡 The Breakthrough: RTL Wrapping Architecture

Instead of complex code generation that attempts to map Delphi semantics to C++, we've taken a revolutionary approach: wrap every Delphi construct in a C++ runtime library (under the np:: namespace).

What this means:

  • Delphi's for loopsnp::ForLoop() - handles inclusive ranges perfectly
  • Delphi's div/modnp::Div()/np::Mod() - exact Delphi semantics
  • Delphi's Stringnp::String - UTF-16 with 1-based indexing, just like Delphi
  • Delphi's WriteLnnp::WriteLn() - variadic templates, handles any types

The result? The code generator is now trivial - just simple syntax translation. All complexity lives in the RTL, which is written once, tested once, and reused forever.

🎉 What's New in v0.2.0

This release establishes the foundation with comprehensive Delphi language support:

Type System

  • Complete scalar types: Integer, Boolean, Char, Double, Single, Byte, Word, Cardinal, Int64
  • Complex types: String (UTF-16), Pointer, Record, Array (static & dynamic), Set, Enum
  • Full pointer semantics with New/Dispose

Operators & Expressions

  • Arithmetic: +, -, *, /, div, mod
  • Comparison: =, <>, <, >, <=, >=
  • Logical: and, or, xor, not
  • Bitwise: shl, shr, and, or, xor
  • Set operations: in, +, -, *

Control Flow

  • Conditional: if..then..else, case..of
  • Loops: for..to..do, for..downto..do, while..do, repeat..until
  • All with proper Delphi semantics (inclusive ranges, evaluated-once bounds, etc.)

Functions & Procedures

  • Full function/procedure declarations
  • Parameter modes: const, var, out
  • Result variable handling
  • Forward declarations

I/O & System Functions

  • Console I/O: Write, WriteLn, Read, ReadLn
  • Memory management: New, Dispose, GetMem, FreeMem
  • String functions: Length, Copy, Pos, IntToStr, StrToInt

🔥 Why This Architecture Matters

By wrapping Delphi semantics in C++, we achieve:

  • True Delphi compatibility - not approximations or "close enough"
  • C-level performance - via Zig's LLVM optimization pipeline
  • 🌐 Cross-platform everywhere - Windows, Linux, macOS, embedded, WebAssembly
  • 🎯 Simple, maintainable compiler - complexity lives in RTL, not in code generation
  • 🔧 Debuggable output - generated C++ is readable and understandable

Write pure Delphi → Get native C++ performance. No compromises.

📚 Documentation

Want to see what's working RIGHT NOW?

  • COVERAGE.md - Complete feature checklist: [x] implemented vs [ ] planned
  • DESIGN.md - Deep dive into the RTL wrapping architecture
  • MANUAL.md - User guide and getting started

Check the docs to see exactly what Delphi syntax you can use today!

🚀 Getting Started

# Clone the repository
git clone https://github.com/tinyBigGAMES/NitroPascal
cd NitroPascal

# Compile your first Delphi program
nitropascal hello.pas

Example Delphi program:

program Hello;
var
  i: Integer;
begin
  for i := 1 to 10 do
    WriteLn('Hello from NitroPascal! Count: ', i);
end.

Compiles to optimized native code via C++ → LLVM → machine code.

🌐 Community

🔮 What's Next?

Each update expands the RTL with more Delphi semantics!

What Delphi features do YOU want to see in the next release? Let us know in the discussions!


The future of Pascal is here, and it's wrapped in a beautiful C++ runtime library. 🎁


File Integrity

Files are signed with minisign using this public key:
RWTqBYfsUOCQscb6ZeknLC0On3cvWCVzMzlHamtgXNaDOO4bNs3WCSkV

NitroPascal v0.1.0

07 Oct 20:19
Compare
Choose a tag to compare

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