Skip to content

Commit c3ff7d0

Browse files
committed
PHASE 1 COMPLETE: SSA Layer
1 parent b222f21 commit c3ff7d0

36 files changed

+15933
-10980
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,9 @@ zip_latest_commit.cmd
9292
CPascal-main.zip
9393
/bin/output
9494
bin/view.txt
95+
src/TODO.md
96+
src/SESSION.md
97+
src/NOTES.md
98+
src/LOAD.md
99+
/bin/temp
100+
src/CPASCAL-BNF.md

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ project/
232232

233233
### 🏆 **Contributors**
234234

235-
<a href="https://github.com/tinyBigGAMES/JetVM/graphs/contributors">
236-
<img src="https://contrib.rocks/image?repo=tinyBigGAMES/CPascal&max=500&columns=20&anon=1" />
235+
<a href="https://github.com/tinyBigGAMES/CPascal/graphs/contributors">
236+
<img src="https://contrib.rocks/image?repo=tinyBigGAMES/CPascal&max=100&columns=12&anon=0" />
237237
</a>
238238

239239
*Join our growing community of developers building the future of Pascal development\!*

docs/CPASCAL-BNF.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@
2020
2121
<module_header> ::= "module" <identifier> ";"
2222
23-
<import_clause> ::= "import" <identifier_list> ";"
23+
<import_clause> ::= "import" <qualified_identifier_list> ";"
24+
25+
<qualified_identifier_list> ::= <qualified_identifier> ("," <qualified_identifier>)*
26+
27+
<qualified_identifier> ::= <identifier> ("." <identifier>)*
2428
2529
<identifier_list> ::= <identifier> ("," <identifier>)*
2630
2731
<exports_clause> ::= "exports" <export_list> ";"
2832
29-
<export_list> ::= <identifier> ("," <identifier>)*
33+
<export_list> ::= <qualified_identifier> ("," <qualified_identifier>)*
3034
```
3135

3236
## Compiler Directives
@@ -113,6 +117,7 @@
113117
| "public"? <external_function>
114118
| "public"? <inline_function>
115119
| "public"? <varargs_function>
120+
| "public"? <external_varargs_function>
116121
117122
<function_header> ::= "function" <identifier> "(" <parameter_list>? ")" ":" <type_definition>
118123
| "procedure" <identifier> "(" <parameter_list>? ")"
@@ -135,6 +140,11 @@
135140
136141
<varargs_function> ::= "function" <identifier> "(" <parameter_list> "," "..." ")" ":" <type_definition> <calling_convention>? ";"
137142
| "procedure" <identifier> "(" <parameter_list> "," "..." ")" <calling_convention>? ";"
143+
144+
<external_varargs_function> ::= "function" <identifier> "(" <parameter_list> "," "..." ")" ":" <type_definition> <calling_convention>? "external" <string>? ";"
145+
| "function" <identifier> "(" <parameter_list> "," "..." ")" ":" <type_definition> "external" <string>? <calling_convention>? ";"
146+
| "procedure" <identifier> "(" <parameter_list> "," "..." ")" <calling_convention>? "external" <string>? ";"
147+
| "procedure" <identifier> "(" <parameter_list> "," "..." ")" "external" <string>? <calling_convention>? ";"
138148
```
139149

140150
## Statements
@@ -384,4 +394,21 @@ PChar char* 8/4 8/4
384394
Records map to C structs with identical layout and alignment.
385395
Arrays map to C arrays with identical memory layout.
386396
Function pointers use C calling conventions by default.
387-
```
397+
```
398+
399+
## 🆕 External VarArgs Functions (Added for Phase 1A)
400+
401+
The `<external_varargs_function>` rule enables essential C library integration by combining external function declarations with variadic arguments. This allows direct integration with functions like `printf`, `scanf`, and other C runtime functions that require variable argument lists.
402+
403+
**Examples:**
404+
```pascal
405+
// Standard C runtime functions
406+
function printf(format: PChar, ...): Int32 cdecl external 'msvcrt.dll';
407+
procedure fprintf(stream: Pointer; format: PChar, ...): cdecl external 'msvcrt.dll';
408+
function scanf(format: PChar, ...): Int32 cdecl external 'msvcrt.dll';
409+
410+
// Custom varargs functions from external libraries
411+
function MyLogger(level: Int32; format: PChar, ...): Boolean stdcall external 'mylib.dll';
412+
```
413+
414+
This addition maintains full BNF compliance while enabling the essential external function capabilities required for real-world C library integration.

examples/testbed/CPascalTestbed.dpr

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Copyright © 2025-present tinyBigGAMES™ LLC
2929
All Rights Reserved.
3030
31-
https://github.com/tinyBigGAMES/CPascal
31+
https://cpascal.org
3232
3333
BSD 3-Clause License
3434
@@ -67,12 +67,25 @@ program CPascalTestbed;
6767
uses
6868
System.SysUtils,
6969
UCPascalTestbed in 'UCPascalTestbed.pas',
70-
CPascal.CodeGen in '..\..\src\CPascal.CodeGen.pas',
70+
CPascal.Builder in '..\..\src\CPascal.Builder.pas',
7171
CPascal.Common in '..\..\src\CPascal.Common.pas',
72-
CPascal.Parser in '..\..\src\CPascal.Parser.pas',
72+
CPascal.Expressions in '..\..\src\CPascal.Expressions.pas',
7373
CPascal.LLVM in '..\..\src\CPascal.LLVM.pas',
74+
CPascal in '..\..\src\CPascal.pas',
7475
CPascal.Platform in '..\..\src\CPascal.Platform.pas',
75-
CPascal.Platform.Win32 in '..\..\src\CPascal.Platform.Win32.pas';
76+
CPascal.Builder.Interfaces in '..\..\src\CPascal.Builder.Interfaces.pas',
77+
CPascal.Builder.Source in '..\..\src\CPascal.Builder.Source.pas',
78+
CPascal.Builder.IR in '..\..\src\CPascal.Builder.IR.pas',
79+
CPascal.Tests.CompilerDirectives in '..\..\src\tests\CPascal.Tests.CompilerDirectives.pas',
80+
CPascal.Tests.ControlFlow in '..\..\src\tests\CPascal.Tests.ControlFlow.pas',
81+
CPascal.Tests.Declarations in '..\..\src\tests\CPascal.Tests.Declarations.pas',
82+
CPascal.Tests.Expressions in '..\..\src\tests\CPascal.Tests.Expressions.pas',
83+
CPascal.Tests.Functions in '..\..\src\tests\CPascal.Tests.Functions.pas',
84+
CPascal.Tests.Infrastructure in '..\..\src\tests\CPascal.Tests.Infrastructure.pas',
85+
CPascal.Tests.Modules in '..\..\src\tests\CPascal.Tests.Modules.pas',
86+
CPascal.Tests in '..\..\src\tests\CPascal.Tests.pas',
87+
CPascal.Tests.Structure in '..\..\src\tests\CPascal.Tests.Structure.pas',
88+
CPascal.Tests.Types in '..\..\src\tests\CPascal.Tests.Types.pas';
7689

7790
begin
7891
RunCPascalTestbed();

examples/testbed/CPascalTestbed.dproj

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,25 @@
118118
<MainSource>MainSource</MainSource>
119119
</DelphiCompile>
120120
<DCCReference Include="UCPascalTestbed.pas"/>
121-
<DCCReference Include="..\..\src\CPascal.CodeGen.pas"/>
121+
<DCCReference Include="..\..\src\CPascal.Builder.pas"/>
122122
<DCCReference Include="..\..\src\CPascal.Common.pas"/>
123-
<DCCReference Include="..\..\src\CPascal.Parser.pas"/>
123+
<DCCReference Include="..\..\src\CPascal.Expressions.pas"/>
124124
<DCCReference Include="..\..\src\CPascal.LLVM.pas"/>
125+
<DCCReference Include="..\..\src\CPascal.pas"/>
125126
<DCCReference Include="..\..\src\CPascal.Platform.pas"/>
126-
<DCCReference Include="..\..\src\CPascal.Platform.Win32.pas"/>
127+
<DCCReference Include="..\..\src\CPascal.Builder.Interfaces.pas"/>
128+
<DCCReference Include="..\..\src\CPascal.Builder.Source.pas"/>
129+
<DCCReference Include="..\..\src\CPascal.Builder.IR.pas"/>
130+
<DCCReference Include="..\..\src\tests\CPascal.Tests.CompilerDirectives.pas"/>
131+
<DCCReference Include="..\..\src\tests\CPascal.Tests.ControlFlow.pas"/>
132+
<DCCReference Include="..\..\src\tests\CPascal.Tests.Declarations.pas"/>
133+
<DCCReference Include="..\..\src\tests\CPascal.Tests.Expressions.pas"/>
134+
<DCCReference Include="..\..\src\tests\CPascal.Tests.Functions.pas"/>
135+
<DCCReference Include="..\..\src\tests\CPascal.Tests.Infrastructure.pas"/>
136+
<DCCReference Include="..\..\src\tests\CPascal.Tests.Modules.pas"/>
137+
<DCCReference Include="..\..\src\tests\CPascal.Tests.pas"/>
138+
<DCCReference Include="..\..\src\tests\CPascal.Tests.Structure.pas"/>
139+
<DCCReference Include="..\..\src\tests\CPascal.Tests.Types.pas"/>
127140
<BuildConfiguration Include="Base">
128141
<Key>Base</Key>
129142
</BuildConfiguration>

0 commit comments

Comments
 (0)