IncludeCPP 4.2.2__py3-none-any.whl → 4.3.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.
@@ -1,1682 +1,1720 @@
1
- # CSSL - C-Style Scripting Language
1
+ # CSSL - C-Style Scripting Language
2
2
 
3
- > Version 4.1.0 | A modern scripting language with C++-style syntax and unique features like CodeInfusion, BruteInjection, Python Interop, and Multi-Language Support.
3
+ > Version 4.1.0 | A modern scripting language with C++-style syntax and unique features like CodeInfusion, BruteInjection, Python Interop, and Multi-Language Support.
4
4
 
5
- ---
5
+ ---
6
6
 
7
- ## Table of Contents
7
+ ## Table of Contents
8
8
 
9
- 1. [Quick Start](#quick-start)
10
- 2. [Syntax Basics](#syntax-basics)
11
- 3. [Data Types](#data-types)
12
- 4. [Variables & Globals](#variables--globals)
13
- 5. [Operators](#operators)
14
- 6. [Control Flow](#control-flow)
15
- 7. [Functions](#functions)
16
- 8. [Classes & OOP](#classes--oop)
17
- 9. [Container Types](#container-types)
18
- 10. [Built-in Functions](#built-in-functions)
19
- 11. [CodeInfusion](#codeinfusion)
20
- 12. [BruteInjection](#bruteinjection)
21
- 13. [Value Capture](#value-capture)
22
- 14. [Module System](#module-system)
23
- 15. [Multi-Language Support](#multi-language-support)
24
- 16. [Error Handling](#error-handling)
25
- 17. [Quick Reference](#quick-reference)
9
+ 1. [Quick Start](#quick-start)
10
+ 2. [Syntax Basics](#syntax-basics)
11
+ 3. [Data Types](#data-types)
12
+ 4. [Variables & Globals](#variables--globals)
13
+ 5. [Operators](#operators)
14
+ 6. [Control Flow](#control-flow)
15
+ 7. [Functions](#functions)
16
+ 8. [Classes & OOP](#classes--oop)
17
+ 9. [Container Types](#container-types)
18
+ 10. [Built-in Functions](#built-in-functions)
19
+ 11. [CodeInfusion](#codeinfusion)
20
+ 12. [BruteInjection](#bruteinjection)
21
+ 13. [Value Capture](#value-capture)
22
+ 14. [Module System](#module-system)
23
+ 15. [Multi-Language Support](#multi-language-support)
24
+ 16. [Error Handling](#error-handling)
25
+ 17. [Quick Reference](#quick-reference)
26
26
 
27
- ---
27
+ ---
28
28
 
29
- ## Quick Start
29
+ ## Quick Start
30
30
 
31
- ### Installation
31
+ ### Installation
32
32
 
33
- ```bash
34
- pip install includecpp
35
- ```
33
+ ```bash
34
+ pip install includecpp
35
+ ```
36
36
 
37
- ### Python Usage
37
+ ### Python Usage
38
38
 
39
- ```python
40
- from includecpp import CSSL
39
+ ```python
40
+ from includecpp import CSSL
41
41
 
42
- # Execute CSSL code
43
- CSSL.run('''
44
- printl("Hello CSSL!");
45
- ''')
42
+ # Execute CSSL code
43
+ CSSL.run('''
44
+ printl("Hello CSSL!");
45
+ ''')
46
46
 
47
- # With parameters and return value
48
- result = CSSL.run('''
49
- string name = parameter.get(0);
50
- printl("Hello " + name);
51
- parameter.return(true);
52
- ''', "World")
47
+ # With parameters and return value
48
+ result = CSSL.run('''
49
+ string name = parameter.get(0);
50
+ printl("Hello " + name);
51
+ parameter.return(true);
52
+ ''', "World")
53
53
 
54
- print(result) # True
55
- ```
54
+ print(result) # True
55
+ ```
56
56
 
57
- ### CLI Execution
57
+ ### CLI Execution
58
58
 
59
- ```bash
60
- # Execute CSSL file
61
- python -m includecpp cssl exec myfile.cssl
59
+ ```bash
60
+ # Execute CSSL file
61
+ python -m includecpp cssl exec myfile.cssl
62
62
 
63
- # Create module from Python file
64
- python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
65
- ```
63
+ # Create module from Python file
64
+ python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
65
+ ```
66
66
 
67
- ### First Script
68
-
69
- ```cssl
70
- // Variables
71
- string name = "CSSL";
72
- int version = 3;
73
-
74
- // Output
75
- printl("Welcome to " + name);
76
-
77
- // Function
78
- void greet(string msg) {
79
- printl(msg);
80
- }
67
+ ### First Script
81
68
 
82
- greet("Hello World!");
83
- ```
69
+ ```cssl
70
+ // Variables
71
+ string name = "CSSL";
72
+ int version = 3;
84
73
 
85
- ---
74
+ // Output
75
+ printl("Welcome to " + name);
86
76
 
87
- ## Syntax Basics
77
+ // Function
78
+ void greet(string msg) {
79
+ printl(msg);
80
+ }
81
+
82
+ greet("Hello World!");
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Syntax Basics
88
+
89
+ ### Comments
90
+
91
+ ```cssl
92
+ // Single-line comment (C-style)
93
+ # Single-line comment (Python-style)
94
+ ```
95
+
96
+ ### Semicolons
97
+
98
+ Semicolons are optional but recommended for clarity.
88
99
 
89
- ### Comments
100
+ ```cssl
101
+ printl("Hello") // Works
102
+ printl("Hello"); // Also works (recommended)
103
+ ```
90
104
 
91
- ```cssl
92
- // Single-line comment (C-style)
93
- # Single-line comment (Python-style)
94
- ```
105
+ ### I/O Functions
95
106
 
96
- ### Semicolons
107
+ ```cssl
108
+ // Output
109
+ printl("Text"); // Print with newline
110
+ print("No newline"); // Print without newline
111
+ debug("Debug info"); // Print with [DEBUG] prefix
112
+ error("Error message"); // Print with [ERROR] prefix
113
+ warn("Warning"); // Print with [WARN] prefix
114
+ log("INFO", "Message"); // Print with custom prefix
97
115
 
98
- Semicolons are optional but recommended for clarity.
116
+ // Input
117
+ string name = input("Enter your name: ");
118
+ int age = int(input("Enter your age: "));
119
+ string raw = input(); // Without prompt
120
+ ```
99
121
 
100
- ```cssl
101
- printl("Hello") // Works
102
- printl("Hello"); // Also works (recommended)
103
- ```
122
+ ---
104
123
 
105
- ### I/O Functions
124
+ ## Data Types
106
125
 
107
- ```cssl
108
- // Output
109
- printl("Text"); // Print with newline
110
- print("No newline"); // Print without newline
111
- debug("Debug info"); // Print with [DEBUG] prefix
112
- error("Error message"); // Print with [ERROR] prefix
113
- warn("Warning"); // Print with [WARN] prefix
114
- log("INFO", "Message"); // Print with custom prefix
126
+ ### Primitive Types
115
127
 
116
- // Input
117
- string name = input("Enter your name: ");
118
- int age = int(input("Enter your age: "));
119
- string raw = input(); // Without prompt
120
- ```
128
+ | Type | Description | Example |
129
+ |------|-------------|---------|
130
+ | `int` | Integer | `int x = 42;` |
131
+ | `float` | Floating point | `float f = 3.14;` |
132
+ | `string` | Text string | `string s = "Hello";` |
133
+ | `bool` | Boolean | `bool b = true;` |
134
+ | `dynamic` | Any type (flexible) | `dynamic x = "text";` |
135
+ | `void` | No return value | `void func() { }` |
136
+ | `null` | Absence of value | `dynamic x = null;` |
121
137
 
122
- ---
138
+ ### Generic Container Types
123
139
 
124
- ## Data Types
140
+ | Type | Description | Example |
141
+ |------|-------------|---------|
142
+ | `stack<T>` | LIFO stack | `stack<string> names;` |
143
+ | `vector<T>` | Dynamic array | `vector<int> nums;` |
144
+ | `array<T>` | Standard array | `array<float> values;` |
145
+ | `map<K,V>` | Ordered key-value | `map<string, int> ages;` |
146
+ | `list` | Python-like list | `list items = [1, 2, 3];` |
147
+ | `dict` | Dictionary | `dict data = {"a": 1};` |
148
+ | `datastruct<T>` | Universal container | `datastruct<string> data;` |
149
+ | `iterator<T>` | Programmable iterator | `iterator<int> it;` |
150
+ | `shuffled<T>` | Multi-value returns | `shuffled<string> results;` |
151
+ | `combo<T>` | Filter/search space | `combo<string> search;` |
125
152
 
126
- ### Primitive Types
153
+ ### Type Conversion
127
154
 
128
- | Type | Description | Example |
129
- |------|-------------|---------|
130
- | `int` | Integer | `int x = 42;` |
131
- | `float` | Floating point | `float f = 3.14;` |
132
- | `string` | Text string | `string s = "Hello";` |
133
- | `bool` | Boolean | `bool b = true;` |
134
- | `dynamic` | Any type (flexible) | `dynamic x = "text";` |
135
- | `void` | No return value | `void func() { }` |
136
- | `null` | Absence of value | `dynamic x = null;` |
155
+ ```cssl
156
+ int("42"); // String to int: 42
157
+ float("3.14"); // String to float: 3.14
158
+ str(42); // Int to string: "42"
159
+ bool(1); // Int to bool: true
160
+ int("ff", 16); // Hex to int: 255
161
+ ```
137
162
 
138
- ### Generic Container Types
163
+ ### Type Checking
139
164
 
140
- | Type | Description | Example |
141
- |------|-------------|---------|
142
- | `stack<T>` | LIFO stack | `stack<string> names;` |
143
- | `vector<T>` | Dynamic array | `vector<int> nums;` |
144
- | `array<T>` | Standard array | `array<float> values;` |
145
- | `map<K,V>` | Ordered key-value | `map<string, int> ages;` |
146
- | `list` | Python-like list | `list items = [1, 2, 3];` |
147
- | `dict` | Dictionary | `dict data = {"a": 1};` |
148
- | `datastruct<T>` | Universal container | `datastruct<string> data;` |
149
- | `iterator<T>` | Programmable iterator | `iterator<int> it;` |
150
- | `shuffled<T>` | Multi-value returns | `shuffled<string> results;` |
151
- | `combo<T>` | Filter/search space | `combo<string> search;` |
165
+ ```cssl
166
+ typeof(42); // "int"
167
+ typeof("hello"); // "str"
168
+ isinstance(42, "int"); // true
169
+ isint(42); // true
170
+ isstr("hello"); // true
171
+ isnull(null); // true
172
+ ```
152
173
 
153
- ### Type Conversion
174
+ ---
154
175
 
155
- ```cssl
156
- int("42"); // String to int: 42
157
- float("3.14"); // String to float: 3.14
158
- str(42); // Int to string: "42"
159
- bool(1); // Int to bool: true
160
- int("ff", 16); // Hex to int: 255
161
- ```
176
+ ## Variables & Globals
162
177
 
163
- ### Type Checking
178
+ ### Scope Behavior
164
179
 
165
- ```cssl
166
- typeof(42); // "int"
167
- typeof("hello"); // "str"
168
- isinstance(42, "int"); // true
169
- isint(42); // true
170
- isstr("hello"); // true
171
- isnull(null); // true
172
- ```
180
+ Variables are **local by default**. Each function/class has its own scope - variables defined inside a function only exist within that function.
173
181
 
174
- ---
182
+ ```cssl
183
+ define myFunction() {
184
+ string name = "Alice"; // Local to myFunction
185
+ printl(name); // Works
186
+ }
187
+
188
+ myFunction();
189
+ // printl(name); // Error! 'name' doesn't exist here
175
190
 
176
- ## Variables & Globals
191
+ // Same variable name in different scopes = different variables
192
+ string name = "Bob";
177
193
 
178
- ### Scope Behavior
194
+ define otherFunction() {
195
+ string name = "Charlie"; // Different variable, local to otherFunction
196
+ printl(name); // "Charlie"
197
+ }
179
198
 
180
- Variables are **local by default**. Each function/class has its own scope - variables defined inside a function only exist within that function.
199
+ otherFunction();
200
+ printl(name); // "Bob" - outer scope unchanged
201
+ ```
181
202
 
182
- ```cssl
183
- define myFunction() {
184
- string name = "Alice"; // Local to myFunction
185
- printl(name); // Works
186
- }
187
-
188
- myFunction();
189
- // printl(name); // Error! 'name' doesn't exist here
190
-
191
- // Same variable name in different scopes = different variables
192
- string name = "Bob";
193
-
194
- define otherFunction() {
195
- string name = "Charlie"; // Different variable, local to otherFunction
196
- printl(name); // "Charlie"
197
- }
198
-
199
- otherFunction();
200
- printl(name); // "Bob" - outer scope unchanged
201
- ```
202
-
203
- ### Everything is Local by Default
203
+ ### Everything is Local by Default
204
204
 
205
- All elements (variables, functions, classes) are **local by default** and must be explicitly marked global.
206
-
207
- | Element | Local (default) | Global |
208
- |---------|-----------------|--------|
209
- | **Variables** | `string x = "text";` | `global x = "text";` or `@x = "text";` |
210
- | **Functions** | `define myFunc() { }` | `global define myFunc() { }` or `define @myFunc() { }` |
211
- | **Typed functions** | `void myFunc() { }` | `global void myFunc() { }` or `void @myFunc() { }` |
212
- | **Classes** | `class MyClass { }` | `global class MyClass { }` or `class @MyClass { }` |
205
+ All elements (variables, functions, classes) are **local by default** and must be explicitly marked global.
213
206
 
214
- ### Local Variables
207
+ | Element | Local (default) | Global |
208
+ |---------|-----------------|--------|
209
+ | **Variables** | `string x = "text";` | `global x = "text";` or `@x = "text";` |
210
+ | **Functions** | `define myFunc() { }` | `global define myFunc() { }` or `define @myFunc() { }` |
211
+ | **Typed functions** | `void myFunc() { }` | `global void myFunc() { }` or `void @myFunc() { }` |
212
+ | **Classes** | `class MyClass { }` | `global class MyClass { }` or `class @MyClass { }` |
215
213
 
216
- ```cssl
217
- string name = "Alice";
218
- int count = 10;
219
- float price = 19.99;
220
- bool active = true;
221
- ```
214
+ ### Local Variables
222
215
 
223
- ### Global Variables
216
+ ```cssl
217
+ string name = "Alice";
218
+ int count = 10;
219
+ float price = 19.99;
220
+ bool active = true;
221
+ ```
224
222
 
225
- Use `global` keyword or `@`/`r@` prefix to create/access global variables:
223
+ ### Global Variables
226
224
 
227
- ```cssl
228
- // Declaration with 'global' keyword
229
- global myGlobal = "visible everywhere";
225
+ Use `global` keyword or `@`/`r@` prefix to create/access global variables:
230
226
 
231
- // Access with '@' prefix
232
- printl(@myGlobal);
227
+ ```cssl
228
+ // Declaration with 'global' keyword
229
+ global myGlobal = "visible everywhere";
233
230
 
234
- // Direct global assignment with @ or r@
235
- @anotherGlobal = "also global";
236
- r@yetAnother = "and this too";
231
+ // Access with '@' prefix
232
+ printl(@myGlobal);
237
233
 
238
- // Always read globals with @
239
- printl(@x);
240
- ```
234
+ // Direct global assignment with @ or r@
235
+ @anotherGlobal = "also global";
236
+ r@yetAnother = "and this too";
241
237
 
242
- ### Global Functions
238
+ // Always read globals with @
239
+ printl(@x);
240
+ ```
243
241
 
244
- ```cssl
245
- // Global function with 'global' keyword
246
- global define helper() {
247
- printl("I'm global!");
248
- }
242
+ ### Global Functions
249
243
 
250
- // Alternative: @ prefix syntax
251
- define @anotherHelper() {
252
- printl("Also global!");
253
- }
244
+ ```cssl
245
+ // Global function with 'global' keyword
246
+ global define helper() {
247
+ printl("I'm global!");
248
+ }
254
249
 
255
- // Global typed function
256
- global void @utilityFunc(string msg) {
257
- printl(msg);
258
- }
259
- ```
250
+ // Alternative: @ prefix syntax
251
+ define @anotherHelper() {
252
+ printl("Also global!");
253
+ }
260
254
 
261
- ### Global Classes
255
+ // Global typed function
256
+ global void @utilityFunc(string msg) {
257
+ printl(msg);
258
+ }
259
+ ```
262
260
 
263
- ```cssl
264
- // Global class with 'global' keyword
265
- global class SharedClass {
266
- string value;
267
- }
261
+ ### Global Classes
268
262
 
269
- // Alternative: @ prefix syntax
270
- class @AnotherShared {
271
- int count;
272
- }
263
+ ```cssl
264
+ // Global class with 'global' keyword
265
+ global class SharedClass {
266
+ string value;
267
+ }
273
268
 
274
- // Instantiate global class with @ prefix
275
- instance = new @SharedClass();
276
- ```
269
+ // Alternative: @ prefix syntax
270
+ class @AnotherShared {
271
+ int count;
272
+ }
277
273
 
278
- ### Prefix Reference
274
+ // Instantiate global class with @ prefix
275
+ instance = new @SharedClass();
276
+ ```
277
+
278
+ ### Prefix Reference
279
+
280
+ | Prefix | Name | Usage |
281
+ |--------|------|-------|
282
+ | `@` | Global/Module | Read global vars, access modules: `@myVar`, `@os.getcwd()` |
283
+ | `r@` | Global Ref | Assign to global scope: `r@name = value` |
284
+ | `$` | Shared | Access Python objects: `$counter.value` |
285
+ | `%` | Captured | Capture value at registration: `%version` |
286
+ | `s@` | Self-Ref | Access global structs: `s@Backend.config` |
287
+
288
+ ### Shared Objects ($)
289
+
290
+ Access Python objects shared via `CSSL.share()`:
291
+
292
+ ```cssl
293
+ // Access shared Python object
294
+ $counter.value = 100;
295
+ $counter.increment();
296
+
297
+ // Delete shared object
298
+ delete("counter");
299
+ ```
300
+
301
+ ### Captured References (%)
302
+
303
+ Capture value at registration time:
304
+
305
+ ```cssl
306
+ string version = "1.0";
307
+ savedVersion <<== { %version; }
308
+ version = "2.0";
309
+ printl(savedVersion); // Still "1.0"
310
+ ```
311
+
312
+ ### Class Member Access (this->)
313
+
314
+ Inside classes, use `this->` to access instance members:
315
+
316
+ ```cssl
317
+ class Person {
318
+ string name;
319
+
320
+ void setName(string n) {
321
+ this->name = n; // Instance member
322
+ }
323
+ }
324
+ ```
325
+
326
+ ---
327
+
328
+ ## Operators
329
+
330
+ ### Arithmetic
331
+
332
+ | Operator | Description | Example |
333
+ |----------|-------------|---------|
334
+ | `+` | Addition / Concatenation | `a + b` |
335
+ | `-` | Subtraction | `a - b` |
336
+ | `*` | Multiplication | `a * b` |
337
+ | `/` | Division | `a / b` |
338
+ | `%` | Modulo | `a % b` |
339
+
340
+ ### Comparison
341
+
342
+ | Operator | Description | Example |
343
+ |----------|-------------|---------|
344
+ | `==` | Equal | `a == b` |
345
+ | `!=` | Not equal | `a != b` |
346
+ | `<` | Less than | `a < b` |
347
+ | `>` | Greater than | `a > b` |
348
+ | `<=` | Less or equal | `a <= b` |
349
+ | `>=` | Greater or equal | `a >= b` |
350
+
351
+ ### Logical
352
+
353
+ | Operator | Description | Example |
354
+ |----------|-------------|---------|
355
+ | `&&` | AND | `a && b` |
356
+ | `\|\|` | OR | `a \|\| b` |
357
+ | `!` | NOT | `!a` |
358
+ | `and` | AND (keyword) | `a and b` |
359
+ | `or` | OR (keyword) | `a or b` |
360
+ | `not` | NOT (keyword) | `not a` |
361
+
362
+ ### Increment/Decrement (in for-loops)
363
+
364
+ | Operator | Description | Example |
365
+ |----------|-------------|---------|
366
+ | `++` | Increment | `i++` |
367
+ | `--` | Decrement | `i--` |
368
+ | `+=` | Add assign | `i += 1` |
369
+ | `-=` | Subtract assign | `i -= 1` |
370
+
371
+ ---
372
+
373
+ ## Control Flow
374
+
375
+ ### If / Else If / Else
376
+
377
+ ```cssl
378
+ if (x < 5) {
379
+ printl("Small");
380
+ } else if (x < 15) {
381
+ printl("Medium");
382
+ } else {
383
+ printl("Large");
384
+ }
279
385
 
280
- | Prefix | Name | Usage |
281
- |--------|------|-------|
282
- | `@` | Global/Module | Read global vars, access modules: `@myVar`, `@os.getcwd()` |
283
- | `r@` | Global Ref | Assign to global scope: `r@name = value` |
284
- | `$` | Shared | Access Python objects: `$counter.value` |
285
- | `%` | Captured | Capture value at registration: `%version` |
286
- | `s@` | Self-Ref | Access global structs: `s@Backend.config` |
386
+ // elif also works
387
+ if (x < 5) {
388
+ printl("Small");
389
+ } elif (x < 15) {
390
+ printl("Medium");
391
+ }
392
+ ```
393
+
394
+ ### Switch / Case
395
+
396
+ ```cssl
397
+ switch (day) {
398
+ case 1:
399
+ printl("Monday");
400
+ break;
401
+ case 2:
402
+ printl("Tuesday");
403
+ break;
404
+ default:
405
+ printl("Other");
406
+ }
407
+ ```
408
+
409
+ ### Parameter Switch (Open Params)
410
+
411
+ Pattern matching on which named parameters were provided to a function.
412
+
413
+ ```cssl
414
+ define greet(...) {
415
+ switch (open) {
416
+ case name & age:
417
+ printl("Hello " + OpenFind<string, "name"> + ", age " + OpenFind<int, "age">);
418
+ case name:
419
+ printl("Hello " + OpenFind<string, "name">);
420
+ except name:
421
+ printl("No name provided!");
422
+ default:
423
+ printl("Unknown parameters");
424
+ always:
425
+ printl("-- greeting complete --");
426
+ finally:
427
+ printl("== cleanup ==");
428
+ }
429
+ }
287
430
 
288
- ### Shared Objects ($)
431
+ greet(name="Alice"); // case name matches
432
+ greet(name="Bob", age=25); // case name & age matches
433
+ greet(foo="bar"); // except name matches (no name)
434
+ ```
435
+
436
+ **Syntax:**
437
+ - `case param:` - executes if parameter exists
438
+ - `case param1 & param2:` - executes if ALL parameters exist
439
+ - `case param1 & not param2:` - AND with negation
440
+ - `except param:` - executes if parameter does NOT exist
441
+ - `default:` - executes if no case matched
442
+ - `always:` - executes after any matching case (not after except/default)
443
+ - `finally:` - always executes (cleanup, like try/finally)
444
+
445
+ > **Note:** Cases are checked in order. Place more specific cases first (`case name & age` before `case name`).
446
+
447
+ ### While Loop
448
+
449
+ ```cssl
450
+ int i = 0;
451
+ while (i < 5) {
452
+ printl(i);
453
+ i = i + 1;
454
+ }
455
+ ```
289
456
 
290
- Access Python objects shared via `CSSL.share()`:
457
+ ### For Loop (Python-Style)
291
458
 
292
- ```cssl
293
- // Access shared Python object
294
- $counter.value = 100;
295
- $counter.increment();
459
+ ```cssl
460
+ // Range-based
461
+ for (i in range(5)) {
462
+ printl(i); // 0, 1, 2, 3, 4
463
+ }
296
464
 
297
- // Delete shared object
298
- delete("counter");
299
- ```
465
+ // With start and end
466
+ for (i in range(10, 15)) {
467
+ printl(i); // 10, 11, 12, 13, 14
468
+ }
300
469
 
301
- ### Captured References (%)
470
+ // With step
471
+ for (i in range(0, 10, 2)) {
472
+ printl(i); // 0, 2, 4, 6, 8
473
+ }
474
+ ```
302
475
 
303
- Capture value at registration time:
304
-
305
- ```cssl
306
- string version = "1.0";
307
- savedVersion <<== { %version; }
308
- version = "2.0";
309
- printl(savedVersion); // Still "1.0"
310
- ```
311
-
312
- ### Class Member Access (this->)
313
-
314
- Inside classes, use `this->` to access instance members:
315
-
316
- ```cssl
317
- class Person {
318
- string name;
319
-
320
- void setName(string n) {
321
- this->name = n; // Instance member
322
- }
323
- }
324
- ```
325
-
326
- ---
327
-
328
- ## Operators
329
-
330
- ### Arithmetic
331
-
332
- | Operator | Description | Example |
333
- |----------|-------------|---------|
334
- | `+` | Addition / Concatenation | `a + b` |
335
- | `-` | Subtraction | `a - b` |
336
- | `*` | Multiplication | `a * b` |
337
- | `/` | Division | `a / b` |
338
- | `%` | Modulo | `a % b` |
339
-
340
- ### Comparison
341
-
342
- | Operator | Description | Example |
343
- |----------|-------------|---------|
344
- | `==` | Equal | `a == b` |
345
- | `!=` | Not equal | `a != b` |
346
- | `<` | Less than | `a < b` |
347
- | `>` | Greater than | `a > b` |
348
- | `<=` | Less or equal | `a <= b` |
349
- | `>=` | Greater or equal | `a >= b` |
350
-
351
- ### Logical
352
-
353
- | Operator | Description | Example |
354
- |----------|-------------|---------|
355
- | `&&` | AND | `a && b` |
356
- | `\|\|` | OR | `a \|\| b` |
357
- | `!` | NOT | `!a` |
358
- | `and` | AND (keyword) | `a and b` |
359
- | `or` | OR (keyword) | `a or b` |
360
- | `not` | NOT (keyword) | `not a` |
361
-
362
- ### Increment/Decrement (in for-loops)
363
-
364
- | Operator | Description | Example |
365
- |----------|-------------|---------|
366
- | `++` | Increment | `i++` |
367
- | `--` | Decrement | `i--` |
368
- | `+=` | Add assign | `i += 1` |
369
- | `-=` | Subtract assign | `i -= 1` |
370
-
371
- ---
372
-
373
- ## Control Flow
374
-
375
- ### If / Else If / Else
376
-
377
- ```cssl
378
- if (x < 5) {
379
- printl("Small");
380
- } else if (x < 15) {
381
- printl("Medium");
382
- } else {
383
- printl("Large");
384
- }
385
-
386
- // elif also works
387
- if (x < 5) {
388
- printl("Small");
389
- } elif (x < 15) {
390
- printl("Medium");
391
- }
392
- ```
393
-
394
- ### Switch / Case
395
-
396
- ```cssl
397
- switch (day) {
398
- case 1:
399
- printl("Monday");
400
- break;
401
- case 2:
402
- printl("Tuesday");
403
- break;
404
- default:
405
- printl("Other");
406
- }
407
- ```
408
-
409
- ### While Loop
410
-
411
- ```cssl
412
- int i = 0;
413
- while (i < 5) {
414
- printl(i);
415
- i = i + 1;
416
- }
417
- ```
418
-
419
- ### For Loop (Python-Style)
420
-
421
- ```cssl
422
- // Range-based
423
- for (i in range(5)) {
424
- printl(i); // 0, 1, 2, 3, 4
425
- }
426
-
427
- // With start and end
428
- for (i in range(10, 15)) {
429
- printl(i); // 10, 11, 12, 13, 14
430
- }
431
-
432
- // With step
433
- for (i in range(0, 10, 2)) {
434
- printl(i); // 0, 2, 4, 6, 8
435
- }
436
- ```
437
-
438
- ### For Loop (C-Style)
439
-
440
- ```cssl
441
- for (int i = 0; i < 10; i++) {
442
- printl(i);
443
- }
444
-
445
- for (int i = 10; i > 0; i--) {
446
- printl(i);
447
- }
448
- ```
449
-
450
- ### Foreach
451
-
452
- ```cssl
453
- stack<string> names;
454
- names.push("Alice");
455
- names.push("Bob");
456
-
457
- // Syntax 1
458
- foreach (name in names) {
459
- printl(name);
460
- }
461
-
462
- // Syntax 2
463
- foreach names as name {
464
- printl(name);
465
- }
466
- ```
467
-
468
- ### Break & Continue
469
-
470
- ```cssl
471
- for (i in range(10)) {
472
- if (i == 5) break; // Exit loop
473
- if (i == 3) continue; // Skip iteration
474
- printl(i);
475
- }
476
- ```
477
-
478
- ---
479
-
480
- ## Functions
481
-
482
- ### Basic Syntax
483
-
484
- ```cssl
485
- // Without return
486
- void sayHello() {
487
- printl("Hello!");
488
- }
489
-
490
- // With return
491
- string getName() {
492
- return "CSSL";
493
- }
494
-
495
- // With parameters
496
- int add(int a, int b) {
497
- return a + b;
498
- }
499
- ```
500
-
501
- ### Define Functions
502
-
503
- ```cssl
504
- // Simple function without type
505
- define greet() {
506
- printl("Hello!");
507
- }
508
-
509
- // With parameters
510
- define greet(string name) {
511
- printl("Hello " + name);
512
- }
513
- ```
514
-
515
- ### Function Modifiers
516
-
517
- | Modifier | Description |
518
- |----------|-------------|
519
- | `undefined` | Silently ignore errors |
520
- | `closed` | Block external CodeInfusion |
521
- | `private` | Block all CodeInfusion |
522
- | `virtual` | Import-cycle safe |
523
- | `meta` | Source function (any return type allowed) |
524
- | `super` | Force execution (no exceptions) |
525
- | `open` | Accept any parameters |
526
- | `shuffled` | Return multiple values |
527
- | `const` | Immutable function (like C++) |
528
- | `static` | Static method/function |
529
- | `public` | Explicitly public (default) |
530
- | `global` | Makes function globally accessible |
531
-
532
- **Flexible Modifier Order**: Modifiers can appear in any order before the function declaration.
533
-
534
- ```cssl
535
- // Ignore errors
536
- undefined void mayFail() {
537
- riskyOperation();
538
- }
539
-
540
- // Protected from injection
541
- closed void protected() {
542
- printl("Protected");
543
- }
544
-
545
- // Multiple returns
546
- shuffled string getNames() {
547
- return "Alice", "Bob", "Charlie";
548
- }
549
-
550
- a, b, c = getNames();
551
-
552
- // Any order of modifiers works
553
- private string *@Myfunc() {
554
- println("Hello from global private non-null function!");
555
- return "Hey";
556
- }
557
-
558
- // Const function
559
- const void immutableFunc() {
560
- printl("I'm constant");
561
- }
562
-
563
- // Global private const
564
- global private const void @MyGlobalFunc() {
565
- printl("Complex modifiers in any order");
566
- }
567
- ```
568
-
569
- ### Typed Functions (Enforced Returns)
570
-
571
- Functions with a return type (like `int`, `string`, `vector<T>`) MUST return that type:
572
-
573
- ```cssl
574
- // MUST return string
575
- string getName() {
576
- return "Alice"; // OK
577
- // return 42; // Error! Expected string
578
- }
579
-
580
- // MUST return int
581
- int getAge() {
582
- return 30; // OK
583
- }
584
-
585
- // meta modifier bypasses type checking
586
- meta datastruct<string> getData() {
587
- return "just a string"; // OK despite declared type
588
- return 42; // Also OK - meta allows any type
589
- }
590
- ```
591
-
592
- ### Non-Null Functions (*)
593
-
594
- Functions that must never return null:
595
-
596
- ```cssl
597
- // Non-null function
598
- define *alwaysReturns() {
599
- return "Always a value";
600
- }
601
-
602
- // Non-null assertion on value
603
- this->name = *$System.os; // Error if null
604
- ```
605
-
606
- ### Type Exclusion Filter (*[type])
607
-
608
- Functions that must NOT return a specific type:
609
-
610
- ```cssl
611
- // Must NOT return string
612
- shuffled *[string] getNumbers() {
613
- return 1, 2, 3; // OK
614
- // return "text"; // Error!
615
- }
616
-
617
- // Must NOT return null
618
- define *[null] getValue() {
619
- return 42; // OK
620
- }
621
- ```
476
+ ### For Loop (C-Style)
622
477
 
623
- ### Open Parameters
478
+ ```cssl
479
+ for (int i = 0; i < 10; i++) {
480
+ printl(i);
481
+ }
624
482
 
625
- ```cssl
626
- open define flexibleFunc(open Params) {
627
- string name = OpenFind<string>(0);
628
- int num = OpenFind<int>(0);
629
- printl(name + " " + num);
630
- }
483
+ for (int i = 10; i > 0; i--) {
484
+ printl(i);
485
+ }
486
+ ```
631
487
 
632
- flexibleFunc("Hello", 123, true);
633
- ```
488
+ ### Foreach
634
489
 
635
- ---
490
+ ```cssl
491
+ stack<string> names;
492
+ names.push("Alice");
493
+ names.push("Bob");
636
494
 
637
- ## Classes & OOP
495
+ // Syntax 1
496
+ foreach (name in names) {
497
+ printl(name);
498
+ }
638
499
 
639
- ### Class Definition
500
+ // Syntax 2
501
+ foreach names as name {
502
+ printl(name);
503
+ }
504
+ ```
640
505
 
641
- ```cssl
642
- class Person {
643
- string name;
644
- int age;
506
+ ### Break & Continue
645
507
 
646
- // Constructor
647
- void Person(string n, int a) {
648
- this->name = n;
649
- this->age = a;
508
+ ```cssl
509
+ for (i in range(10)) {
510
+ if (i == 5) break; // Exit loop
511
+ if (i == 3) continue; // Skip iteration
512
+ printl(i);
650
513
  }
514
+ ```
515
+
516
+ ---
651
517
 
652
- void greet() {
653
- printl("Hello, I'm " + this->name);
518
+ ## Functions
519
+
520
+ ### Basic Syntax
521
+
522
+ ```cssl
523
+ // Without return
524
+ void sayHello() {
525
+ printl("Hello!");
654
526
  }
655
527
 
528
+ // With return
656
529
  string getName() {
657
- return this->name;
530
+ return "CSSL";
531
+ }
532
+
533
+ // With parameters
534
+ int add(int a, int b) {
535
+ return a + b;
536
+ }
537
+ ```
538
+
539
+ ### Define Functions
540
+
541
+ ```cssl
542
+ // Simple function without type
543
+ define greet() {
544
+ printl("Hello!");
545
+ }
546
+
547
+ // With parameters
548
+ define greet(string name) {
549
+ printl("Hello " + name);
550
+ }
551
+ ```
552
+
553
+ ### Function Modifiers
554
+
555
+ | Modifier | Description |
556
+ |----------|-------------|
557
+ | `undefined` | Silently ignore errors |
558
+ | `closed` | Block external CodeInfusion |
559
+ | `private` | Block all CodeInfusion |
560
+ | `virtual` | Import-cycle safe |
561
+ | `meta` | Source function (any return type allowed) |
562
+ | `super` | Force execution (no exceptions) |
563
+ | `open` | Accept any parameters |
564
+ | `shuffled` | Return multiple values |
565
+ | `const` | Immutable function (like C++) |
566
+ | `static` | Static method/function |
567
+ | `public` | Explicitly public (default) |
568
+ | `global` | Makes function globally accessible |
569
+
570
+ **Flexible Modifier Order**: Modifiers can appear in any order before the function declaration.
571
+
572
+ ```cssl
573
+ // Ignore errors
574
+ undefined void mayFail() {
575
+ riskyOperation();
576
+ }
577
+
578
+ // Protected from injection
579
+ closed void protected() {
580
+ printl("Protected");
581
+ }
582
+
583
+ // Multiple returns
584
+ shuffled string getNames() {
585
+ return "Alice", "Bob", "Charlie";
586
+ }
587
+
588
+ a, b, c = getNames();
589
+
590
+ // Any order of modifiers works
591
+ private string *@Myfunc() {
592
+ println("Hello from global private non-null function!");
593
+ return "Hey";
594
+ }
595
+
596
+ // Const function
597
+ const void immutableFunc() {
598
+ printl("I'm constant");
658
599
  }
659
- }
660
- ```
661
600
 
662
- ### Creating Instances
601
+ // Global private const
602
+ global private const void @MyGlobalFunc() {
603
+ printl("Complex modifiers in any order");
604
+ }
605
+ ```
606
+
607
+ ### Typed Functions (Enforced Returns)
663
608
 
664
- ```cssl
665
- Person p = new Person("Alice", 30);
666
- p.greet();
667
- printl(p.name);
668
- ```
609
+ Functions with a return type (like `int`, `string`, `vector<T>`) MUST return that type:
669
610
 
670
- ### Constructor with `constr` Keyword
611
+ ```cssl
612
+ // MUST return string
613
+ string getName() {
614
+ return "Alice"; // OK
615
+ // return 42; // Error! Expected string
616
+ }
671
617
 
672
- ```cssl
673
- class Vehicle {
674
- string brand;
618
+ // MUST return int
619
+ int getAge() {
620
+ return 30; // OK
621
+ }
675
622
 
676
- constr Initialize(string b) {
677
- this->brand = b;
623
+ // meta modifier bypasses type checking
624
+ meta datastruct<string> getData() {
625
+ return "just a string"; // OK despite declared type
626
+ return 42; // Also OK - meta allows any type
678
627
  }
628
+ ```
629
+
630
+ ### Non-Null Functions (*)
679
631
 
680
- constr SetupDefaults() {
681
- printl("Vehicle ready");
632
+ Functions that must never return null:
633
+
634
+ ```cssl
635
+ // Non-null function
636
+ define *alwaysReturns() {
637
+ return "Always a value";
682
638
  }
683
- }
684
639
 
685
- Vehicle v = new Vehicle("Toyota");
686
- ```
640
+ // Non-null assertion on value
641
+ this->name = *$System.os; // Error if null
642
+ ```
687
643
 
688
- ### Class Inheritance
644
+ ### Type Exclusion Filter (*[type])
689
645
 
690
- ```cssl
691
- class Animal {
692
- string name;
646
+ Functions that must NOT return a specific type:
693
647
 
694
- void Animal(string n) {
695
- this->name = n;
648
+ ```cssl
649
+ // Must NOT return string
650
+ shuffled *[string] getNumbers() {
651
+ return 1, 2, 3; // OK
652
+ // return "text"; // Error!
696
653
  }
697
654
 
698
- void speak() {
699
- printl("Sound");
655
+ // Must NOT return null
656
+ define *[null] getValue() {
657
+ return 42; // OK
700
658
  }
701
- }
659
+ ```
660
+
661
+ ### Open Parameters
702
662
 
703
- class Dog : extends Animal {
704
- void Dog(string n) {
705
- this->name = n;
663
+ ```cssl
664
+ open define flexibleFunc(open Params) {
665
+ string name = OpenFind<string>(0);
666
+ int num = OpenFind<int>(0);
667
+ printl(name + " " + num);
706
668
  }
707
669
 
708
- void speak() {
709
- printl("Woof! I'm " + this->name);
670
+ flexibleFunc("Hello", 123, true);
671
+ ```
672
+
673
+ ---
674
+
675
+ ## Classes & OOP
676
+
677
+ ### Class Definition
678
+
679
+ ```cssl
680
+ class Person {
681
+ string name;
682
+ int age;
683
+
684
+ // Constructor
685
+ void Person(string n, int a) {
686
+ this->name = n;
687
+ this->age = a;
688
+ }
689
+
690
+ void greet() {
691
+ printl("Hello, I'm " + this->name);
692
+ }
693
+
694
+ string getName() {
695
+ return this->name;
696
+ }
710
697
  }
711
- }
698
+ ```
699
+
700
+ ### Creating Instances
712
701
 
713
- Dog d = new Dog("Buddy");
714
- d.speak(); // "Woof! I'm Buddy"
715
- ```
702
+ ```cssl
703
+ Person p = new Person("Alice", 30);
704
+ p.greet();
705
+ printl(p.name);
706
+ ```
716
707
 
717
- ### super() and super::method()
708
+ ### Constructor with `constr` Keyword
718
709
 
719
- ```cssl
720
- class Child : extends Parent {
721
- constr ChildInit(string name) {
722
- super(name); // Call parent constructor
710
+ ```cssl
711
+ class Vehicle {
712
+ string brand;
713
+
714
+ constr Initialize(string b) {
715
+ this->brand = b;
716
+ }
717
+
718
+ constr SetupDefaults() {
719
+ printl("Vehicle ready");
720
+ }
723
721
  }
724
722
 
725
- void speak() {
726
- super::speak(); // Call parent method
727
- printl("Child speaking");
723
+ Vehicle v = new Vehicle("Toyota");
724
+ ```
725
+
726
+ ### Class Inheritance
727
+
728
+ ```cssl
729
+ class Animal {
730
+ string name;
731
+
732
+ void Animal(string n) {
733
+ this->name = n;
734
+ }
735
+
736
+ void speak() {
737
+ printl("Sound");
738
+ }
728
739
  }
729
- }
730
- ```
731
740
 
732
- ### Append Mode (++)
741
+ class Dog : extends Animal {
742
+ void Dog(string n) {
743
+ this->name = n;
744
+ }
733
745
 
734
- Extend constructors/functions while keeping original code:
746
+ void speak() {
747
+ printl("Woof! I'm " + this->name);
748
+ }
749
+ }
735
750
 
736
- ```cssl
737
- // Original function
738
- define BaseFunc() {
739
- printl("Base functionality");
740
- }
751
+ Dog d = new Dog("Buddy");
752
+ d.speak(); // "Woof! I'm Buddy"
753
+ ```
741
754
 
742
- // Append to BaseFunc
743
- define ExtendedFunc() &BaseFunc ++ {
744
- printl("Extended functionality");
745
- }
755
+ ### super() and super::method()
746
756
 
747
- ExtendedFunc();
748
- // Output:
749
- // Base functionality
750
- // Extended functionality
751
- ```
757
+ ```cssl
758
+ class Child : extends Parent {
759
+ constr ChildInit(string name) {
760
+ super(name); // Call parent constructor
761
+ }
752
762
 
753
- ```cssl
754
- class MyClass {
755
- constr MyClassConstructor() {
756
- printl("MyClass constructor");
757
- this->value = 10;
763
+ void speak() {
764
+ super::speak(); // Call parent method
765
+ printl("Child speaking");
766
+ }
758
767
  }
759
- }
768
+ ```
769
+
770
+ ### Append Mode (++)
760
771
 
761
- class BetterClass :: extends MyClass {
762
- constr BetterConstructor() &MyClass::MyClassConstructor ++ {
763
- printl("BetterClass - added code");
764
- this->extra = 20;
772
+ Extend constructors/functions while keeping original code:
773
+
774
+ ```cssl
775
+ // Original function
776
+ define BaseFunc() {
777
+ printl("Base functionality");
765
778
  }
766
- }
767
- ```
768
779
 
769
- ### Non-Null Class
780
+ // Append to BaseFunc
781
+ define ExtendedFunc() &BaseFunc ++ {
782
+ printl("Extended functionality");
783
+ }
770
784
 
771
- ```cssl
772
- class *MyClass {
773
- // All methods must return non-null
774
- string getValue() {
775
- return "Value";
776
- }
777
- }
778
- ```
779
-
780
- ---
781
-
782
- ## Container Types
783
-
784
- ### stack\<T\> - LIFO Stack
785
-
786
- ```cssl
787
- stack<string> names;
788
- names.push("Alice");
789
- names.push("Bob");
790
-
791
- printl(names.pop()); // "Bob"
792
- printl(names.peek()); // "Alice" (doesn't remove)
793
- printl(names.size()); // 1
794
- printl(names.isEmpty()); // false
795
- ```
796
-
797
- **Methods:**
798
-
799
- | Method | Description |
800
- |--------|-------------|
801
- | `push(value)` | Add to top |
802
- | `pop()` | Remove and return top |
803
- | `peek()` | View top without removing |
804
- | `size()` / `length()` | Element count |
805
- | `isEmpty()` / `is_empty()` | Check if empty |
806
- | `contains(value)` | Check if contains |
807
- | `indexOf(value)` | Find index (-1 if not found) |
808
- | `toArray()` | Convert to list |
809
- | `swap()` | Swap top two elements |
810
- | `dup()` | Duplicate top element |
811
-
812
- ### vector\<T\> - Dynamic Array
813
-
814
- ```cssl
815
- vector<int> nums;
816
- nums.push(10);
817
- nums.push(20);
818
-
819
- printl(nums.at(0)); // 10
820
- printl(nums.front()); // 10
821
- printl(nums.back()); // 20
822
- ```
823
-
824
- **Methods:**
825
-
826
- | Method | Description |
827
- |--------|-------------|
828
- | `push(value)` / `push_back(value)` | Add to end |
829
- | `push_front(value)` | Add to front |
830
- | `pop_back()` | Remove from end |
831
- | `pop_front()` | Remove from front |
832
- | `at(index)` | Get element |
833
- | `set(index, value)` | Set element |
834
- | `front()` | Get first |
835
- | `back()` | Get last |
836
- | `size()` / `length()` | Element count |
837
- | `empty()` / `isEmpty()` | Check if empty |
838
- | `contains(value)` | Check if contains |
839
- | `indexOf(value)` | Find first index |
840
- | `lastIndexOf(value)` | Find last index |
841
- | `slice(start, end)` | Get sub-vector |
842
- | `join(separator)` | Join to string |
843
- | `map(func)` | Apply function |
844
- | `filter(predicate)` | Filter elements |
845
- | `forEach(func)` | Execute for each |
846
- | `every(predicate)` | Check all match |
847
- | `some(predicate)` | Check any match |
848
- | `reduce(func, initial)` | Reduce to value |
849
- | `toArray()` | Convert to list |
850
-
851
- ### map\<K,V\> - Ordered Key-Value
852
-
853
- ```cssl
854
- map<string, int> ages;
855
- ages.insert("Alice", 30);
856
- ages.insert("Bob", 25);
857
-
858
- printl(ages.find("Alice")); // 30
859
- printl(ages.contains("Bob")); // true
860
- ages.erase("Bob");
861
- ```
862
-
863
- **Methods:**
864
-
865
- | Method | Description |
866
- |--------|-------------|
867
- | `insert(key, value)` | Insert/update pair |
868
- | `find(key)` | Get value (null if not found) |
869
- | `at(key)` | Get value (throws if not found) |
870
- | `erase(key)` | Remove key |
871
- | `contains(key)` | Check if key exists |
872
- | `count(key)` | Count (0 or 1) |
873
- | `size()` | Pair count |
874
- | `empty()` | Check if empty |
875
- | `begin()` | First key-value tuple |
876
- | `end()` | Last key-value tuple |
877
- | `lower_bound(key)` | First key >= given |
878
- | `upper_bound(key)` | First key > given |
879
-
880
- ### datastruct\<T\> - Universal Container
881
-
882
- Primary target for BruteInjection operations.
883
-
884
- ```cssl
885
- datastruct<string> data;
886
- data.add("item1");
887
- data.add("item2");
888
-
889
- printl(data.content()); // All elements
890
- ```
891
-
892
- **Methods:**
893
-
894
- | Method | Description |
895
- |--------|-------------|
896
- | `content()` | Get all elements |
897
- | `add(value)` | Add element |
898
- | `remove_where(predicate)` | Remove matching |
899
- | `find_where(predicate)` | Find first matching |
900
- | `convert(type)` | Convert first element |
901
-
902
- ### shuffled\<T\> - Multiple Returns
903
-
904
- ```cssl
905
- shuffled string getInfo() {
906
- return "Alice", "Bob", "Charlie";
907
- }
908
-
909
- a, b, c = getInfo();
910
- printl(a); // "Alice"
911
- ```
912
-
913
- ---
914
-
915
- ## Built-in Functions
916
-
917
- ### String Operations
918
-
919
- ```cssl
920
- string s = "Hello World";
921
-
922
- // Case
923
- upper(s); // "HELLO WORLD"
924
- lower(s); // "hello world"
925
- capitalize(s); // "Hello world"
926
- title(s); // "Hello World"
927
-
928
- // Trim
929
- trim(" text "); // "text"
930
- ltrim(" text"); // "text"
931
- rtrim("text "); // "text"
932
-
933
- // Search
934
- contains(s, "World"); // true
935
- startswith(s, "Hello"); // true
936
- endswith(s, "World"); // true
937
- indexof(s, "o"); // 4
938
- lastindexof(s, "o"); // 7
939
-
940
- // Manipulation
941
- replace(s, "World", "CSSL"); // "Hello CSSL"
942
- substr(s, 0, 5); // "Hello"
943
- split(s, " "); // ["Hello", "World"]
944
- join("-", ["a", "b"]); // "a-b"
945
- repeat("ab", 3); // "ababab"
946
- reverse(s); // "dlroW olleH"
947
-
948
- // Padding
949
- padleft("42", 5, "0"); // "00042"
950
- padright("42", 5, "."); // "42..."
951
- center("hi", 6, "-"); // "--hi--"
952
- zfill("42", 5); // "00042"
953
-
954
- // Character
955
- len(s); // 11
956
- chars("abc"); // ["a", "b", "c"]
957
- ord("A"); // 65
958
- chr(65); // "A"
959
-
960
- // Checks
961
- isalpha("abc"); // true
962
- isdigit("123"); // true
963
- isalnum("abc123"); // true
964
- isspace(" "); // true
965
- ```
966
-
967
- ### Array/List Operations
968
-
969
- ```cssl
970
- stack<int> arr = [1, 2, 3, 4, 5];
971
-
972
- // Add/Remove
973
- push(arr, 6); // Add to end
974
- pop(arr); // Remove last
975
- shift(arr); // Remove first
976
- unshift(arr, 0); // Add to front
977
-
978
- // Access
979
- first(arr); // First element
980
- last(arr); // Last element
981
- slice(arr, 1, 3); // [2, 3]
982
-
983
- // Transform
984
- sort(arr); // Sort ascending
985
- rsort(arr); // Sort descending
986
- reversed(arr); // Reverse copy
987
- shuffle(arr); // Random order
988
- unique(arr); // Remove duplicates
989
- flatten([[1,2],[3,4]]); // [1, 2, 3, 4]
990
-
991
- // Search
992
- find(arr, x => x > 3); // First matching
993
- findindex(arr, x => x > 3);
994
- every(arr, x => x > 0); // All match?
995
- some(arr, x => x > 3); // Any match?
996
- count(arr, 2); // Count of 2
997
-
998
- // Functional
999
- map(arr, x => x * 2); // [2, 4, 6, 8, 10]
1000
- filter(arr, x => x > 2); // [3, 4, 5]
1001
- reduce(arr, (a,b) => a+b, 0); // 15
1002
-
1003
- // Utilities
1004
- range(5); // [0, 1, 2, 3, 4]
1005
- range(1, 5); // [1, 2, 3, 4]
1006
- range(0, 10, 2); // [0, 2, 4, 6, 8]
1007
- enumerate(arr); // [(0,1), (1,2), ...]
1008
- zip([1,2], ["a","b"]); // [(1,"a"), (2,"b")]
1009
- take(arr, 3); // First 3 elements
1010
- drop(arr, 2); // Skip first 2
1011
- chunk(arr, 2); // [[1,2], [3,4], [5]]
1012
- sample(arr, 2); // 2 random elements
1013
- ```
1014
-
1015
- ### Dictionary Operations
1016
-
1017
- ```cssl
1018
- dict d = {"name": "Alice", "age": 30};
1019
-
1020
- keys(d); // ["name", "age"]
1021
- values(d); // ["Alice", 30]
1022
- items(d); // [("name","Alice"), ...]
1023
- haskey(d, "name"); // true
1024
- getkey(d, "name"); // "Alice"
1025
- getkey(d, "x", "default"); // "default"
1026
- setkey(d, "city", "NYC"); // Add key
1027
- delkey(d, "age"); // Remove key
1028
- merge(d1, d2); // Merge dicts
1029
- update(d, {"new": 1}); // Update in place
1030
- fromkeys(["a","b"], 0); // {"a": 0, "b": 0}
1031
- invert({"a": 1}); // {1: "a"}
1032
- pick(d, "name"); // {"name": "Alice"}
1033
- omit(d, "age"); // {"name": "Alice"}
1034
- ```
1035
-
1036
- ### Math Functions
1037
-
1038
- ```cssl
1039
- abs(-5); // 5
1040
- min(3, 1, 2); // 1
1041
- max(3, 1, 2); // 3
1042
- sum([1, 2, 3]); // 6
1043
- avg([1, 2, 3, 4, 5]); // 3.0
1044
-
1045
- round(3.14159, 2); // 3.14
1046
- floor(3.9); // 3
1047
- ceil(3.1); // 4
1048
-
1049
- pow(2, 3); // 8
1050
- sqrt(16); // 4
1051
- mod(7, 3); // 1
1052
-
1053
- sin(0); // 0.0
1054
- cos(0); // 1.0
1055
- tan(0); // 0.0
1056
- asin(1); // 1.5708
1057
- acos(0); // 1.5708
1058
- atan(1); // 0.7854
1059
- atan2(1, 1); // 0.7854
1060
-
1061
- log(e()); // 1.0
1062
- log10(100); // 2.0
1063
- exp(1); // 2.71828
1064
-
1065
- pi(); // 3.14159...
1066
- e(); // 2.71828...
1067
- radians(180); // 3.14159
1068
- degrees(3.14159); // 180
1069
-
1070
- random(); // 0.0 to 1.0
1071
- randint(1, 6); // 1 to 6
1072
- ```
1073
-
1074
- ### Date/Time Functions
1075
-
1076
- ```cssl
1077
- now(); // Unix timestamp (float)
1078
- timestamp(); // Unix timestamp (int)
1079
- date(); // "2025-12-30"
1080
- date("%d/%m/%Y"); // "30/12/2025"
1081
- time(); // "14:30:45"
1082
- datetime(); // "2025-12-30 14:30:45"
1083
- strftime("%Y-%m-%d", ts);
1084
-
1085
- sleep(1.5); // Wait 1.5 seconds
1086
- delay(500); // Wait 500 milliseconds
1087
- ```
1088
-
1089
- ### File I/O Functions
1090
-
1091
- ```cssl
1092
- // Read
1093
- string content = read("file.txt");
1094
- string line5 = readline(5, "file.txt");
1095
- stack<string> lines = readlines("file.txt");
1096
-
1097
- // Write
1098
- write("file.txt", "Hello");
1099
- writeline(3, "New line", "file.txt");
1100
- appendfile("file.txt", "\nMore");
1101
-
1102
- // Path operations
1103
- basename("/path/to/file.txt"); // "file.txt"
1104
- dirname("/path/to/file.txt"); // "/path/to"
1105
- joinpath("/path", "file.txt"); // "/path/file.txt"
1106
- abspath("./file.txt");
1107
- normpath("/path/../other");
1108
-
1109
- // Checks
1110
- pathexists("file.txt"); // true/false
1111
- isfile("file.txt"); // true/false
1112
- isdir("folder"); // true/false
1113
- filesize("file.txt"); // bytes
1114
-
1115
- // Directory
1116
- listdir("./"); // ["file1", "file2"]
1117
- makedirs("new/folder");
1118
- removefile("file.txt");
1119
- removedir("folder");
1120
- copyfile("src", "dst");
1121
- movefile("old", "new");
1122
- ```
1123
-
1124
- ### JSON Functions (json:: namespace)
1125
-
1126
- ```cssl
1127
- // File operations
1128
- json data = json::read("config.json");
1129
- json::write("output.json", data);
1130
-
1131
- // Parse/Stringify
1132
- json obj = json::parse('{"name": "Alice"}');
1133
- string str = json::stringify(obj);
1134
- string pretty = json::pretty(obj);
1135
-
1136
- // Path operations
1137
- json::get(data, "user.name");
1138
- json::get(data, "user.age", 0); // with default
1139
- json::set(data, "user.name", "Bob");
1140
- json::has(data, "user.email");
1141
-
1142
- // Object operations
1143
- json::keys(obj); // ["name"]
1144
- json::values(obj); // ["Alice"]
1145
- json::merge(obj1, obj2); // Deep merge
1146
- ```
1147
-
1148
- ### Instance Functions (instance:: namespace)
1149
-
1150
- ```cssl
1151
- @module = include("lib.cssl-mod");
1152
-
1153
- instance::getMethods(@module); // Method names
1154
- instance::getClasses(@module); // Class names
1155
- instance::getVars(@module); // Variable names
1156
- instance::getAll(@module); // Categorized dict
1157
-
1158
- instance::call(@module, "methodName", arg1);
1159
- instance::has(@module, "attribute");
1160
- instance::type(@module); // Type name
1161
-
1162
- isavailable("sharedName"); // Check if exists
1163
- ```
1164
-
1165
- ### Regex Functions
1166
-
1167
- ```cssl
1168
- match("\\d+", "abc123"); // Match at start
1169
- search("\\d+", "abc123"); // Search anywhere
1170
- findall("\\d+", "a1b2c3"); // ["1", "2", "3"]
1171
- sub("\\d", "X", "a1b2"); // "aXbX"
1172
- sub("\\d", "X", "a1b2", 1); // "aXb2" (count=1)
1173
- ```
1174
-
1175
- ### Hash Functions
1176
-
1177
- ```cssl
1178
- md5("hello"); // 32 hex chars
1179
- sha1("hello"); // 40 hex chars
1180
- sha256("hello"); // 64 hex chars
1181
- ```
785
+ ExtendedFunc();
786
+ // Output:
787
+ // Base functionality
788
+ // Extended functionality
789
+ ```
790
+
791
+ ```cssl
792
+ class MyClass {
793
+ constr MyClassConstructor() {
794
+ printl("MyClass constructor");
795
+ this->value = 10;
796
+ }
797
+ }
1182
798
 
1183
- ### System Functions
799
+ class BetterClass :: extends MyClass {
800
+ constr BetterConstructor() &MyClass::MyClassConstructor ++ {
801
+ printl("BetterClass - added code");
802
+ this->extra = 20;
803
+ }
804
+ }
805
+ ```
806
+
807
+ ### Non-Null Class
808
+
809
+ ```cssl
810
+ class *MyClass {
811
+ // All methods must return non-null
812
+ string getValue() {
813
+ return "Value";
814
+ }
815
+ }
816
+ ```
817
+
818
+ ---
819
+
820
+ ## Container Types
821
+
822
+ ### stack\<T\> - LIFO Stack
823
+
824
+ ```cssl
825
+ stack<string> names;
826
+ names.push("Alice");
827
+ names.push("Bob");
828
+
829
+ printl(names.pop()); // "Bob"
830
+ printl(names.peek()); // "Alice" (doesn't remove)
831
+ printl(names.size()); // 1
832
+ printl(names.isEmpty()); // false
833
+ ```
834
+
835
+ **Methods:**
836
+
837
+ | Method | Description |
838
+ |--------|-------------|
839
+ | `push(value)` | Add to top |
840
+ | `pop()` | Remove and return top |
841
+ | `peek()` | View top without removing |
842
+ | `size()` / `length()` | Element count |
843
+ | `isEmpty()` / `is_empty()` | Check if empty |
844
+ | `contains(value)` | Check if contains |
845
+ | `indexOf(value)` | Find index (-1 if not found) |
846
+ | `toArray()` | Convert to list |
847
+ | `swap()` | Swap top two elements |
848
+ | `dup()` | Duplicate top element |
849
+
850
+ ### vector\<T\> - Dynamic Array
851
+
852
+ ```cssl
853
+ vector<int> nums;
854
+ nums.push(10);
855
+ nums.push(20);
856
+
857
+ printl(nums.at(0)); // 10
858
+ printl(nums.front()); // 10
859
+ printl(nums.back()); // 20
860
+ ```
861
+
862
+ **Methods:**
863
+
864
+ | Method | Description |
865
+ |--------|-------------|
866
+ | `push(value)` / `push_back(value)` | Add to end |
867
+ | `push_front(value)` | Add to front |
868
+ | `pop_back()` | Remove from end |
869
+ | `pop_front()` | Remove from front |
870
+ | `at(index)` | Get element |
871
+ | `set(index, value)` | Set element |
872
+ | `front()` | Get first |
873
+ | `back()` | Get last |
874
+ | `size()` / `length()` | Element count |
875
+ | `empty()` / `isEmpty()` | Check if empty |
876
+ | `contains(value)` | Check if contains |
877
+ | `indexOf(value)` | Find first index |
878
+ | `lastIndexOf(value)` | Find last index |
879
+ | `slice(start, end)` | Get sub-vector |
880
+ | `join(separator)` | Join to string |
881
+ | `map(func)` | Apply function |
882
+ | `filter(predicate)` | Filter elements |
883
+ | `forEach(func)` | Execute for each |
884
+ | `every(predicate)` | Check all match |
885
+ | `some(predicate)` | Check any match |
886
+ | `reduce(func, initial)` | Reduce to value |
887
+ | `toArray()` | Convert to list |
888
+
889
+ ### map\<K,V\> - Ordered Key-Value
890
+
891
+ ```cssl
892
+ map<string, int> ages;
893
+ ages.insert("Alice", 30);
894
+ ages.insert("Bob", 25);
895
+
896
+ printl(ages.find("Alice")); // 30
897
+ printl(ages.contains("Bob")); // true
898
+ ages.erase("Bob");
899
+ ```
900
+
901
+ **Methods:**
902
+
903
+ | Method | Description |
904
+ |--------|-------------|
905
+ | `insert(key, value)` | Insert/update pair |
906
+ | `find(key)` | Get value (null if not found) |
907
+ | `at(key)` | Get value (throws if not found) |
908
+ | `erase(key)` | Remove key |
909
+ | `contains(key)` | Check if key exists |
910
+ | `count(key)` | Count (0 or 1) |
911
+ | `size()` | Pair count |
912
+ | `empty()` | Check if empty |
913
+ | `begin()` | First key-value tuple |
914
+ | `end()` | Last key-value tuple |
915
+ | `lower_bound(key)` | First key >= given |
916
+ | `upper_bound(key)` | First key > given |
917
+
918
+ ### datastruct\<T\> - Universal Container
919
+
920
+ Primary target for BruteInjection operations.
921
+
922
+ ```cssl
923
+ datastruct<string> data;
924
+ data.add("item1");
925
+ data.add("item2");
926
+
927
+ printl(data.content()); // All elements
928
+ ```
929
+
930
+ **Methods:**
931
+
932
+ | Method | Description |
933
+ |--------|-------------|
934
+ | `content()` | Get all elements |
935
+ | `add(value)` | Add element |
936
+ | `remove_where(predicate)` | Remove matching |
937
+ | `find_where(predicate)` | Find first matching |
938
+ | `convert(type)` | Convert first element |
939
+
940
+ ### shuffled\<T\> - Multiple Returns
941
+
942
+ ```cssl
943
+ shuffled string getInfo() {
944
+ return "Alice", "Bob", "Charlie";
945
+ }
1184
946
 
1185
- ```cssl
1186
- exit(0); // Exit with code
1187
- input("Enter name: "); // Read user input
947
+ a, b, c = getInfo();
948
+ printl(a); // "Alice"
949
+ ```
950
+
951
+ ---
952
+
953
+ ## Built-in Functions
954
+
955
+ ### String Operations
956
+
957
+ ```cssl
958
+ string s = "Hello World";
959
+
960
+ // Case
961
+ upper(s); // "HELLO WORLD"
962
+ lower(s); // "hello world"
963
+ capitalize(s); // "Hello world"
964
+ title(s); // "Hello World"
965
+
966
+ // Trim
967
+ trim(" text "); // "text"
968
+ ltrim(" text"); // "text"
969
+ rtrim("text "); // "text"
970
+
971
+ // Search
972
+ contains(s, "World"); // true
973
+ startswith(s, "Hello"); // true
974
+ endswith(s, "World"); // true
975
+ indexof(s, "o"); // 4
976
+ lastindexof(s, "o"); // 7
977
+
978
+ // Manipulation
979
+ replace(s, "World", "CSSL"); // "Hello CSSL"
980
+ substr(s, 0, 5); // "Hello"
981
+ split(s, " "); // ["Hello", "World"]
982
+ join("-", ["a", "b"]); // "a-b"
983
+ repeat("ab", 3); // "ababab"
984
+ reverse(s); // "dlroW olleH"
985
+
986
+ // Padding
987
+ padleft("42", 5, "0"); // "00042"
988
+ padright("42", 5, "."); // "42..."
989
+ center("hi", 6, "-"); // "--hi--"
990
+ zfill("42", 5); // "00042"
991
+
992
+ // Character
993
+ len(s); // 11
994
+ chars("abc"); // ["a", "b", "c"]
995
+ ord("A"); // 65
996
+ chr(65); // "A"
997
+
998
+ // Checks
999
+ isalpha("abc"); // true
1000
+ isdigit("123"); // true
1001
+ isalnum("abc123"); // true
1002
+ isspace(" "); // true
1003
+ ```
1004
+
1005
+ ### Array/List Operations
1006
+
1007
+ ```cssl
1008
+ stack<int> arr = [1, 2, 3, 4, 5];
1009
+
1010
+ // Add/Remove
1011
+ push(arr, 6); // Add to end
1012
+ pop(arr); // Remove last
1013
+ shift(arr); // Remove first
1014
+ unshift(arr, 0); // Add to front
1015
+
1016
+ // Access
1017
+ first(arr); // First element
1018
+ last(arr); // Last element
1019
+ slice(arr, 1, 3); // [2, 3]
1020
+
1021
+ // Transform
1022
+ sort(arr); // Sort ascending
1023
+ rsort(arr); // Sort descending
1024
+ reversed(arr); // Reverse copy
1025
+ shuffle(arr); // Random order
1026
+ unique(arr); // Remove duplicates
1027
+ flatten([[1,2],[3,4]]); // [1, 2, 3, 4]
1028
+
1029
+ // Search
1030
+ find(arr, x => x > 3); // First matching
1031
+ findindex(arr, x => x > 3);
1032
+ every(arr, x => x > 0); // All match?
1033
+ some(arr, x => x > 3); // Any match?
1034
+ count(arr, 2); // Count of 2
1035
+
1036
+ // Functional
1037
+ map(arr, x => x * 2); // [2, 4, 6, 8, 10]
1038
+ filter(arr, x => x > 2); // [3, 4, 5]
1039
+ reduce(arr, (a,b) => a+b, 0); // 15
1040
+
1041
+ // Utilities
1042
+ range(5); // [0, 1, 2, 3, 4]
1043
+ range(1, 5); // [1, 2, 3, 4]
1044
+ range(0, 10, 2); // [0, 2, 4, 6, 8]
1045
+ enumerate(arr); // [(0,1), (1,2), ...]
1046
+ zip([1,2], ["a","b"]); // [(1,"a"), (2,"b")]
1047
+ take(arr, 3); // First 3 elements
1048
+ drop(arr, 2); // Skip first 2
1049
+ chunk(arr, 2); // [[1,2], [3,4], [5]]
1050
+ sample(arr, 2); // 2 random elements
1051
+ ```
1052
+
1053
+ ### Dictionary Operations
1054
+
1055
+ ```cssl
1056
+ dict d = {"name": "Alice", "age": 30};
1057
+
1058
+ keys(d); // ["name", "age"]
1059
+ values(d); // ["Alice", 30]
1060
+ items(d); // [("name","Alice"), ...]
1061
+ haskey(d, "name"); // true
1062
+ getkey(d, "name"); // "Alice"
1063
+ getkey(d, "x", "default"); // "default"
1064
+ setkey(d, "city", "NYC"); // Add key
1065
+ delkey(d, "age"); // Remove key
1066
+ merge(d1, d2); // Merge dicts
1067
+ update(d, {"new": 1}); // Update in place
1068
+ fromkeys(["a","b"], 0); // {"a": 0, "b": 0}
1069
+ invert({"a": 1}); // {1: "a"}
1070
+ pick(d, "name"); // {"name": "Alice"}
1071
+ omit(d, "age"); // {"name": "Alice"}
1072
+ ```
1073
+
1074
+ ### Math Functions
1075
+
1076
+ ```cssl
1077
+ abs(-5); // 5
1078
+ min(3, 1, 2); // 1
1079
+ max(3, 1, 2); // 3
1080
+ sum([1, 2, 3]); // 6
1081
+ avg([1, 2, 3, 4, 5]); // 3.0
1082
+
1083
+ round(3.14159, 2); // 3.14
1084
+ floor(3.9); // 3
1085
+ ceil(3.1); // 4
1086
+
1087
+ pow(2, 3); // 8
1088
+ sqrt(16); // 4
1089
+ mod(7, 3); // 1
1090
+
1091
+ sin(0); // 0.0
1092
+ cos(0); // 1.0
1093
+ tan(0); // 0.0
1094
+ asin(1); // 1.5708
1095
+ acos(0); // 1.5708
1096
+ atan(1); // 0.7854
1097
+ atan2(1, 1); // 0.7854
1098
+
1099
+ log(e()); // 1.0
1100
+ log10(100); // 2.0
1101
+ exp(1); // 2.71828
1102
+
1103
+ pi(); // 3.14159...
1104
+ e(); // 2.71828...
1105
+ radians(180); // 3.14159
1106
+ degrees(3.14159); // 180
1107
+
1108
+ random(); // 0.0 to 1.0
1109
+ randint(1, 6); // 1 to 6
1110
+ ```
1111
+
1112
+ ### Date/Time Functions
1113
+
1114
+ ```cssl
1115
+ now(); // Unix timestamp (float)
1116
+ timestamp(); // Unix timestamp (int)
1117
+ date(); // "2025-12-30"
1118
+ date("%d/%m/%Y"); // "30/12/2025"
1119
+ time(); // "14:30:45"
1120
+ datetime(); // "2025-12-30 14:30:45"
1121
+ strftime("%Y-%m-%d", ts);
1122
+
1123
+ sleep(1.5); // Wait 1.5 seconds
1124
+ delay(500); // Wait 500 milliseconds
1125
+ ```
1126
+
1127
+ ### File I/O Functions
1128
+
1129
+ ```cssl
1130
+ // Read
1131
+ string content = read("file.txt");
1132
+ string line5 = readline(5, "file.txt");
1133
+ stack<string> lines = readlines("file.txt");
1134
+
1135
+ // Write
1136
+ write("file.txt", "Hello");
1137
+ writeline(3, "New line", "file.txt");
1138
+ appendfile("file.txt", "\nMore");
1139
+
1140
+ // Path operations
1141
+ basename("/path/to/file.txt"); // "file.txt"
1142
+ dirname("/path/to/file.txt"); // "/path/to"
1143
+ joinpath("/path", "file.txt"); // "/path/file.txt"
1144
+ abspath("./file.txt");
1145
+ normpath("/path/../other");
1146
+
1147
+ // Checks
1148
+ pathexists("file.txt"); // true/false
1149
+ isfile("file.txt"); // true/false
1150
+ isdir("folder"); // true/false
1151
+ filesize("file.txt"); // bytes
1152
+
1153
+ // Directory
1154
+ listdir("./"); // ["file1", "file2"]
1155
+ makedirs("new/folder");
1156
+ removefile("file.txt");
1157
+ removedir("folder");
1158
+ copyfile("src", "dst");
1159
+ movefile("old", "new");
1160
+ ```
1161
+
1162
+ ### JSON Functions (json:: namespace)
1163
+
1164
+ ```cssl
1165
+ // File operations
1166
+ json data = json::read("config.json");
1167
+ json::write("output.json", data);
1168
+
1169
+ // Parse/Stringify
1170
+ json obj = json::parse('{"name": "Alice"}');
1171
+ string str = json::stringify(obj);
1172
+ string pretty = json::pretty(obj);
1173
+
1174
+ // Path operations
1175
+ json::get(data, "user.name");
1176
+ json::get(data, "user.age", 0); // with default
1177
+ json::set(data, "user.name", "Bob");
1178
+ json::has(data, "user.email");
1179
+
1180
+ // Object operations
1181
+ json::keys(obj); // ["name"]
1182
+ json::values(obj); // ["Alice"]
1183
+ json::merge(obj1, obj2); // Deep merge
1184
+ ```
1185
+
1186
+ ### Instance Functions (instance:: namespace)
1187
+
1188
+ ```cssl
1189
+ @module = include("lib.cssl-mod");
1190
+
1191
+ instance::getMethods(@module); // Method names
1192
+ instance::getClasses(@module); // Class names
1193
+ instance::getVars(@module); // Variable names
1194
+ instance::getAll(@module); // Categorized dict
1195
+
1196
+ instance::call(@module, "methodName", arg1);
1197
+ instance::has(@module, "attribute");
1198
+ instance::type(@module); // Type name
1199
+
1200
+ isavailable("sharedName"); // Check if exists
1201
+ ```
1202
+
1203
+ ### Regex Functions
1204
+
1205
+ ```cssl
1206
+ match("\\d+", "abc123"); // Match at start
1207
+ search("\\d+", "abc123"); // Search anywhere
1208
+ findall("\\d+", "a1b2c3"); // ["1", "2", "3"]
1209
+ sub("\\d", "X", "a1b2"); // "aXbX"
1210
+ sub("\\d", "X", "a1b2", 1); // "aXb2" (count=1)
1211
+ ```
1212
+
1213
+ ### Hash Functions
1214
+
1215
+ ```cssl
1216
+ md5("hello"); // 32 hex chars
1217
+ sha1("hello"); // 40 hex chars
1218
+ sha256("hello"); // 64 hex chars
1219
+ ```
1220
+
1221
+ ### System Functions
1188
1222
 
1189
- env("PATH"); // Get env variable
1190
- setenv("MY_VAR", "val"); // Set env variable
1223
+ ```cssl
1224
+ exit(0); // Exit with code
1225
+ input("Enter name: "); // Read user input
1191
1226
 
1192
- copy(obj); // Shallow copy
1193
- deepcopy(obj); // Deep copy
1227
+ env("PATH"); // Get env variable
1228
+ setenv("MY_VAR", "val"); // Set env variable
1229
+
1230
+ copy(obj); // Shallow copy
1231
+ deepcopy(obj); // Deep copy
1232
+
1233
+ clear(); // Clear console
1194
1234
 
1195
- clear(); // Clear console
1235
+ pyimport("os"); // Import Python module
1236
+ include("lib.cssl-mod"); // Import CSSL module
1237
+ payload("helper.cssl-pl"); // Load payload
1196
1238
 
1197
- pyimport("os"); // Import Python module
1198
- include("lib.cssl-mod"); // Import CSSL module
1199
- payload("helper.cssl-pl"); // Load payload
1239
+ isLinux(); // Platform checks
1240
+ isWindows();
1241
+ isMac();
1242
+ ```
1200
1243
 
1201
- isLinux(); // Platform checks
1202
- isWindows();
1203
- isMac();
1204
- ```
1244
+ ### Filter Functions (filter:: namespace)
1205
1245
 
1206
- ### Filter Functions (filter:: namespace)
1246
+ ```cssl
1247
+ // Register custom filter
1248
+ filter::register("custom", "handler", callback);
1249
+ filter::unregister("custom", "handler");
1250
+ filter::list(); // All registered filters
1251
+ filter::exists("custom", "handler");
1252
+ ```
1207
1253
 
1208
- ```cssl
1209
- // Register custom filter
1210
- filter::register("custom", "handler", callback);
1211
- filter::unregister("custom", "handler");
1212
- filter::list(); // All registered filters
1213
- filter::exists("custom", "handler");
1214
- ```
1254
+ ---
1215
1255
 
1216
- ---
1256
+ ## CodeInfusion
1217
1257
 
1218
- ## CodeInfusion
1258
+ Modify functions at runtime.
1219
1259
 
1220
- Modify functions at runtime.
1260
+ ### <<== (Replace)
1221
1261
 
1222
- ### <<== (Replace)
1262
+ ```cssl
1263
+ void original() {
1264
+ printl("Original");
1265
+ }
1223
1266
 
1224
- ```cssl
1225
- void original() {
1226
- printl("Original");
1227
- }
1267
+ original() <<== {
1268
+ printl("Replaced");
1269
+ }
1228
1270
 
1229
- original() <<== {
1230
- printl("Replaced");
1231
- }
1271
+ original(); // "Replaced"
1272
+ ```
1232
1273
 
1233
- original(); // "Replaced"
1234
- ```
1274
+ ### +<<== (Add Before)
1235
1275
 
1236
- ### +<<== (Add Before)
1276
+ ```cssl
1277
+ void base() {
1278
+ printl("Base");
1279
+ }
1237
1280
 
1238
- ```cssl
1239
- void base() {
1240
- printl("Base");
1241
- }
1281
+ base() +<<== {
1282
+ printl("Added");
1283
+ }
1242
1284
 
1243
- base() +<<== {
1244
- printl("Added");
1245
- }
1285
+ base();
1286
+ // Output:
1287
+ // Added
1288
+ // Base
1289
+ ```
1246
1290
 
1247
- base();
1248
- // Output:
1249
- // Added
1250
- // Base
1251
- ```
1291
+ ### -<<== (Remove)
1252
1292
 
1253
- ### -<<== (Remove)
1293
+ ```cssl
1294
+ void withExtra() {
1295
+ printl("Important");
1296
+ printl("Unimportant");
1297
+ }
1254
1298
 
1255
- ```cssl
1256
- void withExtra() {
1257
- printl("Important");
1258
- printl("Unimportant");
1259
- }
1299
+ withExtra() -<<== {
1300
+ printl("Unimportant");
1301
+ }
1260
1302
 
1261
- withExtra() -<<== {
1262
- printl("Unimportant");
1263
- }
1303
+ withExtra(); // Only "Important"
1304
+ ```
1264
1305
 
1265
- withExtra(); // Only "Important"
1266
- ```
1306
+ ### Exit Injection
1267
1307
 
1268
- ### Exit Injection
1308
+ ```cssl
1309
+ exit() <<== {
1310
+ printl("Cleanup...");
1311
+ }
1269
1312
 
1270
- ```cssl
1271
- exit() <<== {
1272
- printl("Cleanup...");
1273
- }
1313
+ exit(); // Executes injection
1314
+ ```
1274
1315
 
1275
- exit(); // Executes injection
1276
- ```
1316
+ ---
1277
1317
 
1278
- ---
1318
+ ## BruteInjection
1279
1319
 
1280
- ## BruteInjection
1320
+ Transfer data between containers.
1281
1321
 
1282
- Transfer data between containers.
1322
+ ### +<== (Copy)
1283
1323
 
1284
- ### +<== (Copy)
1324
+ ```cssl
1325
+ stack<string> source;
1326
+ source.push("A");
1327
+ source.push("B");
1285
1328
 
1286
- ```cssl
1287
- stack<string> source;
1288
- source.push("A");
1289
- source.push("B");
1329
+ datastruct<string> target;
1330
+ target +<== source; // Copy A, B (source unchanged)
1331
+ ```
1290
1332
 
1291
- datastruct<string> target;
1292
- target +<== source; // Copy A, B (source unchanged)
1293
- ```
1333
+ ### -<== (Move)
1294
1334
 
1295
- ### -<== (Move)
1335
+ ```cssl
1336
+ stack<string> src;
1337
+ src.push("Data");
1296
1338
 
1297
- ```cssl
1298
- stack<string> src;
1299
- src.push("Data");
1339
+ datastruct<string> dst;
1340
+ dst -<== src; // src is empty after
1341
+ ```
1300
1342
 
1301
- datastruct<string> dst;
1302
- dst -<== src; // src is empty after
1303
- ```
1343
+ ### ==> (Replace)
1304
1344
 
1305
- ### ==> (Replace)
1345
+ ```cssl
1346
+ stack<string> data;
1347
+ data.push("New");
1306
1348
 
1307
- ```cssl
1308
- stack<string> data;
1309
- data.push("New");
1349
+ datastruct<string> container;
1350
+ container ==> data; // Replace container content
1351
+ ```
1310
1352
 
1311
- datastruct<string> container;
1312
- container ==> data; // Replace container content
1313
- ```
1353
+ ### ==>- (Remove Matching)
1314
1354
 
1315
- ### ==>- (Remove Matching)
1355
+ ```cssl
1356
+ stack<string> names;
1357
+ names.push("Alice");
1358
+ names.push("Bob");
1359
+ names.push("Alice");
1316
1360
 
1317
- ```cssl
1318
- stack<string> names;
1319
- names.push("Alice");
1320
- names.push("Bob");
1321
- names.push("Alice");
1361
+ stack<string> toRemove;
1362
+ toRemove.push("Alice");
1322
1363
 
1323
- stack<string> toRemove;
1324
- toRemove.push("Alice");
1364
+ names ==>- toRemove;
1365
+ printl(names); // ["Bob"]
1366
+ ```
1325
1367
 
1326
- names ==>- toRemove;
1327
- printl(names); // ["Bob"]
1328
- ```
1368
+ ### Filter Syntax
1329
1369
 
1330
- ### Filter Syntax
1370
+ ```cssl
1371
+ target +<== [type::filter=value] source;
1331
1372
 
1332
- ```cssl
1333
- target +<== [type::filter=value] source;
1373
+ // String filters
1374
+ result +<== [string::where="Apple"] fruits;
1375
+ result +<== [string::not="Banana"] fruits;
1376
+ result +<== [string::contains="App"] fruits;
1377
+ result +<== [string::length=5] fruits;
1378
+ result +<== [string::cut=3] version;
1379
+ result +<== [string::cutAfter="."] version;
1334
1380
 
1335
- // String filters
1336
- result +<== [string::where="Apple"] fruits;
1337
- result +<== [string::not="Banana"] fruits;
1338
- result +<== [string::contains="App"] fruits;
1339
- result +<== [string::length=5] fruits;
1340
- result +<== [string::cut=3] version;
1341
- result +<== [string::cutAfter="."] version;
1381
+ // Other filters
1382
+ result +<== [integer::where=42] numbers;
1383
+ result +<== [json::key="name"] objects;
1384
+ ```
1342
1385
 
1343
- // Other filters
1344
- result +<== [integer::where=42] numbers;
1345
- result +<== [json::key="name"] objects;
1346
- ```
1386
+ ---
1347
1387
 
1348
- ---
1388
+ ## Value Capture
1349
1389
 
1350
- ## Value Capture
1390
+ Capture values at registration time with `%`:
1351
1391
 
1352
- Capture values at registration time with `%`:
1392
+ ```cssl
1393
+ string version = "1.0.0";
1394
+ savedVersion <<== { %version; }
1353
1395
 
1354
- ```cssl
1355
- string version = "1.0.0";
1356
- savedVersion <<== { %version; }
1396
+ version = "2.0.0";
1397
+ printl(savedVersion); // "1.0.0" (captured value)
1398
+ ```
1357
1399
 
1358
- version = "2.0.0";
1359
- printl(savedVersion); // "1.0.0" (captured value)
1360
- ```
1400
+ ### Capturing Functions
1361
1401
 
1362
- ### Capturing Functions
1402
+ ```cssl
1403
+ originalExit <<== { %exit(); }
1363
1404
 
1364
- ```cssl
1365
- originalExit <<== { %exit(); }
1405
+ exit() <<== {
1406
+ printl("Custom cleanup");
1407
+ originalExit();
1408
+ }
1409
+ ```
1366
1410
 
1367
- exit() <<== {
1368
- printl("Custom cleanup");
1369
- originalExit();
1370
- }
1371
- ```
1411
+ ---
1372
1412
 
1373
- ---
1413
+ ## Module System
1374
1414
 
1375
- ## Module System
1415
+ ### Import CSSL Module
1376
1416
 
1377
- ### Import CSSL Module
1417
+ ```cssl
1418
+ @Math = include("mathlib.cssl-mod");
1419
+ int result = @Math.add(5, 3);
1420
+ ```
1378
1421
 
1379
- ```cssl
1380
- @Math = include("mathlib.cssl-mod");
1381
- int result = @Math.add(5, 3);
1382
- ```
1422
+ ### Import Python Module
1383
1423
 
1384
- ### Import Python Module
1424
+ ```cssl
1425
+ @os = pyimport("os");
1426
+ string cwd = @os.getcwd();
1385
1427
 
1386
- ```cssl
1387
- @os = pyimport("os");
1388
- string cwd = @os.getcwd();
1428
+ @datetime = pyimport("datetime");
1429
+ @datetime.datetime.now();
1430
+ ```
1389
1431
 
1390
- @datetime = pyimport("datetime");
1391
- @datetime.datetime.now();
1392
- ```
1432
+ ### Load Payload
1393
1433
 
1394
- ### Load Payload
1434
+ ```cssl
1435
+ payload("helpers.cssl-pl");
1436
+ ```
1395
1437
 
1396
- ```cssl
1397
- payload("helpers.cssl-pl");
1398
- ```
1438
+ ### Create Module (CLI)
1399
1439
 
1400
- ### Create Module (CLI)
1440
+ ```bash
1441
+ python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
1442
+ ```
1401
1443
 
1402
- ```bash
1403
- python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
1404
- ```
1444
+ ---
1405
1445
 
1406
- ---
1446
+ ## Multi-Language Support
1407
1447
 
1408
- ## Multi-Language Support
1448
+ CSSL v4.1.0 introduces multi-language support for interoperability with other programming languages.
1409
1449
 
1410
- CSSL v4.1.0 introduces multi-language support for interoperability with other programming languages.
1450
+ ### libinclude - Load Language Support
1411
1451
 
1412
- ### libinclude - Load Language Support
1452
+ Use `libinclude()` to load a language support module:
1413
1453
 
1414
- Use `libinclude()` to load a language support module:
1454
+ ```cssl
1455
+ // Load language support
1456
+ @py = libinclude("python");
1457
+ cpp = libinclude("c++");
1458
+ java = libinclude("java");
1459
+ csharp = libinclude("c#");
1460
+ js = libinclude("javascript");
1461
+ ```
1415
1462
 
1416
- ```cssl
1417
- // Load language support
1418
- @py = libinclude("python");
1419
- cpp = libinclude("c++");
1420
- java = libinclude("java");
1421
- csharp = libinclude("c#");
1422
- js = libinclude("javascript");
1423
- ```
1463
+ **Supported Languages:**
1424
1464
 
1425
- **Supported Languages:**
1465
+ | Language | Identifiers |
1466
+ |----------|-------------|
1467
+ | Python | `python`, `py` |
1468
+ | C++ | `c++`, `cpp` |
1469
+ | Java | `java` |
1470
+ | C# | `c#`, `csharp` |
1471
+ | JavaScript | `javascript`, `js` |
1426
1472
 
1427
- | Language | Identifiers |
1428
- |----------|-------------|
1429
- | Python | `python`, `py` |
1430
- | C++ | `c++`, `cpp` |
1431
- | Java | `java` |
1432
- | C# | `c#`, `csharp` |
1433
- | JavaScript | `javascript`, `js` |
1473
+ ### supports - Multi-Language Syntax
1434
1474
 
1435
- ### supports - Multi-Language Syntax
1475
+ Use the `supports` keyword to write functions or classes using another language's syntax:
1436
1476
 
1437
- Use the `supports` keyword to write functions or classes using another language's syntax:
1477
+ ```cssl
1478
+ // Python-style function
1479
+ define calculate(numbers) : supports python {
1480
+ total = 0
1481
+ for n in numbers:
1482
+ total = total + n
1483
+ return total
1484
+ }
1438
1485
 
1439
- ```cssl
1440
- // Python-style function
1441
- define calculate(numbers) : supports python {
1442
- total = 0
1443
- for n in numbers:
1444
- total = total + n
1445
- return total
1446
- }
1486
+ // C++ style class
1487
+ class Engine : supports cpp {
1488
+ int power;
1489
+ bool running;
1447
1490
 
1448
- // C++ style class
1449
- class Engine : supports cpp {
1450
- int power;
1451
- bool running;
1491
+ void start() {
1492
+ this->running = true;
1493
+ }
1494
+ }
1452
1495
 
1453
- void start() {
1454
- this->running = true;
1496
+ // JavaScript style function
1497
+ define fetchData(url) : supports javascript {
1498
+ let response = fetch(url);
1499
+ console.log("Fetched: " + url);
1500
+ return response;
1455
1501
  }
1456
- }
1502
+ ```
1503
+
1504
+ ### Cross-Language Instance Access
1457
1505
 
1458
- // JavaScript style function
1459
- define fetchData(url) : supports javascript {
1460
- let response = fetch(url);
1461
- console.log("Fetched: " + url);
1462
- return response;
1463
- }
1464
- ```
1506
+ Access instances shared from other languages using `lang$InstanceName` syntax:
1465
1507
 
1466
- ### Cross-Language Instance Access
1508
+ ```cssl
1509
+ cpp = libinclude("c++");
1467
1510
 
1468
- Access instances shared from other languages using `lang$InstanceName` syntax:
1511
+ // Access C++ shared instance
1512
+ engine = cpp$MyEngine;
1513
+ printl(engine.power);
1469
1514
 
1470
- ```cssl
1471
- cpp = libinclude("c++");
1515
+ // Cross-language inheritance
1516
+ class TurboEngine : extends cpp$Engine {
1517
+ int turboBoost;
1472
1518
 
1473
- // Access C++ shared instance
1474
- engine = cpp$MyEngine;
1475
- printl(engine.power);
1519
+ constr TurboEngine(int boost) {
1520
+ this->turboBoost = boost;
1521
+ }
1522
+ }
1523
+ ```
1524
+
1525
+ ### Instance Sharing API
1476
1526
 
1477
- // Cross-language inheritance
1478
- class TurboEngine : extends cpp$Engine {
1479
- int turboBoost;
1527
+ Share instances between languages using the `share()` and `get_instance()` methods:
1480
1528
 
1481
- constr TurboEngine(int boost) {
1482
- this->turboBoost = boost;
1529
+ ```cssl
1530
+ // Get language support
1531
+ cpp = libinclude("c++");
1532
+
1533
+ // Share a CSSL instance with C++
1534
+ class MyClass {
1535
+ string value;
1483
1536
  }
1484
- }
1485
- ```
1537
+ instance = new MyClass();
1538
+ cpp.share("MyClass", instance);
1539
+
1540
+ // Access from C++:
1541
+ // auto* obj = CSSL_GET(MyClass, "MyClass");
1542
+ ```
1486
1543
 
1487
- ### Instance Sharing API
1544
+ ### Language SDKs
1488
1545
 
1489
- Share instances between languages using the `share()` and `get_instance()` methods:
1546
+ SDKs are available for sharing instances from other languages into CSSL:
1490
1547
 
1491
- ```cssl
1492
- // Get language support
1493
- cpp = libinclude("c++");
1548
+ **C++ SDK:**
1549
+ ```cpp
1550
+ #include "includecpp.h"
1494
1551
 
1495
- // Share a CSSL instance with C++
1496
- class MyClass {
1497
- string value;
1498
- }
1499
- instance = new MyClass();
1500
- cpp.share("MyClass", instance);
1552
+ class Engine { public: int power = 100; };
1501
1553
 
1502
- // Access from C++:
1503
- // auto* obj = CSSL_GET(MyClass, "MyClass");
1504
- ```
1554
+ Engine engine;
1555
+ CSSL_SHARE(Engine, &engine);
1556
+ // Now accessible as cpp$Engine in CSSL
1557
+ ```
1505
1558
 
1506
- ### Language SDKs
1559
+ **Java SDK:**
1560
+ ```java
1561
+ import com.includecpp.CSSL;
1507
1562
 
1508
- SDKs are available for sharing instances from other languages into CSSL:
1563
+ MyService svc = new MyService();
1564
+ CSSL.share("MyService", svc);
1565
+ // Now accessible as java$MyService in CSSL
1566
+ ```
1509
1567
 
1510
- **C++ SDK:**
1511
- ```cpp
1512
- #include "includecpp.h"
1568
+ **C# SDK:**
1569
+ ```csharp
1570
+ using IncludeCPP;
1513
1571
 
1514
- class Engine { public: int power = 100; };
1515
-
1516
- Engine engine;
1517
- CSSL_SHARE(Engine, &engine);
1518
- // Now accessible as cpp$Engine in CSSL
1519
- ```
1520
-
1521
- **Java SDK:**
1522
- ```java
1523
- import com.includecpp.CSSL;
1524
-
1525
- MyService svc = new MyService();
1526
- CSSL.share("MyService", svc);
1527
- // Now accessible as java$MyService in CSSL
1528
- ```
1529
-
1530
- **C# SDK:**
1531
- ```csharp
1532
- using IncludeCPP;
1533
-
1534
- var service = new MyService();
1535
- CSSL.Share("MyService", service);
1536
- // Now accessible as csharp$MyService in CSSL
1537
- ```
1538
-
1539
- **JavaScript SDK:**
1540
- ```javascript
1541
- import { CSSL } from 'includecpp-cssl';
1542
-
1543
- class DataProcessor { process(data) { } }
1544
- CSSL.share('DataProcessor', new DataProcessor());
1545
- // Now accessible as js$DataProcessor in CSSL
1546
- ```
1547
-
1548
- ### SDK API Reference
1549
-
1550
- All language SDKs provide these methods:
1551
-
1552
- | Method | Description |
1553
- |--------|-------------|
1554
- | `share(name, instance)` | Share an instance by name |
1555
- | `get(name)` | Get a shared instance |
1556
- | `has(name)` | Check if instance exists |
1557
- | `remove(name)` | Remove a shared instance |
1558
- | `list()` | Get all instance names |
1559
- | `clear()` | Clear all instances |
1560
-
1561
- ---
1562
-
1563
- ## Error Handling
1564
-
1565
- ### Try / Catch
1566
-
1567
- ```cssl
1568
- try {
1569
- riskyOperation();
1570
- } catch (error) {
1571
- printl("Error: " + error);
1572
- }
1573
-
1574
- try {
1575
- operation();
1576
- } catch (error) {
1577
- printl("Error");
1578
- } finally {
1579
- printl("Always runs");
1580
- }
1581
- ```
1582
-
1583
- ### Undefined Functions
1584
-
1585
- ```cssl
1586
- undefined void safeOperation() {
1587
- dangerousCode(); // Errors ignored
1588
- }
1589
- ```
1590
-
1591
- ### Assert
1592
-
1593
- ```cssl
1594
- assert(x > 0, "x must be positive");
1595
- ```
1596
-
1597
- ---
1598
-
1599
- ## Quick Reference
1600
-
1601
- ### Keywords
1602
-
1603
- | Keyword | Description |
1604
- |---------|-------------|
1605
- | `void` | No return value |
1606
- | `return` | Return value |
1607
- | `global` | Declare global |
1608
- | `if` / `else` / `elif` | Conditionals |
1609
- | `switch` / `case` / `default` | Switch statement |
1610
- | `for` / `foreach` / `while` | Loops |
1611
- | `break` / `continue` | Loop control |
1612
- | `try` / `catch` / `finally` | Error handling |
1613
- | `class` / `new` / `this` | OOP |
1614
- | `extends` / `overwrites` | Inheritance |
1615
- | `constr` | Constructor |
1616
- | `define` | Function definition |
1617
- | `undefined` | Ignore errors |
1618
- | `closed` / `private` | Injection protection |
1619
- | `virtual` | Import-safe |
1620
- | `meta` / `super` | Special function types |
1621
- | `shuffled` | Multiple returns |
1622
- | `open` | Any parameters |
1623
- | `include` / `get` | Import modules |
1624
-
1625
- ### Injection Operators
1626
-
1627
- | Operator | Type | Description |
1628
- |----------|------|-------------|
1629
- | `<<==` | CodeInfusion | Replace function |
1630
- | `+<<==` | CodeInfusion | Add code before |
1631
- | `-<<==` | CodeInfusion | Remove code |
1632
- | `<==` | ValueCapture | Capture/assign |
1633
- | `+<==` | BruteInjection | Copy data |
1634
- | `-<==` | BruteInjection | Move data |
1635
- | `==>` | BruteInjection | Replace data |
1636
- | `==>-` | BruteInjection | Remove matching |
1637
- | `++` | AppendMode | Append to parent |
1638
-
1639
- ### Special Syntax
1640
-
1641
- | Syntax | Description |
1642
- |--------|-------------|
1643
- | `@name` | Global variable access |
1644
- | `@name = value` | Global variable assignment |
1645
- | `r@name = value` | Global reference assignment |
1646
- | `$name` | Shared Python object |
1647
- | `%name` | Captured value |
1648
- | `this->` | Class member access |
1649
- | `super::method()` | Parent method call |
1650
- | `json::func()` | Namespace function |
1651
- | `&ClassName::member` | Class member reference |
1652
- | `&FunctionName ++` | Append to function |
1653
- | `*func()` | Non-null function |
1654
- | `*[type]func()` | Type exclusion filter |
1655
- | `global class Name` | Global class declaration |
1656
- | `class @Name` | Global class (alt syntax) |
1657
- | `global define func()` | Global function declaration |
1658
- | `define @func()` | Global function (alt syntax) |
1659
- | `new @ClassName()` | Instantiate global class |
1660
- | `libinclude("lang")` | Load language support module |
1661
- | `supports lang` | Use other language syntax |
1662
- | `lang$InstanceName` | Cross-language instance access |
1663
-
1664
- ### Multi-Language Keywords
1665
-
1666
- | Keyword | Description |
1667
- |---------|-------------|
1668
- | `libinclude` | Load language support module |
1669
- | `supports` | Use another language's syntax in function/class |
1670
-
1671
- ### Cross-Language Syntax
1672
-
1673
- | Syntax | Description | Example |
1674
- |--------|-------------|---------|
1675
- | `libinclude("lang")` | Load language support | `cpp = libinclude("c++")` |
1676
- | `: supports lang` | Use language syntax | `define func() : supports python { }` |
1677
- | `lang$Name` | Access shared instance | `cpp$Engine`, `java$Service` |
1678
- | `extends lang$Name` | Inherit from shared class | `class Child : extends cpp$Parent { }` |
1679
-
1680
- ---
1681
-
1682
- *CSSL v4.1.0 - Developed as part of IncludeCPP*
1572
+ var service = new MyService();
1573
+ CSSL.Share("MyService", service);
1574
+ // Now accessible as csharp$MyService in CSSL
1575
+ ```
1576
+
1577
+ **JavaScript SDK:**
1578
+ ```javascript
1579
+ import { CSSL } from 'includecpp-cssl';
1580
+
1581
+ class DataProcessor { process(data) { } }
1582
+ CSSL.share('DataProcessor', new DataProcessor());
1583
+ // Now accessible as js$DataProcessor in CSSL
1584
+ ```
1585
+
1586
+ ### SDK API Reference
1587
+
1588
+ All language SDKs provide these methods:
1589
+
1590
+ | Method | Description |
1591
+ |--------|-------------|
1592
+ | `share(name, instance)` | Share an instance by name |
1593
+ | `get(name)` | Get a shared instance |
1594
+ | `has(name)` | Check if instance exists |
1595
+ | `remove(name)` | Remove a shared instance |
1596
+ | `list()` | Get all instance names |
1597
+ | `clear()` | Clear all instances |
1598
+
1599
+ ---
1600
+
1601
+ ## Error Handling
1602
+
1603
+ ### Try / Catch
1604
+
1605
+ ```cssl
1606
+ try {
1607
+ riskyOperation();
1608
+ } catch (error) {
1609
+ printl("Error: " + error);
1610
+ }
1611
+
1612
+ try {
1613
+ operation();
1614
+ } catch (error) {
1615
+ printl("Error");
1616
+ } finally {
1617
+ printl("Always runs");
1618
+ }
1619
+ ```
1620
+
1621
+ ### Undefined Functions
1622
+
1623
+ ```cssl
1624
+ undefined void safeOperation() {
1625
+ dangerousCode(); // Errors ignored
1626
+ }
1627
+ ```
1628
+
1629
+ ### Assert
1630
+
1631
+ ```cssl
1632
+ assert(x > 0, "x must be positive");
1633
+ ```
1634
+
1635
+ ---
1636
+
1637
+ ## Quick Reference
1638
+
1639
+ ### Keywords
1640
+
1641
+ | Keyword | Description |
1642
+ |---------|-------------|
1643
+ | `void` | No return value |
1644
+ | `return` | Return value |
1645
+ | `global` | Declare global |
1646
+ | `if` / `else` / `elif` | Conditionals |
1647
+ | `switch` / `case` / `default` | Switch statement |
1648
+ | `for` / `foreach` / `while` | Loops |
1649
+ | `break` / `continue` | Loop control |
1650
+ | `try` / `catch` / `finally` | Error handling |
1651
+ | `class` / `new` / `this` | OOP |
1652
+ | `extends` / `overwrites` | Inheritance |
1653
+ | `constr` | Constructor |
1654
+ | `define` | Function definition |
1655
+ | `undefined` | Ignore errors |
1656
+ | `closed` / `private` | Injection protection |
1657
+ | `virtual` | Import-safe |
1658
+ | `meta` / `super` | Special function types |
1659
+ | `shuffled` | Multiple returns |
1660
+ | `open` | Any parameters |
1661
+ | `include` / `get` | Import modules |
1662
+
1663
+ ### Injection Operators
1664
+
1665
+ | Operator | Type | Description |
1666
+ |----------|------|-------------|
1667
+ | `<<==` | CodeInfusion | Replace function |
1668
+ | `+<<==` | CodeInfusion | Add code before |
1669
+ | `-<<==` | CodeInfusion | Remove code |
1670
+ | `<==` | ValueCapture | Capture/assign |
1671
+ | `+<==` | BruteInjection | Copy data |
1672
+ | `-<==` | BruteInjection | Move data |
1673
+ | `==>` | BruteInjection | Replace data |
1674
+ | `==>-` | BruteInjection | Remove matching |
1675
+ | `++` | AppendMode | Append to parent |
1676
+
1677
+ ### Special Syntax
1678
+
1679
+ | Syntax | Description |
1680
+ |--------|-------------|
1681
+ | `@name` | Global variable access |
1682
+ | `@name = value` | Global variable assignment |
1683
+ | `r@name = value` | Global reference assignment |
1684
+ | `$name` | Shared Python object |
1685
+ | `%name` | Captured value |
1686
+ | `this->` | Class member access |
1687
+ | `super::method()` | Parent method call |
1688
+ | `json::func()` | Namespace function |
1689
+ | `&ClassName::member` | Class member reference |
1690
+ | `&FunctionName ++` | Append to function |
1691
+ | `*func()` | Non-null function |
1692
+ | `*[type]func()` | Type exclusion filter |
1693
+ | `global class Name` | Global class declaration |
1694
+ | `class @Name` | Global class (alt syntax) |
1695
+ | `global define func()` | Global function declaration |
1696
+ | `define @func()` | Global function (alt syntax) |
1697
+ | `new @ClassName()` | Instantiate global class |
1698
+ | `libinclude("lang")` | Load language support module |
1699
+ | `supports lang` | Use other language syntax |
1700
+ | `lang$InstanceName` | Cross-language instance access |
1701
+
1702
+ ### Multi-Language Keywords
1703
+
1704
+ | Keyword | Description |
1705
+ |---------|-------------|
1706
+ | `libinclude` | Load language support module |
1707
+ | `supports` | Use another language's syntax in function/class |
1708
+
1709
+ ### Cross-Language Syntax
1710
+
1711
+ | Syntax | Description | Example |
1712
+ |--------|-------------|---------|
1713
+ | `libinclude("lang")` | Load language support | `cpp = libinclude("c++")` |
1714
+ | `: supports lang` | Use language syntax | `define func() : supports python { }` |
1715
+ | `lang$Name` | Access shared instance | `cpp$Engine`, `java$Service` |
1716
+ | `extends lang$Name` | Inherit from shared class | `class Child : extends cpp$Parent { }` |
1717
+
1718
+ ---
1719
+
1720
+ *CSSL v4.1.0 - Developed as part of IncludeCPP*