IncludeCPP 3.5.0__py3-none-any.whl → 3.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- includecpp/__init__.py +1 -1
- includecpp/core/cssl/CSSL_DOCUMENTATION.md +351 -20
- includecpp/core/cssl/cssl_builtins.py +228 -2
- includecpp/core/cssl/cssl_parser.py +214 -25
- includecpp/core/cssl/cssl_runtime.py +365 -38
- includecpp/core/cssl/cssl_types.py +339 -2
- includecpp/core/cssl_bridge.py +100 -4
- includecpp/core/cssl_bridge.pyi +177 -0
- {includecpp-3.5.0.dist-info → includecpp-3.6.0.dist-info}/METADATA +1 -1
- {includecpp-3.5.0.dist-info → includecpp-3.6.0.dist-info}/RECORD +14 -14
- {includecpp-3.5.0.dist-info → includecpp-3.6.0.dist-info}/WHEEL +0 -0
- {includecpp-3.5.0.dist-info → includecpp-3.6.0.dist-info}/entry_points.txt +0 -0
- {includecpp-3.5.0.dist-info → includecpp-3.6.0.dist-info}/licenses/LICENSE +0 -0
- {includecpp-3.5.0.dist-info → includecpp-3.6.0.dist-info}/top_level.txt +0 -0
includecpp/__init__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CSSL - C-Style Scripting Language
|
|
2
2
|
|
|
3
|
-
> Version 3.
|
|
3
|
+
> Version 3.6.0 | A modern scripting language with C++-style syntax and unique features like CodeInfusion and BruteInjection.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -15,16 +15,19 @@
|
|
|
15
15
|
7. [Functions](#functions)
|
|
16
16
|
8. [Function Keywords](#function-keywords)
|
|
17
17
|
9. [String Methods](#string-methods)
|
|
18
|
-
10. [
|
|
19
|
-
11. [
|
|
20
|
-
12. [
|
|
21
|
-
13. [
|
|
22
|
-
14. [
|
|
23
|
-
15. [
|
|
24
|
-
16. [
|
|
25
|
-
17. [
|
|
26
|
-
18. [
|
|
27
|
-
19. [
|
|
18
|
+
10. [File I/O](#file-io)
|
|
19
|
+
11. [JSON Functions](#json-functions)
|
|
20
|
+
12. [Live Object Sharing](#live-object-sharing)
|
|
21
|
+
13. [CodeInfusion](#codeinfusion)
|
|
22
|
+
14. [Value Capture](#value-capture)
|
|
23
|
+
15. [BruteInjection](#bruteinjection)
|
|
24
|
+
16. [Filter Syntax](#filter-syntax)
|
|
25
|
+
17. [Module System](#module-system)
|
|
26
|
+
18. [Parameter Bridge](#parameter-bridge)
|
|
27
|
+
19. [Structures](#structures)
|
|
28
|
+
20. [Error Handling](#error-handling)
|
|
29
|
+
21. [CLI Commands](#cli-commands)
|
|
30
|
+
22. [Examples](#examples)
|
|
28
31
|
|
|
29
32
|
---
|
|
30
33
|
|
|
@@ -336,14 +339,26 @@ int number = 42;
|
|
|
336
339
|
// Declaration with 'global'
|
|
337
340
|
global myGlobal = "visible everywhere";
|
|
338
341
|
|
|
339
|
-
// Access with '@'
|
|
342
|
+
// Access with '@' prefix
|
|
340
343
|
printl(@myGlobal);
|
|
341
344
|
|
|
342
|
-
//
|
|
345
|
+
// Or access directly without '@' (since v3.5.9)
|
|
346
|
+
printl(myGlobal); // Works the same!
|
|
347
|
+
|
|
348
|
+
// Alternative: r@ syntax for declaration
|
|
343
349
|
r@anotherGlobal = "also global";
|
|
344
350
|
printl(@anotherGlobal);
|
|
351
|
+
printl(anotherGlobal); // Also works
|
|
345
352
|
```
|
|
346
353
|
|
|
354
|
+
### Lookup Order
|
|
355
|
+
|
|
356
|
+
When accessing a variable, CSSL checks in order:
|
|
357
|
+
1. Local scope
|
|
358
|
+
2. Global scope
|
|
359
|
+
3. Promoted globals
|
|
360
|
+
4. Built-in functions
|
|
361
|
+
|
|
347
362
|
### Usage in Functions
|
|
348
363
|
|
|
349
364
|
```cssl
|
|
@@ -539,6 +554,29 @@ string n = getName();
|
|
|
539
554
|
int sum = add(5, 3);
|
|
540
555
|
```
|
|
541
556
|
|
|
557
|
+
### Named Parameters
|
|
558
|
+
|
|
559
|
+
Functions can be called with named parameters for clarity.
|
|
560
|
+
|
|
561
|
+
```cssl
|
|
562
|
+
// Define function
|
|
563
|
+
int calculate(int base, int multiplier, int offset) {
|
|
564
|
+
return base * multiplier + offset;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// Call with positional arguments
|
|
568
|
+
int r1 = calculate(10, 5, 3); // 53
|
|
569
|
+
|
|
570
|
+
// Call with named parameters
|
|
571
|
+
int r2 = calculate(base=10, multiplier=5, offset=3); // 53
|
|
572
|
+
|
|
573
|
+
// Mix positional and named (positional must come first)
|
|
574
|
+
int r3 = calculate(10, multiplier=5, offset=3); // 53
|
|
575
|
+
|
|
576
|
+
// Named parameters can be in any order
|
|
577
|
+
int r4 = calculate(offset=3, base=10, multiplier=5); // 53
|
|
578
|
+
```
|
|
579
|
+
|
|
542
580
|
### Nested Functions
|
|
543
581
|
|
|
544
582
|
```cssl
|
|
@@ -798,6 +836,170 @@ string padded2 = num.padEnd(5, "."); // "42..."
|
|
|
798
836
|
|
|
799
837
|
---
|
|
800
838
|
|
|
839
|
+
## File I/O
|
|
840
|
+
|
|
841
|
+
CSSL provides built-in functions for file operations.
|
|
842
|
+
|
|
843
|
+
### Basic File Operations
|
|
844
|
+
|
|
845
|
+
```cssl
|
|
846
|
+
// Read entire file
|
|
847
|
+
string content = read("/path/to/file.txt");
|
|
848
|
+
printl(content);
|
|
849
|
+
|
|
850
|
+
// Read specific line (1-indexed)
|
|
851
|
+
string line5 = readline(5, "/path/to/file.txt");
|
|
852
|
+
printl(line5);
|
|
853
|
+
|
|
854
|
+
// Write to file (overwrites)
|
|
855
|
+
write("/path/to/file.txt", "Hello World");
|
|
856
|
+
|
|
857
|
+
// Write/replace specific line
|
|
858
|
+
writeline(3, "New line content", "/path/to/file.txt");
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
### Extended File Functions
|
|
862
|
+
|
|
863
|
+
```cssl
|
|
864
|
+
// Read all lines as array
|
|
865
|
+
stack<string> lines = readlines("/path/to/file.txt");
|
|
866
|
+
|
|
867
|
+
// Append to file
|
|
868
|
+
appendfile("/path/to/file.txt", "\nNew content");
|
|
869
|
+
|
|
870
|
+
// File checks
|
|
871
|
+
bool exists = pathexists("/path/to/file.txt");
|
|
872
|
+
bool isFile = isfile("/path/to/file.txt");
|
|
873
|
+
bool isDir = isdir("/path/to/folder");
|
|
874
|
+
|
|
875
|
+
// File size
|
|
876
|
+
int size = filesize("/path/to/file.txt");
|
|
877
|
+
|
|
878
|
+
// Directory listing
|
|
879
|
+
stack<string> files = listdir("/path/to/folder");
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
### Path Functions
|
|
883
|
+
|
|
884
|
+
```cssl
|
|
885
|
+
// Path manipulation
|
|
886
|
+
string base = basename("/path/to/file.txt"); // "file.txt"
|
|
887
|
+
string dir = dirname("/path/to/file.txt"); // "/path/to"
|
|
888
|
+
string full = joinpath("/path", "to", "file.txt"); // "/path/to/file.txt"
|
|
889
|
+
string abs = abspath("./file.txt"); // "/current/dir/file.txt"
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
### All File I/O Functions
|
|
893
|
+
|
|
894
|
+
| Function | Description |
|
|
895
|
+
|----------|-------------|
|
|
896
|
+
| `read(path)` | Read entire file content |
|
|
897
|
+
| `readline(line, path)` | Read specific line (1-indexed) |
|
|
898
|
+
| `write(path, content)` | Write content to file |
|
|
899
|
+
| `writeline(line, content, path)` | Write/replace specific line |
|
|
900
|
+
| `readfile(path)` | Read file (alias for read) |
|
|
901
|
+
| `writefile(path, content)` | Write file (alias for write) |
|
|
902
|
+
| `readlines(path)` | Read all lines as array |
|
|
903
|
+
| `appendfile(path, content)` | Append to file |
|
|
904
|
+
| `pathexists(path)` | Check if path exists |
|
|
905
|
+
| `isfile(path)` | Check if is file |
|
|
906
|
+
| `isdir(path)` | Check if is directory |
|
|
907
|
+
| `filesize(path)` | Get file size in bytes |
|
|
908
|
+
| `listdir(path)` | List directory contents |
|
|
909
|
+
| `makedirs(path)` | Create directories |
|
|
910
|
+
| `removefile(path)` | Delete file |
|
|
911
|
+
| `removedir(path)` | Delete empty directory |
|
|
912
|
+
| `copyfile(src, dst)` | Copy file |
|
|
913
|
+
| `movefile(src, dst)` | Move file |
|
|
914
|
+
|
|
915
|
+
---
|
|
916
|
+
|
|
917
|
+
## JSON Functions
|
|
918
|
+
|
|
919
|
+
CSSL provides namespace-style JSON functions with the `json::` prefix.
|
|
920
|
+
|
|
921
|
+
### Reading & Writing JSON Files
|
|
922
|
+
|
|
923
|
+
```cssl
|
|
924
|
+
// Read and parse JSON file
|
|
925
|
+
json data = json::read("/path/to/config.json");
|
|
926
|
+
printl(data.name);
|
|
927
|
+
|
|
928
|
+
// Write data to JSON file
|
|
929
|
+
json::write("/path/to/output.json", data);
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
### JSON Parsing & Stringifying
|
|
933
|
+
|
|
934
|
+
```cssl
|
|
935
|
+
// Parse JSON string
|
|
936
|
+
string jsonStr = '{"name": "Alice", "age": 30}';
|
|
937
|
+
json obj = json::parse(jsonStr);
|
|
938
|
+
|
|
939
|
+
// Convert to JSON string
|
|
940
|
+
string str = json::stringify(obj);
|
|
941
|
+
|
|
942
|
+
// Pretty print with indentation
|
|
943
|
+
string pretty = json::pretty(obj);
|
|
944
|
+
printl(pretty);
|
|
945
|
+
```
|
|
946
|
+
|
|
947
|
+
### JSON Path Operations
|
|
948
|
+
|
|
949
|
+
```cssl
|
|
950
|
+
json data = json::read("config.json");
|
|
951
|
+
|
|
952
|
+
// Get value by dot-path
|
|
953
|
+
string name = json::get(data, "user.name");
|
|
954
|
+
int age = json::get(data, "user.profile.age");
|
|
955
|
+
string city = json::get(data, "address.city", "Unknown"); // with default
|
|
956
|
+
|
|
957
|
+
// Set value by dot-path
|
|
958
|
+
data = json::set(data, "user.name", "Bob");
|
|
959
|
+
data = json::set(data, "settings.theme", "dark");
|
|
960
|
+
|
|
961
|
+
// Check if path exists
|
|
962
|
+
if (json::has(data, "user.email")) {
|
|
963
|
+
printl("Email exists");
|
|
964
|
+
}
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
### JSON Object Operations
|
|
968
|
+
|
|
969
|
+
```cssl
|
|
970
|
+
json obj = json::read("data.json");
|
|
971
|
+
|
|
972
|
+
// Get all keys
|
|
973
|
+
stack<string> keys = json::keys(obj);
|
|
974
|
+
foreach (key in keys) {
|
|
975
|
+
printl(key);
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// Get all values
|
|
979
|
+
stack<dynamic> values = json::values(obj);
|
|
980
|
+
|
|
981
|
+
// Deep merge objects
|
|
982
|
+
json merged = json::merge(obj1, obj2, obj3);
|
|
983
|
+
```
|
|
984
|
+
|
|
985
|
+
### All JSON Functions
|
|
986
|
+
|
|
987
|
+
| Function | Description |
|
|
988
|
+
|----------|-------------|
|
|
989
|
+
| `json::read(path)` | Read and parse JSON file |
|
|
990
|
+
| `json::write(path, data)` | Write data to JSON file |
|
|
991
|
+
| `json::parse(str)` | Parse JSON string to object |
|
|
992
|
+
| `json::stringify(data)` | Convert to JSON string |
|
|
993
|
+
| `json::pretty(data)` | Pretty print JSON |
|
|
994
|
+
| `json::get(data, path, default)` | Get value by dot-path |
|
|
995
|
+
| `json::set(data, path, value)` | Set value by dot-path |
|
|
996
|
+
| `json::has(data, path)` | Check if path exists |
|
|
997
|
+
| `json::keys(data)` | Get all keys |
|
|
998
|
+
| `json::values(data)` | Get all values |
|
|
999
|
+
| `json::merge(obj1, obj2, ...)` | Deep merge objects |
|
|
1000
|
+
|
|
1001
|
+
---
|
|
1002
|
+
|
|
801
1003
|
## Live Object Sharing
|
|
802
1004
|
|
|
803
1005
|
Share Python objects with CSSL. Changes in CSSL reflect back to Python.
|
|
@@ -934,6 +1136,74 @@ exit(); // Executes injection
|
|
|
934
1136
|
|
|
935
1137
|
---
|
|
936
1138
|
|
|
1139
|
+
## Value Capture
|
|
1140
|
+
|
|
1141
|
+
The `%identifier` syntax captures values at registration time, useful for saving original functions before replacement.
|
|
1142
|
+
|
|
1143
|
+
### Capturing Variables
|
|
1144
|
+
|
|
1145
|
+
```cssl
|
|
1146
|
+
string version = "1.0.0";
|
|
1147
|
+
|
|
1148
|
+
// Capture current value
|
|
1149
|
+
v <== { %version; }
|
|
1150
|
+
printl(v); // "1.0.0"
|
|
1151
|
+
|
|
1152
|
+
// Even if version changes later, v keeps captured value
|
|
1153
|
+
version = "2.0.0";
|
|
1154
|
+
printl(v); // Still "1.0.0"
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
### Capturing Functions
|
|
1158
|
+
|
|
1159
|
+
```cssl
|
|
1160
|
+
// Save original exit function before replacing
|
|
1161
|
+
originalExit <<== { %exit(); }
|
|
1162
|
+
|
|
1163
|
+
// Replace exit with custom behavior
|
|
1164
|
+
exit() <<== {
|
|
1165
|
+
printl("Custom cleanup...");
|
|
1166
|
+
originalExit(); // Call saved original
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
exit();
|
|
1170
|
+
// Output:
|
|
1171
|
+
// Custom cleanup...
|
|
1172
|
+
// (original exit behavior)
|
|
1173
|
+
```
|
|
1174
|
+
|
|
1175
|
+
### Use Cases
|
|
1176
|
+
|
|
1177
|
+
```cssl
|
|
1178
|
+
// 1. Preserving original behavior
|
|
1179
|
+
void myFunc() {
|
|
1180
|
+
printl("Original");
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
savedFunc <<== { %myFunc(); }
|
|
1184
|
+
|
|
1185
|
+
myFunc() <<== {
|
|
1186
|
+
printl("Modified");
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
myFunc(); // "Modified"
|
|
1190
|
+
savedFunc(); // "Original"
|
|
1191
|
+
|
|
1192
|
+
// 2. Capturing configuration at startup
|
|
1193
|
+
global config = loadConfig();
|
|
1194
|
+
startupConfig <== { %config; }
|
|
1195
|
+
|
|
1196
|
+
// 3. Snapshot values for later comparison
|
|
1197
|
+
int counter = 0;
|
|
1198
|
+
initial <== { %counter; }
|
|
1199
|
+
// ... operations ...
|
|
1200
|
+
if (counter != initial) {
|
|
1201
|
+
printl("Counter changed!");
|
|
1202
|
+
}
|
|
1203
|
+
```
|
|
1204
|
+
|
|
1205
|
+
---
|
|
1206
|
+
|
|
937
1207
|
## BruteInjection
|
|
938
1208
|
|
|
939
1209
|
BruteInjection copies/moves data between containers.
|
|
@@ -981,6 +1251,26 @@ container ==> data;
|
|
|
981
1251
|
|
|
982
1252
|
---
|
|
983
1253
|
|
|
1254
|
+
### ==>- (Receive Minus)
|
|
1255
|
+
|
|
1256
|
+
Removes matching items from target.
|
|
1257
|
+
|
|
1258
|
+
```cssl
|
|
1259
|
+
stack<string> names;
|
|
1260
|
+
names.push("Alice");
|
|
1261
|
+
names.push("Bob");
|
|
1262
|
+
names.push("Alice");
|
|
1263
|
+
|
|
1264
|
+
stack<string> toRemove;
|
|
1265
|
+
toRemove.push("Alice");
|
|
1266
|
+
|
|
1267
|
+
// Remove all "Alice" from names
|
|
1268
|
+
names ==>- toRemove;
|
|
1269
|
+
printl(names); // ["Bob"]
|
|
1270
|
+
```
|
|
1271
|
+
|
|
1272
|
+
---
|
|
1273
|
+
|
|
984
1274
|
## Filter Syntax
|
|
985
1275
|
|
|
986
1276
|
Filters enable targeted data operations in BruteInjection.
|
|
@@ -1014,6 +1304,30 @@ result +<== [string::contains="App"] fruits; // Apple, Apricot
|
|
|
1014
1304
|
result +<== [string::length=5] fruits; // Apple
|
|
1015
1305
|
```
|
|
1016
1306
|
|
|
1307
|
+
### String Cutting Filters
|
|
1308
|
+
|
|
1309
|
+
Cut strings at specific positions or substrings.
|
|
1310
|
+
|
|
1311
|
+
```cssl
|
|
1312
|
+
string version = "1.0.0-beta";
|
|
1313
|
+
|
|
1314
|
+
// Cut at position (integer index)
|
|
1315
|
+
x = <==[string::cut=3] version;
|
|
1316
|
+
printl(x); // "1.0" (first 3 chars)
|
|
1317
|
+
|
|
1318
|
+
// Cut at substring position
|
|
1319
|
+
x = <==[string::cut="0-"] version;
|
|
1320
|
+
printl(x); // "1.0." (before "0-")
|
|
1321
|
+
|
|
1322
|
+
// Get everything after substring
|
|
1323
|
+
x = <==[string::cutAfter=".0."] version;
|
|
1324
|
+
printl(x); // "0-beta" (after ".0.")
|
|
1325
|
+
|
|
1326
|
+
// Cut after at position
|
|
1327
|
+
x = <==[string::cutAfter=4] version;
|
|
1328
|
+
printl(x); // ".0-beta" (after index 4)
|
|
1329
|
+
```
|
|
1330
|
+
|
|
1017
1331
|
### All Filters
|
|
1018
1332
|
|
|
1019
1333
|
| Filter | Description |
|
|
@@ -1022,6 +1336,10 @@ result +<== [string::length=5] fruits; // Apple
|
|
|
1022
1336
|
| `string::not=VALUE` | Everything except this value |
|
|
1023
1337
|
| `string::contains=VALUE` | Contains substring |
|
|
1024
1338
|
| `string::length=LENGTH` | Exact string length |
|
|
1339
|
+
| `string::cut=INDEX` | Cut at index (returns first N chars) |
|
|
1340
|
+
| `string::cut="SUBSTR"` | Cut at substring position |
|
|
1341
|
+
| `string::cutAfter=INDEX` | Get everything after index |
|
|
1342
|
+
| `string::cutAfter="SUBSTR"` | Get everything after substring |
|
|
1025
1343
|
| `integer::where=VALUE` | Exact int match |
|
|
1026
1344
|
| `json::key=KEYNAME` | Filter by JSON key |
|
|
1027
1345
|
| `json::value=VALUE` | Filter by JSON value |
|
|
@@ -1457,12 +1775,25 @@ print(result) # ["Missing colon after def"]
|
|
|
1457
1775
|
|
|
1458
1776
|
| Operator | Type | Description |
|
|
1459
1777
|
|----------|------|-------------|
|
|
1460
|
-
| `<<==` | CodeInfusion | Replace |
|
|
1461
|
-
| `+<<==` | CodeInfusion | Add |
|
|
1462
|
-
| `-<<==` | CodeInfusion | Remove |
|
|
1463
|
-
|
|
|
1464
|
-
|
|
|
1465
|
-
|
|
|
1778
|
+
| `<<==` | CodeInfusion | Replace function |
|
|
1779
|
+
| `+<<==` | CodeInfusion | Add code (before) |
|
|
1780
|
+
| `-<<==` | CodeInfusion | Remove code |
|
|
1781
|
+
| `<==` | ValueCapture | Capture/assign value |
|
|
1782
|
+
| `+<==` | BruteInjection | Copy data |
|
|
1783
|
+
| `-<==` | BruteInjection | Move data |
|
|
1784
|
+
| `==>` | BruteInjection | Replace data |
|
|
1785
|
+
| `==>-` | BruteInjection | Remove matching items |
|
|
1786
|
+
|
|
1787
|
+
### Special Syntax
|
|
1788
|
+
|
|
1789
|
+
| Syntax | Description |
|
|
1790
|
+
|--------|-------------|
|
|
1791
|
+
| `%identifier` | Capture value at registration time |
|
|
1792
|
+
| `json::func()` | Namespace function call |
|
|
1793
|
+
| `@name` | Access global variable |
|
|
1794
|
+
| `$name` | Access shared Python object |
|
|
1795
|
+
| `s@name` | Self-reference to struct |
|
|
1796
|
+
| `r@name` | Global variable declaration |
|
|
1466
1797
|
|
|
1467
1798
|
---
|
|
1468
1799
|
|
|
@@ -1479,4 +1810,4 @@ print(result) # ["Missing colon after def"]
|
|
|
1479
1810
|
|
|
1480
1811
|
---
|
|
1481
1812
|
|
|
1482
|
-
*CSSL v3.
|
|
1813
|
+
*CSSL v3.6.0 - Developed as part of IncludeCPP*
|