Skip to content

Commit 8a4d3d8

Browse files
committed
Update README.md
1 parent e5489f1 commit 8a4d3d8

File tree

1 file changed

+104
-41
lines changed

1 file changed

+104
-41
lines changed

README.md

Lines changed: 104 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,66 +6,126 @@
66
>
77
> 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.
88
>
9-
> Your contributions, feedback, and issue reports are highly valued and will help shape TinyPascal into the ultimate 2D game framework for Delphi!
9+
> Your contributions, feedback, and issue reports are highly valued and will help shape TinyPascal into the ultimate Pascal development platform!
1010
1111
# TinyPascal
1212

13-
**TinyPascal** is a lightweight, embeddable Pascal compiler designed to compile Pascal source code directly into Win64 PE format in memory, with immediate execution support. It is built in Delphi, follows a modular architecture, and uses a case-sensitive, Unicode-aware variant of Pascal with UTF-8 strings and clean interop with the Windows API and C ABI.
13+
**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.
1414

15-
TinyPascal generates x64 machine code without external dependencies, making it ideal for embedding and runtime code generation. It supports writing to memory and will also support .exe, .dll, and .lib output using the same backend.
15+
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.
1616

17-
Inspired by the design philosophy of TinyCC, TinyPascal is written in Delphi and designed to be small, fast, and modular. It generates x64 machine code directly, with no external dependencies, making it ideal for embedding in other applications or for use in runtime code generation scenarios.
17+
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.
1818

1919
## ✅ Key Features
2020

21-
- **Memory-first Compilation**
22-
Compiles Pascal source directly to memory as a valid Win64 PE executable.
21+
- **Virtual Machine Execution**
22+
Stack-based VM with type-safe value operations and comprehensive error handling.
2323

24-
- **Direct Execution**
25-
Supports executing compiled code in memory without writing to disk.
24+
- **Bytecode Generation**
25+
Compiles Pascal source to efficient bytecode with full disassembly support for debugging.
2626

27-
- **Delphi-Compatible Core**
28-
Uses a modern, case-sensitive Pascal syntax with strong compatibility for Delphi features.
27+
- **Rapid Development**
28+
VM architecture enables quick addition of new language features without low-level complexity.
2929

30-
- **Unicode by Design**
31-
All strings are UTF-8 internally, with runtime UTF-8 → UTF-16 conversion for Windows API compatibility.
30+
- **Modern Pascal Syntax**
31+
Clean, case-sensitive Pascal with strong type safety and Unicode support.
3232

33-
- **C ABI Interop**
34-
Clean interoperation with C libraries via well-defined basic types.
33+
- **UTF-8 by Design**
34+
All strings are UTF-8 internally with seamless integration for text processing.
3535

36-
- **Self-contained Runtime**
37-
Built-in x64 codegen and PE generation with no external toolchain required.
36+
- **Educational Focus**
37+
Perfect for learning compiler construction, language design, and virtual machine concepts.
38+
39+
- **Embeddable Runtime**
40+
Self-contained VM with no external dependencies, ideal for embedding in applications.
3841

3942
## 🔧 Type System
4043

41-
TinyPascal supports the following core types:
44+
TinyPascal supports a clean, modern type system:
4245

4346
- `Int` → signed 64-bit integer
44-
- `UInt` → unsigned 64-bit integer
45-
- `Float` → IEEE 754 double
46-
- `String` → UTF-8 encoded, ref-counted string
47+
- `UInt` → unsigned 64-bit integer
48+
- `Float` → IEEE 754 double precision
49+
- `String` → UTF-8 encoded string with automatic memory management
4750
- `PString` → null-terminated `PUTF8Char` for C interop
51+
- `Boolean` → true/false values
52+
53+
## 🧱 VM Architecture
54+
55+
TinyPascal uses a sophisticated multi-layer architecture:
4856

49-
## 🧱 Modular Architecture
57+
**Frontend (Source → AST)**
58+
- `TinyPascal.Lexer` — Unicode-aware lexical analysis
59+
- `TinyPascal.Parser` — Recursive descent parser with AST generation
60+
- `TinyPascal.AST` — Abstract syntax tree nodes and visitor pattern
5061

51-
TinyPascal is built using a clean modular design. Units follow a consistent naming convention:
62+
**Backend (AST → Execution)**
63+
- `TinyPascal.Value` — Type-safe runtime value system
64+
- `TinyPascal.Bytecode` — Instruction set and program structure
65+
- `TinyPascal.BytecodeGen` — AST to bytecode compiler
66+
- `TinyPascal.VM` — Stack-based virtual machine execution engine
5267

53-
- `TinyPascal.Lexer` — Lexical analyzer
54-
- `TinyPascal.Parser` — Syntax parsing and AST generation
55-
- `TinyPascal.CodeGen` — x64 code generation
56-
- `TinyPascal.PE` — Win64 PE format emitter
57-
- `TinyPascal.Runtime` — Core runtime helpers (e.g., UTF-8 to UTF-16 conversion)
58-
- `TinyPascal.Compiler` — Entry point and orchestration
68+
**Pipeline:** `Source Code → Lexer → Parser → AST → BytecodeGen → VM → Output`
69+
70+
## 🎯 Perfect For
71+
72+
- **🎓 Education** — Learn compiler design and virtual machines
73+
- **🔬 Research** — Experiment with language features rapidly
74+
- **📝 Scripting** — Embed Pascal scripting in applications
75+
- **🚀 Prototyping** — Quick language concept validation
76+
- **🎮 Game Logic** — Safe, sandboxed game scripting
77+
- **📊 Data Processing** — Mathematical computations with clean syntax
5978

6079
## 📜 Example
6180

6281
```pascal
63-
program HelloWorld;
82+
program ArithmeticDemo;
83+
var
84+
x: Int;
85+
y: Int;
86+
result: Int;
6487
begin
65-
WriteLn('Hello, World! 🚀');
88+
x := 10;
89+
y := 5;
90+
result := x + y * 2; // Correct precedence: 10 + (5 * 2) = 20
91+
WriteLn('Result: ', IntToStr(result));
6692
end.
67-
```
68-
93+
```
94+
95+
**VM Output:**
96+
```
97+
Result: 20
98+
```
99+
100+
**Generated Bytecode:**
101+
```
102+
LOAD_CONST 10 → Stack: [10]
103+
STORE_VAR x → x = 10
104+
LOAD_CONST 5 → Stack: [5]
105+
STORE_VAR y → y = 5
106+
LOAD_VAR x → Stack: [10]
107+
LOAD_VAR y → Stack: [10, 5]
108+
LOAD_CONST 2 → Stack: [10, 5, 2]
109+
MUL → Stack: [10, 10] // 5 * 2
110+
ADD → Stack: [20] // 10 + 10
111+
STORE_VAR result → result = 20
112+
```
113+
114+
## 🚀 Language Features
115+
116+
TinyPascal provides a complete Pascal subset designed for education, embedded scripting, and rapid development:
117+
118+
- Variable declarations with strong type safety
119+
- Assignment statements and expressions
120+
- Arithmetic expressions with proper operator precedence
121+
- Conditional statements (`if...then...else`)
122+
- Comparison and logical operators (`>`, `<`, `=`, `<>`, `>=`, `<=`, `and`, `or`, `not`)
123+
- Loop constructs (`while`, `for`)
124+
- User-defined procedures and functions
125+
- Built-in functions (`WriteLn`, `IntToStr`, `StrToInt`, etc.)
126+
- Arrays and records
127+
- String and numeric literals
128+
- Boolean expressions and structured programming constructs
69129

70130
## 💬 Support & Resources
71131

@@ -78,9 +138,11 @@ end.
78138
We welcome contributions to **TinyPascal**! 🚀
79139

80140
### 💡 Ways to Contribute:
81-
- 🐛 **Report Bugs** – Help improve `TinyPascal` by submitting issues.
82-
-**Suggest Features** – Share ideas to enhance its functionality.
83-
- 🔧 **Submit Pull Requests** – Improve the codebase and add features.
141+
- 🐛 **Report Bugs** – Help improve stability and reliability
142+
-**Suggest Features** – Share ideas for new language features
143+
- 🔧 **Submit Pull Requests** – Add features or fix issues
144+
- 📖 **Improve Documentation** – Help others learn and use TinyPascal
145+
- 🎓 **Create Examples** – Showcase TinyPascal capabilities
84146

85147
### 🏆 Contributors
86148

@@ -98,17 +160,18 @@ See the [LICENSE](https://github.com/tinyBigGAMES/TinyPascal?tab=BSD-3-Clause-1-
98160
Your support keeps **TinyPascal** evolving! If you find this library useful, please consider [sponsoring the project](https://github.com/sponsors/tinyBigGAMES). Every contribution helps drive future enhancements and innovations.
99161

100162
### Other ways to support:
101-
-**Star the repo** – Show your appreciation.
102-
- 📢 **Share with your network** – Spread the word.
103-
- 🐛 **Report bugs** – Help improve `TinyPascal`.
104-
- 🔧 **Submit fixes** – Contribute by fixing issues.
105-
- 💡 **Suggest features** – Help shape its future.
163+
-**Star the repo** – Show your appreciation
164+
- 📢 **Share with your network** – Spread the word
165+
- 🐛 **Report bugs** – Help improve stability
166+
- 🔧 **Submit fixes** – Contribute code improvements
167+
- 💡 **Suggest features** – Help shape the language's future
168+
- 🎓 **Create tutorials** – Help others learn TinyPascal
106169

107170
🚀 Every contribution makes a difference – thank you for being part of the journey!
108171

109172
---
110173

111-
**TinyPascal** — Pascal reborn for systems ⚙️, memory 🧠, and modern interop 🔗.
174+
**TinyPascal**Modern Pascal ⚡, Virtual Machine 🤖, Rapid Development 🚀
112175

113176
<p align="center">
114177
<img src="media/delphi.png" alt="Delphi">

0 commit comments

Comments
 (0)