🚧 This repository is currently under construction.
TinyPascal is actively being developed and rapidly evolving. Some features mentioned in this documentation may not yet be fully implemented, and both APIs and internal structure are subject to change as we continue to improve and expand the library.
Your contributions, feedback, and issue reports are highly valued and will help shape TinyPascal into the ultimate Pascal development platform!
TinyPascal is a lightweight, embeddable Pascal virtual machine designed for rapid language development, educational use, and embedded scripting. Built in Delphi with a clean modular architecture, TinyPascal uses a modern, case-sensitive variant of Pascal with UTF-8 strings and strong type safety.
TinyPascal features a stack-based virtual machine that executes bytecode generated from Pascal source code. This VM-based approach enables rapid development of language features, reliable execution, and easy embedding in host applications without the complexity of native code generation.
Inspired by the philosophy of simplicity and modularity, TinyPascal is designed to be small, fast, and highly extensible. Perfect for educational projects, embedded scripting, rapid prototyping, and language research.
-
Virtual Machine Execution
Stack-based VM with type-safe value operations and comprehensive error handling. -
Bytecode Generation
Compiles Pascal source to efficient bytecode with full disassembly support for debugging. -
Rapid Development
VM architecture enables quick addition of new language features without low-level complexity. -
Modern Pascal Syntax
Clean, case-sensitive Pascal with strong type safety and Unicode support. -
UTF-8 by Design
All strings are UTF-8 internally with seamless integration for text processing. -
Educational Focus
Perfect for learning compiler construction, language design, and virtual machine concepts. -
Embeddable Runtime
Self-contained VM with no external dependencies, ideal for embedding in applications.
TinyPascal supports a clean, modern type system:
Int
→ signed 64-bit integerUInt
→ unsigned 64-bit integerFloat
→ IEEE 754 double precisionString
→ UTF-8 encoded string with automatic memory managementPString
→ null-terminatedPUTF8Char
for C interopBoolean
→ true/false values
TinyPascal uses a sophisticated multi-layer architecture:
Frontend (Source → AST)
TinyPascal.Lexer
— Unicode-aware lexical analysisTinyPascal.Parser
— Recursive descent parser with AST generationTinyPascal.AST
— Abstract syntax tree nodes and visitor pattern
Backend (AST → Execution)
TinyPascal.Value
— Type-safe runtime value systemTinyPascal.Bytecode
— Instruction set and program structureTinyPascal.BytecodeGen
— AST to bytecode compilerTinyPascal.VM
— Stack-based virtual machine execution engine
Pipeline: Source Code → Lexer → Parser → AST → BytecodeGen → VM → Output
- 🎓 Education — Learn compiler design and virtual machines
- 🔬 Research — Experiment with language features rapidly
- 📝 Scripting — Embed Pascal scripting in applications
- 🚀 Prototyping — Quick language concept validation
- 🎮 Game Logic — Safe, sandboxed game scripting
- 📊 Data Processing — Mathematical computations with clean syntax
program ArithmeticDemo;
var
x: Int;
y: Int;
result: Int;
begin
x := 10;
y := 5;
result := x + y * 2; // Correct precedence: 10 + (5 * 2) = 20
WriteLn('Result: ', IntToStr(result));
end.
VM Output:
Result: 20
Generated Bytecode:
LOAD_CONST 10 → Stack: [10]
STORE_VAR x → x = 10
LOAD_CONST 5 → Stack: [5]
STORE_VAR y → y = 5
LOAD_VAR x → Stack: [10]
LOAD_VAR y → Stack: [10, 5]
LOAD_CONST 2 → Stack: [10, 5, 2]
MUL → Stack: [10, 10] // 5 * 2
ADD → Stack: [20] // 10 + 10
STORE_VAR result → result = 20
TinyPascal provides a complete Pascal subset designed for education, embedded scripting, and rapid development:
- Variable declarations with strong type safety
- Assignment statements and expressions
- Arithmetic expressions with proper operator precedence
- Conditional statements (
if...then...else
) - Comparison and logical operators (
>
,<
,=
,<>
,>=
,<=
,and
,or
,not
) - Loop constructs (
while
,for
) - User-defined procedures and functions
- Built-in functions (
WriteLn
,IntToStr
,StrToInt
, etc.) - Arrays and records
- String and numeric literals
- Boolean expressions and structured programming constructs
- 🐞 Report Issues: GitHub Issue Tracker
- 💬 Join the Community: Forum | Discord
- 📚 Learn Delphi: Learn Delphi
We welcome contributions to TinyPascal! 🚀
- 🐛 Report Bugs – Help improve stability and reliability
- ✨ Suggest Features – Share ideas for new language features
- 🔧 Submit Pull Requests – Add features or fix issues
- 📖 Improve Documentation – Help others learn and use TinyPascal
- 🎓 Create Examples – Showcase TinyPascal capabilities
TinyPascal is distributed under the BSD-3-Clause License, allowing redistribution and modification in both source and binary forms. See the LICENSE for details.
Your support keeps TinyPascal evolving! If you find this library useful, please consider sponsoring the project. Every contribution helps drive future enhancements and innovations.
- ⭐ Star the repo – Show your appreciation
- 📢 Share with your network – Spread the word
- 🐛 Report bugs – Help improve stability
- 🔧 Submit fixes – Contribute code improvements
- 💡 Suggest features – Help shape the language's future
- 🎓 Create tutorials – Help others learn TinyPascal
🚀 Every contribution makes a difference – thank you for being part of the journey!
TinyPascal — Modern Pascal ⚡, Virtual Machine 🤖, Rapid Development 🚀