IncludeCPP 3.5.0__py3-none-any.whl → 3.7.1__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/cli/commands.py +418 -0
- includecpp/core/cssl/CSSL_DOCUMENTATION.md +613 -20
- includecpp/core/cssl/cssl_builtins.py +342 -2
- includecpp/core/cssl/cssl_builtins.pyi +1393 -0
- includecpp/core/cssl/cssl_parser.py +368 -64
- includecpp/core/cssl/cssl_runtime.py +637 -38
- includecpp/core/cssl/cssl_types.py +561 -2
- includecpp/core/cssl_bridge.py +100 -4
- includecpp/core/cssl_bridge.pyi +177 -0
- includecpp/vscode/cssl/package.json +24 -4
- includecpp/vscode/cssl/snippets/cssl.snippets.json +1080 -0
- includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +127 -7
- {includecpp-3.5.0.dist-info → includecpp-3.7.1.dist-info}/METADATA +1 -1
- {includecpp-3.5.0.dist-info → includecpp-3.7.1.dist-info}/RECORD +19 -17
- {includecpp-3.5.0.dist-info → includecpp-3.7.1.dist-info}/WHEEL +0 -0
- {includecpp-3.5.0.dist-info → includecpp-3.7.1.dist-info}/entry_points.txt +0 -0
- {includecpp-3.5.0.dist-info → includecpp-3.7.1.dist-info}/licenses/LICENSE +0 -0
- {includecpp-3.5.0.dist-info → includecpp-3.7.1.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CSSL - C-Style Scripting Language
|
|
2
2
|
|
|
3
|
-
> Version 3.
|
|
3
|
+
> Version 3.7.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,22 @@
|
|
|
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. [Instance Management](#instance-management)
|
|
21
|
+
13. [Live Object Sharing](#live-object-sharing)
|
|
22
|
+
14. [CodeInfusion](#codeinfusion)
|
|
23
|
+
15. [Value Capture](#value-capture)
|
|
24
|
+
16. [BruteInjection](#bruteinjection)
|
|
25
|
+
17. [Filter Syntax](#filter-syntax)
|
|
26
|
+
18. [Module System](#module-system)
|
|
27
|
+
19. [Parameter Bridge](#parameter-bridge)
|
|
28
|
+
20. [Classes & OOP](#classes--oop)
|
|
29
|
+
21. [Map Container](#map-container)
|
|
30
|
+
22. [Structures](#structures)
|
|
31
|
+
23. [Error Handling](#error-handling)
|
|
32
|
+
24. [CLI Commands](#cli-commands)
|
|
33
|
+
25. [Examples](#examples)
|
|
28
34
|
|
|
29
35
|
---
|
|
30
36
|
|
|
@@ -336,14 +342,26 @@ int number = 42;
|
|
|
336
342
|
// Declaration with 'global'
|
|
337
343
|
global myGlobal = "visible everywhere";
|
|
338
344
|
|
|
339
|
-
// Access with '@'
|
|
345
|
+
// Access with '@' prefix
|
|
340
346
|
printl(@myGlobal);
|
|
341
347
|
|
|
342
|
-
//
|
|
348
|
+
// Or access directly without '@' (since v3.5.9)
|
|
349
|
+
printl(myGlobal); // Works the same!
|
|
350
|
+
|
|
351
|
+
// Alternative: r@ syntax for declaration
|
|
343
352
|
r@anotherGlobal = "also global";
|
|
344
353
|
printl(@anotherGlobal);
|
|
354
|
+
printl(anotherGlobal); // Also works
|
|
345
355
|
```
|
|
346
356
|
|
|
357
|
+
### Lookup Order
|
|
358
|
+
|
|
359
|
+
When accessing a variable, CSSL checks in order:
|
|
360
|
+
1. Local scope
|
|
361
|
+
2. Global scope
|
|
362
|
+
3. Promoted globals
|
|
363
|
+
4. Built-in functions
|
|
364
|
+
|
|
347
365
|
### Usage in Functions
|
|
348
366
|
|
|
349
367
|
```cssl
|
|
@@ -539,6 +557,29 @@ string n = getName();
|
|
|
539
557
|
int sum = add(5, 3);
|
|
540
558
|
```
|
|
541
559
|
|
|
560
|
+
### Named Parameters
|
|
561
|
+
|
|
562
|
+
Functions can be called with named parameters for clarity.
|
|
563
|
+
|
|
564
|
+
```cssl
|
|
565
|
+
// Define function
|
|
566
|
+
int calculate(int base, int multiplier, int offset) {
|
|
567
|
+
return base * multiplier + offset;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// Call with positional arguments
|
|
571
|
+
int r1 = calculate(10, 5, 3); // 53
|
|
572
|
+
|
|
573
|
+
// Call with named parameters
|
|
574
|
+
int r2 = calculate(base=10, multiplier=5, offset=3); // 53
|
|
575
|
+
|
|
576
|
+
// Mix positional and named (positional must come first)
|
|
577
|
+
int r3 = calculate(10, multiplier=5, offset=3); // 53
|
|
578
|
+
|
|
579
|
+
// Named parameters can be in any order
|
|
580
|
+
int r4 = calculate(offset=3, base=10, multiplier=5); // 53
|
|
581
|
+
```
|
|
582
|
+
|
|
542
583
|
### Nested Functions
|
|
543
584
|
|
|
544
585
|
```cssl
|
|
@@ -798,6 +839,247 @@ string padded2 = num.padEnd(5, "."); // "42..."
|
|
|
798
839
|
|
|
799
840
|
---
|
|
800
841
|
|
|
842
|
+
## File I/O
|
|
843
|
+
|
|
844
|
+
CSSL provides built-in functions for file operations.
|
|
845
|
+
|
|
846
|
+
### Basic File Operations
|
|
847
|
+
|
|
848
|
+
```cssl
|
|
849
|
+
// Read entire file
|
|
850
|
+
string content = read("/path/to/file.txt");
|
|
851
|
+
printl(content);
|
|
852
|
+
|
|
853
|
+
// Read specific line (1-indexed)
|
|
854
|
+
string line5 = readline(5, "/path/to/file.txt");
|
|
855
|
+
printl(line5);
|
|
856
|
+
|
|
857
|
+
// Write to file (overwrites)
|
|
858
|
+
write("/path/to/file.txt", "Hello World");
|
|
859
|
+
|
|
860
|
+
// Write/replace specific line
|
|
861
|
+
writeline(3, "New line content", "/path/to/file.txt");
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
### Extended File Functions
|
|
865
|
+
|
|
866
|
+
```cssl
|
|
867
|
+
// Read all lines as array
|
|
868
|
+
stack<string> lines = readlines("/path/to/file.txt");
|
|
869
|
+
|
|
870
|
+
// Append to file
|
|
871
|
+
appendfile("/path/to/file.txt", "\nNew content");
|
|
872
|
+
|
|
873
|
+
// File checks
|
|
874
|
+
bool exists = pathexists("/path/to/file.txt");
|
|
875
|
+
bool isFile = isfile("/path/to/file.txt");
|
|
876
|
+
bool isDir = isdir("/path/to/folder");
|
|
877
|
+
|
|
878
|
+
// File size
|
|
879
|
+
int size = filesize("/path/to/file.txt");
|
|
880
|
+
|
|
881
|
+
// Directory listing
|
|
882
|
+
stack<string> files = listdir("/path/to/folder");
|
|
883
|
+
```
|
|
884
|
+
|
|
885
|
+
### Path Functions
|
|
886
|
+
|
|
887
|
+
```cssl
|
|
888
|
+
// Path manipulation
|
|
889
|
+
string base = basename("/path/to/file.txt"); // "file.txt"
|
|
890
|
+
string dir = dirname("/path/to/file.txt"); // "/path/to"
|
|
891
|
+
string full = joinpath("/path", "to", "file.txt"); // "/path/to/file.txt"
|
|
892
|
+
string abs = abspath("./file.txt"); // "/current/dir/file.txt"
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
### All File I/O Functions
|
|
896
|
+
|
|
897
|
+
| Function | Description |
|
|
898
|
+
|----------|-------------|
|
|
899
|
+
| `read(path)` | Read entire file content |
|
|
900
|
+
| `readline(line, path)` | Read specific line (1-indexed) |
|
|
901
|
+
| `write(path, content)` | Write content to file |
|
|
902
|
+
| `writeline(line, content, path)` | Write/replace specific line |
|
|
903
|
+
| `readfile(path)` | Read file (alias for read) |
|
|
904
|
+
| `writefile(path, content)` | Write file (alias for write) |
|
|
905
|
+
| `readlines(path)` | Read all lines as array |
|
|
906
|
+
| `appendfile(path, content)` | Append to file |
|
|
907
|
+
| `pathexists(path)` | Check if path exists |
|
|
908
|
+
| `isfile(path)` | Check if is file |
|
|
909
|
+
| `isdir(path)` | Check if is directory |
|
|
910
|
+
| `filesize(path)` | Get file size in bytes |
|
|
911
|
+
| `listdir(path)` | List directory contents |
|
|
912
|
+
| `makedirs(path)` | Create directories |
|
|
913
|
+
| `removefile(path)` | Delete file |
|
|
914
|
+
| `removedir(path)` | Delete empty directory |
|
|
915
|
+
| `copyfile(src, dst)` | Copy file |
|
|
916
|
+
| `movefile(src, dst)` | Move file |
|
|
917
|
+
|
|
918
|
+
---
|
|
919
|
+
|
|
920
|
+
## JSON Functions
|
|
921
|
+
|
|
922
|
+
CSSL provides namespace-style JSON functions with the `json::` prefix.
|
|
923
|
+
|
|
924
|
+
### Reading & Writing JSON Files
|
|
925
|
+
|
|
926
|
+
```cssl
|
|
927
|
+
// Read and parse JSON file
|
|
928
|
+
json data = json::read("/path/to/config.json");
|
|
929
|
+
printl(data.name);
|
|
930
|
+
|
|
931
|
+
// Write data to JSON file
|
|
932
|
+
json::write("/path/to/output.json", data);
|
|
933
|
+
```
|
|
934
|
+
|
|
935
|
+
### JSON Parsing & Stringifying
|
|
936
|
+
|
|
937
|
+
```cssl
|
|
938
|
+
// Parse JSON string
|
|
939
|
+
string jsonStr = '{"name": "Alice", "age": 30}';
|
|
940
|
+
json obj = json::parse(jsonStr);
|
|
941
|
+
|
|
942
|
+
// Convert to JSON string
|
|
943
|
+
string str = json::stringify(obj);
|
|
944
|
+
|
|
945
|
+
// Pretty print with indentation
|
|
946
|
+
string pretty = json::pretty(obj);
|
|
947
|
+
printl(pretty);
|
|
948
|
+
```
|
|
949
|
+
|
|
950
|
+
### JSON Path Operations
|
|
951
|
+
|
|
952
|
+
```cssl
|
|
953
|
+
json data = json::read("config.json");
|
|
954
|
+
|
|
955
|
+
// Get value by dot-path
|
|
956
|
+
string name = json::get(data, "user.name");
|
|
957
|
+
int age = json::get(data, "user.profile.age");
|
|
958
|
+
string city = json::get(data, "address.city", "Unknown"); // with default
|
|
959
|
+
|
|
960
|
+
// Set value by dot-path
|
|
961
|
+
data = json::set(data, "user.name", "Bob");
|
|
962
|
+
data = json::set(data, "settings.theme", "dark");
|
|
963
|
+
|
|
964
|
+
// Check if path exists
|
|
965
|
+
if (json::has(data, "user.email")) {
|
|
966
|
+
printl("Email exists");
|
|
967
|
+
}
|
|
968
|
+
```
|
|
969
|
+
|
|
970
|
+
### JSON Object Operations
|
|
971
|
+
|
|
972
|
+
```cssl
|
|
973
|
+
json obj = json::read("data.json");
|
|
974
|
+
|
|
975
|
+
// Get all keys
|
|
976
|
+
stack<string> keys = json::keys(obj);
|
|
977
|
+
foreach (key in keys) {
|
|
978
|
+
printl(key);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
// Get all values
|
|
982
|
+
stack<dynamic> values = json::values(obj);
|
|
983
|
+
|
|
984
|
+
// Deep merge objects
|
|
985
|
+
json merged = json::merge(obj1, obj2, obj3);
|
|
986
|
+
```
|
|
987
|
+
|
|
988
|
+
### All JSON Functions
|
|
989
|
+
|
|
990
|
+
| Function | Description |
|
|
991
|
+
|----------|-------------|
|
|
992
|
+
| `json::read(path)` | Read and parse JSON file |
|
|
993
|
+
| `json::write(path, data)` | Write data to JSON file |
|
|
994
|
+
| `json::parse(str)` | Parse JSON string to object |
|
|
995
|
+
| `json::stringify(data)` | Convert to JSON string |
|
|
996
|
+
| `json::pretty(data)` | Pretty print JSON |
|
|
997
|
+
| `json::get(data, path, default)` | Get value by dot-path |
|
|
998
|
+
| `json::set(data, path, value)` | Set value by dot-path |
|
|
999
|
+
| `json::has(data, path)` | Check if path exists |
|
|
1000
|
+
| `json::keys(data)` | Get all keys |
|
|
1001
|
+
| `json::values(data)` | Get all values |
|
|
1002
|
+
| `json::merge(obj1, obj2, ...)` | Deep merge objects |
|
|
1003
|
+
|
|
1004
|
+
---
|
|
1005
|
+
|
|
1006
|
+
## Instance Management
|
|
1007
|
+
|
|
1008
|
+
CSSL provides `instance<"name">` syntax and `instance::` namespace for working with shared instances.
|
|
1009
|
+
|
|
1010
|
+
### Instance Declaration
|
|
1011
|
+
|
|
1012
|
+
```cssl
|
|
1013
|
+
// Get/create shared instance by name
|
|
1014
|
+
instance<"MyApp"> app;
|
|
1015
|
+
|
|
1016
|
+
// With initialization
|
|
1017
|
+
instance<"tk"> tk = include("tkinter.cssl-mod");
|
|
1018
|
+
|
|
1019
|
+
// Register object as shared instance
|
|
1020
|
+
myModule ==> $AppModule
|
|
1021
|
+
// Or using instance syntax:
|
|
1022
|
+
myModule ==> instance<"AppModule">
|
|
1023
|
+
```
|
|
1024
|
+
|
|
1025
|
+
### Instance Introspection
|
|
1026
|
+
|
|
1027
|
+
```cssl
|
|
1028
|
+
@tk = include("tk.cssl-mod");
|
|
1029
|
+
|
|
1030
|
+
// Get all methods from module
|
|
1031
|
+
stack<string> methods = instance::getMethods(@tk);
|
|
1032
|
+
foreach (m in methods) {
|
|
1033
|
+
printl("Method: " + m);
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
// Get all classes
|
|
1037
|
+
stack<string> classes = instance::getClasses(@tk);
|
|
1038
|
+
|
|
1039
|
+
// Get all variables
|
|
1040
|
+
stack<string> vars = instance::getVars(@tk);
|
|
1041
|
+
|
|
1042
|
+
// Get everything categorized
|
|
1043
|
+
json all = instance::getAll(@tk);
|
|
1044
|
+
printl(all.methods); // ["method1", "method2", ...]
|
|
1045
|
+
printl(all.classes); // ["Class1", "Class2", ...]
|
|
1046
|
+
printl(all.vars); // ["var1", "var2", ...]
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
### Dynamic Method Calls
|
|
1050
|
+
|
|
1051
|
+
```cssl
|
|
1052
|
+
// Call method dynamically by name
|
|
1053
|
+
result = instance::call(@module, "methodName", arg1, arg2);
|
|
1054
|
+
|
|
1055
|
+
// Check if method/attribute exists
|
|
1056
|
+
if (instance::has(@module, "initialize")) {
|
|
1057
|
+
instance::call(@module, "initialize");
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// Get type name
|
|
1061
|
+
string typeName = instance::type(@module);
|
|
1062
|
+
printl(typeName); // "module"
|
|
1063
|
+
```
|
|
1064
|
+
|
|
1065
|
+
### All Instance Functions
|
|
1066
|
+
|
|
1067
|
+
| Function | Description |
|
|
1068
|
+
|----------|-------------|
|
|
1069
|
+
| `instance<"name"> var` | Declare instance variable |
|
|
1070
|
+
| `obj ==> instance<"name">` | Register as shared instance |
|
|
1071
|
+
| `instance::getMethods(obj)` | Get all method names |
|
|
1072
|
+
| `instance::getClasses(obj)` | Get all class names |
|
|
1073
|
+
| `instance::getVars(obj)` | Get all variable names |
|
|
1074
|
+
| `instance::getAll(obj)` | Get categorized dict |
|
|
1075
|
+
| `instance::call(obj, 'name', ...)` | Call method dynamically |
|
|
1076
|
+
| `instance::has(obj, 'name')` | Check if attribute exists |
|
|
1077
|
+
| `instance::type(obj)` | Get type name |
|
|
1078
|
+
| `isavailable("name")` | Check if shared instance exists |
|
|
1079
|
+
| `instance::exists("name")` | Alias for isavailable |
|
|
1080
|
+
|
|
1081
|
+
---
|
|
1082
|
+
|
|
801
1083
|
## Live Object Sharing
|
|
802
1084
|
|
|
803
1085
|
Share Python objects with CSSL. Changes in CSSL reflect back to Python.
|
|
@@ -934,6 +1216,74 @@ exit(); // Executes injection
|
|
|
934
1216
|
|
|
935
1217
|
---
|
|
936
1218
|
|
|
1219
|
+
## Value Capture
|
|
1220
|
+
|
|
1221
|
+
The `%identifier` syntax captures values at registration time, useful for saving original functions before replacement.
|
|
1222
|
+
|
|
1223
|
+
### Capturing Variables
|
|
1224
|
+
|
|
1225
|
+
```cssl
|
|
1226
|
+
string version = "1.0.0";
|
|
1227
|
+
|
|
1228
|
+
// Capture current value
|
|
1229
|
+
v <== { %version; }
|
|
1230
|
+
printl(v); // "1.0.0"
|
|
1231
|
+
|
|
1232
|
+
// Even if version changes later, v keeps captured value
|
|
1233
|
+
version = "2.0.0";
|
|
1234
|
+
printl(v); // Still "1.0.0"
|
|
1235
|
+
```
|
|
1236
|
+
|
|
1237
|
+
### Capturing Functions
|
|
1238
|
+
|
|
1239
|
+
```cssl
|
|
1240
|
+
// Save original exit function before replacing
|
|
1241
|
+
originalExit <<== { %exit(); }
|
|
1242
|
+
|
|
1243
|
+
// Replace exit with custom behavior
|
|
1244
|
+
exit() <<== {
|
|
1245
|
+
printl("Custom cleanup...");
|
|
1246
|
+
originalExit(); // Call saved original
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
exit();
|
|
1250
|
+
// Output:
|
|
1251
|
+
// Custom cleanup...
|
|
1252
|
+
// (original exit behavior)
|
|
1253
|
+
```
|
|
1254
|
+
|
|
1255
|
+
### Use Cases
|
|
1256
|
+
|
|
1257
|
+
```cssl
|
|
1258
|
+
// 1. Preserving original behavior
|
|
1259
|
+
void myFunc() {
|
|
1260
|
+
printl("Original");
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
savedFunc <<== { %myFunc(); }
|
|
1264
|
+
|
|
1265
|
+
myFunc() <<== {
|
|
1266
|
+
printl("Modified");
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
myFunc(); // "Modified"
|
|
1270
|
+
savedFunc(); // "Original"
|
|
1271
|
+
|
|
1272
|
+
// 2. Capturing configuration at startup
|
|
1273
|
+
global config = loadConfig();
|
|
1274
|
+
startupConfig <== { %config; }
|
|
1275
|
+
|
|
1276
|
+
// 3. Snapshot values for later comparison
|
|
1277
|
+
int counter = 0;
|
|
1278
|
+
initial <== { %counter; }
|
|
1279
|
+
// ... operations ...
|
|
1280
|
+
if (counter != initial) {
|
|
1281
|
+
printl("Counter changed!");
|
|
1282
|
+
}
|
|
1283
|
+
```
|
|
1284
|
+
|
|
1285
|
+
---
|
|
1286
|
+
|
|
937
1287
|
## BruteInjection
|
|
938
1288
|
|
|
939
1289
|
BruteInjection copies/moves data between containers.
|
|
@@ -981,6 +1331,26 @@ container ==> data;
|
|
|
981
1331
|
|
|
982
1332
|
---
|
|
983
1333
|
|
|
1334
|
+
### ==>- (Receive Minus)
|
|
1335
|
+
|
|
1336
|
+
Removes matching items from target.
|
|
1337
|
+
|
|
1338
|
+
```cssl
|
|
1339
|
+
stack<string> names;
|
|
1340
|
+
names.push("Alice");
|
|
1341
|
+
names.push("Bob");
|
|
1342
|
+
names.push("Alice");
|
|
1343
|
+
|
|
1344
|
+
stack<string> toRemove;
|
|
1345
|
+
toRemove.push("Alice");
|
|
1346
|
+
|
|
1347
|
+
// Remove all "Alice" from names
|
|
1348
|
+
names ==>- toRemove;
|
|
1349
|
+
printl(names); // ["Bob"]
|
|
1350
|
+
```
|
|
1351
|
+
|
|
1352
|
+
---
|
|
1353
|
+
|
|
984
1354
|
## Filter Syntax
|
|
985
1355
|
|
|
986
1356
|
Filters enable targeted data operations in BruteInjection.
|
|
@@ -1014,6 +1384,30 @@ result +<== [string::contains="App"] fruits; // Apple, Apricot
|
|
|
1014
1384
|
result +<== [string::length=5] fruits; // Apple
|
|
1015
1385
|
```
|
|
1016
1386
|
|
|
1387
|
+
### String Cutting Filters
|
|
1388
|
+
|
|
1389
|
+
Cut strings at specific positions or substrings.
|
|
1390
|
+
|
|
1391
|
+
```cssl
|
|
1392
|
+
string version = "1.0.0-beta";
|
|
1393
|
+
|
|
1394
|
+
// Cut at position (integer index)
|
|
1395
|
+
x = <==[string::cut=3] version;
|
|
1396
|
+
printl(x); // "1.0" (first 3 chars)
|
|
1397
|
+
|
|
1398
|
+
// Cut at substring position
|
|
1399
|
+
x = <==[string::cut="0-"] version;
|
|
1400
|
+
printl(x); // "1.0." (before "0-")
|
|
1401
|
+
|
|
1402
|
+
// Get everything after substring
|
|
1403
|
+
x = <==[string::cutAfter=".0."] version;
|
|
1404
|
+
printl(x); // "0-beta" (after ".0.")
|
|
1405
|
+
|
|
1406
|
+
// Cut after at position
|
|
1407
|
+
x = <==[string::cutAfter=4] version;
|
|
1408
|
+
printl(x); // ".0-beta" (after index 4)
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1017
1411
|
### All Filters
|
|
1018
1412
|
|
|
1019
1413
|
| Filter | Description |
|
|
@@ -1022,6 +1416,10 @@ result +<== [string::length=5] fruits; // Apple
|
|
|
1022
1416
|
| `string::not=VALUE` | Everything except this value |
|
|
1023
1417
|
| `string::contains=VALUE` | Contains substring |
|
|
1024
1418
|
| `string::length=LENGTH` | Exact string length |
|
|
1419
|
+
| `string::cut=INDEX` | Cut at index (returns first N chars) |
|
|
1420
|
+
| `string::cut="SUBSTR"` | Cut at substring position |
|
|
1421
|
+
| `string::cutAfter=INDEX` | Get everything after index |
|
|
1422
|
+
| `string::cutAfter="SUBSTR"` | Get everything after substring |
|
|
1025
1423
|
| `integer::where=VALUE` | Exact int match |
|
|
1026
1424
|
| `json::key=KEYNAME` | Filter by JSON key |
|
|
1027
1425
|
| `json::value=VALUE` | Filter by JSON value |
|
|
@@ -1157,6 +1555,188 @@ parameter.return(myObject); // JSON/dict
|
|
|
1157
1555
|
|
|
1158
1556
|
---
|
|
1159
1557
|
|
|
1558
|
+
## Classes & OOP
|
|
1559
|
+
|
|
1560
|
+
CSSL supports object-oriented programming with classes, constructors, and the `this->` keyword for member access.
|
|
1561
|
+
|
|
1562
|
+
### Defining a Class
|
|
1563
|
+
|
|
1564
|
+
```cssl
|
|
1565
|
+
class Person {
|
|
1566
|
+
// Member variables
|
|
1567
|
+
string name;
|
|
1568
|
+
int age;
|
|
1569
|
+
|
|
1570
|
+
// Constructor (same name as class)
|
|
1571
|
+
void Person(string n, int a) {
|
|
1572
|
+
this->name = n;
|
|
1573
|
+
this->age = a;
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
// Methods
|
|
1577
|
+
void greet() {
|
|
1578
|
+
printl("Hello, I'm " + this->name);
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
string getName() {
|
|
1582
|
+
return this->name;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
void setAge(int a) {
|
|
1586
|
+
this->age = a;
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
```
|
|
1590
|
+
|
|
1591
|
+
### Creating Instances
|
|
1592
|
+
|
|
1593
|
+
```cssl
|
|
1594
|
+
// Use 'new' keyword to instantiate
|
|
1595
|
+
Person p = new Person("Alice", 30);
|
|
1596
|
+
|
|
1597
|
+
// Call methods
|
|
1598
|
+
p.greet(); // prints: "Hello, I'm Alice"
|
|
1599
|
+
string name = p.getName(); // returns "Alice"
|
|
1600
|
+
|
|
1601
|
+
// Access members (if public)
|
|
1602
|
+
printl(p.name); // prints: "Alice"
|
|
1603
|
+
p.age = 31; // set member directly
|
|
1604
|
+
```
|
|
1605
|
+
|
|
1606
|
+
### The `this->` Keyword
|
|
1607
|
+
|
|
1608
|
+
Inside class methods, use `this->` to access instance members:
|
|
1609
|
+
|
|
1610
|
+
```cssl
|
|
1611
|
+
class Counter {
|
|
1612
|
+
int count;
|
|
1613
|
+
|
|
1614
|
+
void Counter() {
|
|
1615
|
+
this->count = 0;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
void increment() {
|
|
1619
|
+
this->count = this->count + 1;
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
void add(int n) {
|
|
1623
|
+
this->count = this->count + n;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
int get() {
|
|
1627
|
+
return this->count;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
Counter c = new Counter();
|
|
1632
|
+
c.increment();
|
|
1633
|
+
c.add(5);
|
|
1634
|
+
printl(c.get()); // prints: 6
|
|
1635
|
+
```
|
|
1636
|
+
|
|
1637
|
+
### Constructor Variations
|
|
1638
|
+
|
|
1639
|
+
```cssl
|
|
1640
|
+
class MyClass {
|
|
1641
|
+
// Constructor with same name as class
|
|
1642
|
+
void MyClass(int x) {
|
|
1643
|
+
this->value = x;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
// Alternative: use __init__
|
|
1648
|
+
class MyClass2 {
|
|
1649
|
+
void __init__(int x) {
|
|
1650
|
+
this->value = x;
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
```
|
|
1654
|
+
|
|
1655
|
+
### Method Chaining
|
|
1656
|
+
|
|
1657
|
+
```cssl
|
|
1658
|
+
class Builder {
|
|
1659
|
+
string result;
|
|
1660
|
+
|
|
1661
|
+
void Builder() {
|
|
1662
|
+
this->result = "";
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
Builder add(string s) {
|
|
1666
|
+
this->result = this->result + s;
|
|
1667
|
+
return this;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
string build() {
|
|
1671
|
+
return this->result;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
Builder b = new Builder();
|
|
1676
|
+
string result = b.add("Hello ").add("World!").build();
|
|
1677
|
+
printl(result); // prints: "Hello World!"
|
|
1678
|
+
```
|
|
1679
|
+
|
|
1680
|
+
---
|
|
1681
|
+
|
|
1682
|
+
## Map Container
|
|
1683
|
+
|
|
1684
|
+
The `map<>` type provides C++ style ordered key-value storage.
|
|
1685
|
+
|
|
1686
|
+
### Creating Maps
|
|
1687
|
+
|
|
1688
|
+
```cssl
|
|
1689
|
+
map<string, int> ages;
|
|
1690
|
+
map<string, string> config;
|
|
1691
|
+
```
|
|
1692
|
+
|
|
1693
|
+
### Basic Operations
|
|
1694
|
+
|
|
1695
|
+
```cssl
|
|
1696
|
+
map<string, int> ages;
|
|
1697
|
+
|
|
1698
|
+
// Insert values
|
|
1699
|
+
ages.insert("Alice", 30);
|
|
1700
|
+
ages.insert("Bob", 25);
|
|
1701
|
+
|
|
1702
|
+
// Find values
|
|
1703
|
+
int age = ages.find("Alice"); // returns 30
|
|
1704
|
+
|
|
1705
|
+
// Check existence
|
|
1706
|
+
if (ages.contains("Alice")) {
|
|
1707
|
+
printl("Found!");
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
// Erase entries
|
|
1711
|
+
ages.erase("Bob");
|
|
1712
|
+
|
|
1713
|
+
// Get with exception if not found
|
|
1714
|
+
int a = ages.at("Alice"); // throws if not found
|
|
1715
|
+
|
|
1716
|
+
// Size and empty check
|
|
1717
|
+
int size = ages.size();
|
|
1718
|
+
bool empty = ages.empty();
|
|
1719
|
+
```
|
|
1720
|
+
|
|
1721
|
+
### Iteration and Bounds
|
|
1722
|
+
|
|
1723
|
+
```cssl
|
|
1724
|
+
map<string, int> data;
|
|
1725
|
+
data.insert("apple", 1);
|
|
1726
|
+
data.insert("banana", 2);
|
|
1727
|
+
data.insert("cherry", 3);
|
|
1728
|
+
|
|
1729
|
+
// Get first/last elements
|
|
1730
|
+
tuple first = data.begin(); // ("apple", 1)
|
|
1731
|
+
tuple last = data.end(); // ("cherry", 3)
|
|
1732
|
+
|
|
1733
|
+
// Find bounds (for sorted keys)
|
|
1734
|
+
string lb = data.lower_bound("b"); // "banana" (first key >= "b")
|
|
1735
|
+
string ub = data.upper_bound("b"); // "cherry" (first key > "b")
|
|
1736
|
+
```
|
|
1737
|
+
|
|
1738
|
+
---
|
|
1739
|
+
|
|
1160
1740
|
## Structures
|
|
1161
1741
|
|
|
1162
1742
|
Structures are user-defined data types.
|
|
@@ -1457,12 +2037,25 @@ print(result) # ["Missing colon after def"]
|
|
|
1457
2037
|
|
|
1458
2038
|
| Operator | Type | Description |
|
|
1459
2039
|
|----------|------|-------------|
|
|
1460
|
-
| `<<==` | CodeInfusion | Replace |
|
|
1461
|
-
| `+<<==` | CodeInfusion | Add |
|
|
1462
|
-
| `-<<==` | CodeInfusion | Remove |
|
|
1463
|
-
|
|
|
1464
|
-
|
|
|
1465
|
-
|
|
|
2040
|
+
| `<<==` | CodeInfusion | Replace function |
|
|
2041
|
+
| `+<<==` | CodeInfusion | Add code (before) |
|
|
2042
|
+
| `-<<==` | CodeInfusion | Remove code |
|
|
2043
|
+
| `<==` | ValueCapture | Capture/assign value |
|
|
2044
|
+
| `+<==` | BruteInjection | Copy data |
|
|
2045
|
+
| `-<==` | BruteInjection | Move data |
|
|
2046
|
+
| `==>` | BruteInjection | Replace data |
|
|
2047
|
+
| `==>-` | BruteInjection | Remove matching items |
|
|
2048
|
+
|
|
2049
|
+
### Special Syntax
|
|
2050
|
+
|
|
2051
|
+
| Syntax | Description |
|
|
2052
|
+
|--------|-------------|
|
|
2053
|
+
| `%identifier` | Capture value at registration time |
|
|
2054
|
+
| `json::func()` | Namespace function call |
|
|
2055
|
+
| `@name` | Access global variable |
|
|
2056
|
+
| `$name` | Access shared Python object |
|
|
2057
|
+
| `s@name` | Self-reference to struct |
|
|
2058
|
+
| `r@name` | Global variable declaration |
|
|
1466
2059
|
|
|
1467
2060
|
---
|
|
1468
2061
|
|
|
@@ -1479,4 +2072,4 @@ print(result) # ["Missing colon after def"]
|
|
|
1479
2072
|
|
|
1480
2073
|
---
|
|
1481
2074
|
|
|
1482
|
-
*CSSL v3.
|
|
2075
|
+
*CSSL v3.6.3 - Developed as part of IncludeCPP*
|