IncludeCPP 3.8.8__py3-none-any.whl → 4.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- includecpp/__init__.py +1 -1
- includecpp/core/cssl/CSSL_DOCUMENTATION.md +877 -1781
- includecpp/core/cssl/CSSL_DOCUMENTATION_NEW.md +1348 -0
- includecpp/core/cssl/cssl_builtins.pyi +231 -0
- includecpp/core/cssl/cssl_parser.py +439 -94
- includecpp/core/cssl/cssl_runtime.py +498 -27
- includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +25 -0
- {includecpp-3.8.8.dist-info → includecpp-4.0.0.dist-info}/METADATA +1 -1
- {includecpp-3.8.8.dist-info → includecpp-4.0.0.dist-info}/RECORD +13 -12
- {includecpp-3.8.8.dist-info → includecpp-4.0.0.dist-info}/WHEEL +0 -0
- {includecpp-3.8.8.dist-info → includecpp-4.0.0.dist-info}/entry_points.txt +0 -0
- {includecpp-3.8.8.dist-info → includecpp-4.0.0.dist-info}/licenses/LICENSE +0 -0
- {includecpp-3.8.8.dist-info → includecpp-4.0.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,1348 @@
|
|
|
1
|
+
# CSSL - C-Style Scripting Language
|
|
2
|
+
|
|
3
|
+
> Version 3.9.0 | A modern scripting language with C++-style syntax and unique features like CodeInfusion, BruteInjection, and Python Interop.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
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. [Error Handling](#error-handling)
|
|
24
|
+
16. [Quick Reference](#quick-reference)
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
### Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install includecpp
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Python Usage
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from includecpp import CSSL
|
|
40
|
+
|
|
41
|
+
# Execute CSSL code
|
|
42
|
+
CSSL.run('''
|
|
43
|
+
printl("Hello CSSL!");
|
|
44
|
+
''')
|
|
45
|
+
|
|
46
|
+
# With parameters and return value
|
|
47
|
+
result = CSSL.run('''
|
|
48
|
+
string name = parameter.get(0);
|
|
49
|
+
printl("Hello " + name);
|
|
50
|
+
parameter.return(true);
|
|
51
|
+
''', "World")
|
|
52
|
+
|
|
53
|
+
print(result) # True
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### CLI Execution
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Execute CSSL file
|
|
60
|
+
python -m includecpp cssl exec myfile.cssl
|
|
61
|
+
|
|
62
|
+
# Create module from Python file
|
|
63
|
+
python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### First Script
|
|
67
|
+
|
|
68
|
+
```cssl
|
|
69
|
+
// Variables
|
|
70
|
+
string name = "CSSL";
|
|
71
|
+
int version = 3;
|
|
72
|
+
|
|
73
|
+
// Output
|
|
74
|
+
printl("Welcome to " + name);
|
|
75
|
+
|
|
76
|
+
// Function
|
|
77
|
+
void greet(string msg) {
|
|
78
|
+
printl(msg);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
greet("Hello World!");
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Syntax Basics
|
|
87
|
+
|
|
88
|
+
### Comments
|
|
89
|
+
|
|
90
|
+
```cssl
|
|
91
|
+
// Single-line comment (C-style)
|
|
92
|
+
# Single-line comment (Python-style)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Semicolons
|
|
96
|
+
|
|
97
|
+
Semicolons are optional but recommended for clarity.
|
|
98
|
+
|
|
99
|
+
```cssl
|
|
100
|
+
printl("Hello") // Works
|
|
101
|
+
printl("Hello"); // Also works (recommended)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Output Functions
|
|
105
|
+
|
|
106
|
+
```cssl
|
|
107
|
+
printl("Text"); // Print with newline
|
|
108
|
+
print("No newline"); // Print without newline
|
|
109
|
+
debug("Debug info"); // Print with [DEBUG] prefix
|
|
110
|
+
error("Error message"); // Print with [ERROR] prefix
|
|
111
|
+
warn("Warning"); // Print with [WARN] prefix
|
|
112
|
+
log("INFO", "Message"); // Print with custom prefix
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Data Types
|
|
118
|
+
|
|
119
|
+
### Primitive Types
|
|
120
|
+
|
|
121
|
+
| Type | Description | Example |
|
|
122
|
+
|------|-------------|---------|
|
|
123
|
+
| `int` | Integer | `int x = 42;` |
|
|
124
|
+
| `float` | Floating point | `float f = 3.14;` |
|
|
125
|
+
| `string` | Text string | `string s = "Hello";` |
|
|
126
|
+
| `bool` | Boolean | `bool b = true;` |
|
|
127
|
+
| `dynamic` | Any type (flexible) | `dynamic x = "text";` |
|
|
128
|
+
| `void` | No return value | `void func() { }` |
|
|
129
|
+
| `null` | Absence of value | `dynamic x = null;` |
|
|
130
|
+
|
|
131
|
+
### Generic Container Types
|
|
132
|
+
|
|
133
|
+
| Type | Description | Example |
|
|
134
|
+
|------|-------------|---------|
|
|
135
|
+
| `stack<T>` | LIFO stack | `stack<string> names;` |
|
|
136
|
+
| `vector<T>` | Dynamic array | `vector<int> nums;` |
|
|
137
|
+
| `array<T>` | Standard array | `array<float> values;` |
|
|
138
|
+
| `map<K,V>` | Ordered key-value | `map<string, int> ages;` |
|
|
139
|
+
| `list` | Python-like list | `list items = [1, 2, 3];` |
|
|
140
|
+
| `dict` | Dictionary | `dict data = {"a": 1};` |
|
|
141
|
+
| `datastruct<T>` | Universal container | `datastruct<string> data;` |
|
|
142
|
+
| `iterator<T>` | Programmable iterator | `iterator<int> it;` |
|
|
143
|
+
| `shuffled<T>` | Multi-value returns | `shuffled<string> results;` |
|
|
144
|
+
| `combo<T>` | Filter/search space | `combo<string> search;` |
|
|
145
|
+
|
|
146
|
+
### Type Conversion
|
|
147
|
+
|
|
148
|
+
```cssl
|
|
149
|
+
int("42"); // String to int: 42
|
|
150
|
+
float("3.14"); // String to float: 3.14
|
|
151
|
+
str(42); // Int to string: "42"
|
|
152
|
+
bool(1); // Int to bool: true
|
|
153
|
+
int("ff", 16); // Hex to int: 255
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Type Checking
|
|
157
|
+
|
|
158
|
+
```cssl
|
|
159
|
+
typeof(42); // "int"
|
|
160
|
+
typeof("hello"); // "str"
|
|
161
|
+
isinstance(42, "int"); // true
|
|
162
|
+
isint(42); // true
|
|
163
|
+
isstr("hello"); // true
|
|
164
|
+
isnull(null); // true
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Variables & Globals
|
|
170
|
+
|
|
171
|
+
### Local Variables
|
|
172
|
+
|
|
173
|
+
```cssl
|
|
174
|
+
string name = "Alice";
|
|
175
|
+
int count = 10;
|
|
176
|
+
float price = 19.99;
|
|
177
|
+
bool active = true;
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Global Variables
|
|
181
|
+
|
|
182
|
+
```cssl
|
|
183
|
+
// Declaration with 'global' keyword
|
|
184
|
+
global myGlobal = "visible everywhere";
|
|
185
|
+
|
|
186
|
+
// Access with '@' prefix
|
|
187
|
+
printl(@myGlobal);
|
|
188
|
+
|
|
189
|
+
// Alternative: r@ syntax
|
|
190
|
+
r@anotherGlobal = "also global";
|
|
191
|
+
printl(@anotherGlobal);
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Shared Objects ($)
|
|
195
|
+
|
|
196
|
+
Access Python objects shared via `CSSL.share()`:
|
|
197
|
+
|
|
198
|
+
```cssl
|
|
199
|
+
// Access shared Python object
|
|
200
|
+
$counter.value = 100;
|
|
201
|
+
$counter.increment();
|
|
202
|
+
|
|
203
|
+
// Delete shared object
|
|
204
|
+
delete("counter");
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Captured References (%)
|
|
208
|
+
|
|
209
|
+
Capture value at registration time:
|
|
210
|
+
|
|
211
|
+
```cssl
|
|
212
|
+
string version = "1.0";
|
|
213
|
+
savedVersion <<== { %version; }
|
|
214
|
+
version = "2.0";
|
|
215
|
+
printl(savedVersion); // Still "1.0"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Operators
|
|
221
|
+
|
|
222
|
+
### Arithmetic
|
|
223
|
+
|
|
224
|
+
| Operator | Description | Example |
|
|
225
|
+
|----------|-------------|---------|
|
|
226
|
+
| `+` | Addition / Concatenation | `a + b` |
|
|
227
|
+
| `-` | Subtraction | `a - b` |
|
|
228
|
+
| `*` | Multiplication | `a * b` |
|
|
229
|
+
| `/` | Division | `a / b` |
|
|
230
|
+
| `%` | Modulo | `a % b` |
|
|
231
|
+
|
|
232
|
+
### Comparison
|
|
233
|
+
|
|
234
|
+
| Operator | Description | Example |
|
|
235
|
+
|----------|-------------|---------|
|
|
236
|
+
| `==` | Equal | `a == b` |
|
|
237
|
+
| `!=` | Not equal | `a != b` |
|
|
238
|
+
| `<` | Less than | `a < b` |
|
|
239
|
+
| `>` | Greater than | `a > b` |
|
|
240
|
+
| `<=` | Less or equal | `a <= b` |
|
|
241
|
+
| `>=` | Greater or equal | `a >= b` |
|
|
242
|
+
|
|
243
|
+
### Logical
|
|
244
|
+
|
|
245
|
+
| Operator | Description | Example |
|
|
246
|
+
|----------|-------------|---------|
|
|
247
|
+
| `&&` | AND | `a && b` |
|
|
248
|
+
| `\|\|` | OR | `a \|\| b` |
|
|
249
|
+
| `!` | NOT | `!a` |
|
|
250
|
+
| `and` | AND (keyword) | `a and b` |
|
|
251
|
+
| `or` | OR (keyword) | `a or b` |
|
|
252
|
+
| `not` | NOT (keyword) | `not a` |
|
|
253
|
+
|
|
254
|
+
### Increment/Decrement (in for-loops)
|
|
255
|
+
|
|
256
|
+
| Operator | Description | Example |
|
|
257
|
+
|----------|-------------|---------|
|
|
258
|
+
| `++` | Increment | `i++` |
|
|
259
|
+
| `--` | Decrement | `i--` |
|
|
260
|
+
| `+=` | Add assign | `i += 1` |
|
|
261
|
+
| `-=` | Subtract assign | `i -= 1` |
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Control Flow
|
|
266
|
+
|
|
267
|
+
### If / Else If / Else
|
|
268
|
+
|
|
269
|
+
```cssl
|
|
270
|
+
if (x < 5) {
|
|
271
|
+
printl("Small");
|
|
272
|
+
} else if (x < 15) {
|
|
273
|
+
printl("Medium");
|
|
274
|
+
} else {
|
|
275
|
+
printl("Large");
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// elif also works
|
|
279
|
+
if (x < 5) {
|
|
280
|
+
printl("Small");
|
|
281
|
+
} elif (x < 15) {
|
|
282
|
+
printl("Medium");
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Switch / Case
|
|
287
|
+
|
|
288
|
+
```cssl
|
|
289
|
+
switch (day) {
|
|
290
|
+
case 1:
|
|
291
|
+
printl("Monday");
|
|
292
|
+
break;
|
|
293
|
+
case 2:
|
|
294
|
+
printl("Tuesday");
|
|
295
|
+
break;
|
|
296
|
+
default:
|
|
297
|
+
printl("Other");
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### While Loop
|
|
302
|
+
|
|
303
|
+
```cssl
|
|
304
|
+
int i = 0;
|
|
305
|
+
while (i < 5) {
|
|
306
|
+
printl(i);
|
|
307
|
+
i = i + 1;
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### For Loop (Python-Style)
|
|
312
|
+
|
|
313
|
+
```cssl
|
|
314
|
+
// Range-based
|
|
315
|
+
for (i in range(5)) {
|
|
316
|
+
printl(i); // 0, 1, 2, 3, 4
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// With start and end
|
|
320
|
+
for (i in range(10, 15)) {
|
|
321
|
+
printl(i); // 10, 11, 12, 13, 14
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// With step
|
|
325
|
+
for (i in range(0, 10, 2)) {
|
|
326
|
+
printl(i); // 0, 2, 4, 6, 8
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### For Loop (C-Style)
|
|
331
|
+
|
|
332
|
+
```cssl
|
|
333
|
+
for (int i = 0; i < 10; i++) {
|
|
334
|
+
printl(i);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
for (int i = 10; i > 0; i--) {
|
|
338
|
+
printl(i);
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Foreach
|
|
343
|
+
|
|
344
|
+
```cssl
|
|
345
|
+
stack<string> names;
|
|
346
|
+
names.push("Alice");
|
|
347
|
+
names.push("Bob");
|
|
348
|
+
|
|
349
|
+
// Syntax 1
|
|
350
|
+
foreach (name in names) {
|
|
351
|
+
printl(name);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Syntax 2
|
|
355
|
+
foreach names as name {
|
|
356
|
+
printl(name);
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Break & Continue
|
|
361
|
+
|
|
362
|
+
```cssl
|
|
363
|
+
for (i in range(10)) {
|
|
364
|
+
if (i == 5) break; // Exit loop
|
|
365
|
+
if (i == 3) continue; // Skip iteration
|
|
366
|
+
printl(i);
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Functions
|
|
373
|
+
|
|
374
|
+
### Basic Syntax
|
|
375
|
+
|
|
376
|
+
```cssl
|
|
377
|
+
// Without return
|
|
378
|
+
void sayHello() {
|
|
379
|
+
printl("Hello!");
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// With return
|
|
383
|
+
string getName() {
|
|
384
|
+
return "CSSL";
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// With parameters
|
|
388
|
+
int add(int a, int b) {
|
|
389
|
+
return a + b;
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Define Functions
|
|
394
|
+
|
|
395
|
+
```cssl
|
|
396
|
+
// Simple function without type
|
|
397
|
+
define greet() {
|
|
398
|
+
printl("Hello!");
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// With parameters
|
|
402
|
+
define greet(string name) {
|
|
403
|
+
printl("Hello " + name);
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Function Modifiers
|
|
408
|
+
|
|
409
|
+
| Modifier | Description |
|
|
410
|
+
|----------|-------------|
|
|
411
|
+
| `undefined` | Silently ignore errors |
|
|
412
|
+
| `closed` | Block external CodeInfusion |
|
|
413
|
+
| `private` | Block all CodeInfusion |
|
|
414
|
+
| `virtual` | Import-cycle safe |
|
|
415
|
+
| `meta` | Source function (must return) |
|
|
416
|
+
| `super` | Force execution (no exceptions) |
|
|
417
|
+
| `open` | Accept any parameters |
|
|
418
|
+
| `shuffled` | Return multiple values |
|
|
419
|
+
|
|
420
|
+
```cssl
|
|
421
|
+
// Ignore errors
|
|
422
|
+
undefined void mayFail() {
|
|
423
|
+
riskyOperation();
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// Protected from injection
|
|
427
|
+
closed void protected() {
|
|
428
|
+
printl("Protected");
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Multiple returns
|
|
432
|
+
shuffled string getNames() {
|
|
433
|
+
return "Alice", "Bob", "Charlie";
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
a, b, c = getNames();
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### Non-Null Functions (*)
|
|
440
|
+
|
|
441
|
+
Functions that must never return null:
|
|
442
|
+
|
|
443
|
+
```cssl
|
|
444
|
+
// Non-null function
|
|
445
|
+
define *alwaysReturns() {
|
|
446
|
+
return "Always a value";
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// Non-null assertion on value
|
|
450
|
+
this->name = *$System.os; // Error if null
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
### Type Exclusion Filter (*[type])
|
|
454
|
+
|
|
455
|
+
Functions that must NOT return a specific type:
|
|
456
|
+
|
|
457
|
+
```cssl
|
|
458
|
+
// Must NOT return string
|
|
459
|
+
shuffled *[string] getNumbers() {
|
|
460
|
+
return 1, 2, 3; // OK
|
|
461
|
+
// return "text"; // Error!
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// Must NOT return null
|
|
465
|
+
define *[null] getValue() {
|
|
466
|
+
return 42; // OK
|
|
467
|
+
}
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### Open Parameters
|
|
471
|
+
|
|
472
|
+
```cssl
|
|
473
|
+
open define flexibleFunc(open Params) {
|
|
474
|
+
string name = OpenFind<string>(0);
|
|
475
|
+
int num = OpenFind<int>(0);
|
|
476
|
+
printl(name + " " + num);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
flexibleFunc("Hello", 123, true);
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
484
|
+
## Classes & OOP
|
|
485
|
+
|
|
486
|
+
### Class Definition
|
|
487
|
+
|
|
488
|
+
```cssl
|
|
489
|
+
class Person {
|
|
490
|
+
string name;
|
|
491
|
+
int age;
|
|
492
|
+
|
|
493
|
+
// Constructor
|
|
494
|
+
void Person(string n, int a) {
|
|
495
|
+
this->name = n;
|
|
496
|
+
this->age = a;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
void greet() {
|
|
500
|
+
printl("Hello, I'm " + this->name);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
string getName() {
|
|
504
|
+
return this->name;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
### Creating Instances
|
|
510
|
+
|
|
511
|
+
```cssl
|
|
512
|
+
Person p = new Person("Alice", 30);
|
|
513
|
+
p.greet();
|
|
514
|
+
printl(p.name);
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### Constructor with `constr` Keyword
|
|
518
|
+
|
|
519
|
+
```cssl
|
|
520
|
+
class Vehicle {
|
|
521
|
+
string brand;
|
|
522
|
+
|
|
523
|
+
constr Initialize(string b) {
|
|
524
|
+
this->brand = b;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
constr SetupDefaults() {
|
|
528
|
+
printl("Vehicle ready");
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
Vehicle v = new Vehicle("Toyota");
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
### Class Inheritance
|
|
536
|
+
|
|
537
|
+
```cssl
|
|
538
|
+
class Animal {
|
|
539
|
+
string name;
|
|
540
|
+
|
|
541
|
+
void Animal(string n) {
|
|
542
|
+
this->name = n;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
void speak() {
|
|
546
|
+
printl("Sound");
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
class Dog : extends Animal {
|
|
551
|
+
void Dog(string n) {
|
|
552
|
+
this->name = n;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
void speak() {
|
|
556
|
+
printl("Woof! I'm " + this->name);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
Dog d = new Dog("Buddy");
|
|
561
|
+
d.speak(); // "Woof! I'm Buddy"
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
### super() and super::method()
|
|
565
|
+
|
|
566
|
+
```cssl
|
|
567
|
+
class Child : extends Parent {
|
|
568
|
+
constr ChildInit(string name) {
|
|
569
|
+
super(name); // Call parent constructor
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
void speak() {
|
|
573
|
+
super::speak(); // Call parent method
|
|
574
|
+
printl("Child speaking");
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
### Append Mode (++)
|
|
580
|
+
|
|
581
|
+
Extend constructors/functions while keeping original code:
|
|
582
|
+
|
|
583
|
+
```cssl
|
|
584
|
+
// Original function
|
|
585
|
+
define BaseFunc() {
|
|
586
|
+
printl("Base functionality");
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// Append to BaseFunc
|
|
590
|
+
define ExtendedFunc() &BaseFunc ++ {
|
|
591
|
+
printl("Extended functionality");
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
ExtendedFunc();
|
|
595
|
+
// Output:
|
|
596
|
+
// Base functionality
|
|
597
|
+
// Extended functionality
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
```cssl
|
|
601
|
+
class MyClass {
|
|
602
|
+
constr MyClassConstructor() {
|
|
603
|
+
printl("MyClass constructor");
|
|
604
|
+
this->value = 10;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
class BetterClass :: extends MyClass {
|
|
609
|
+
constr BetterConstructor() &MyClass::MyClassConstructor ++ {
|
|
610
|
+
printl("BetterClass - added code");
|
|
611
|
+
this->extra = 20;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
### Non-Null Class
|
|
617
|
+
|
|
618
|
+
```cssl
|
|
619
|
+
class *MyClass {
|
|
620
|
+
// All methods must return non-null
|
|
621
|
+
string getValue() {
|
|
622
|
+
return "Value";
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
---
|
|
628
|
+
|
|
629
|
+
## Container Types
|
|
630
|
+
|
|
631
|
+
### stack\<T\> - LIFO Stack
|
|
632
|
+
|
|
633
|
+
```cssl
|
|
634
|
+
stack<string> names;
|
|
635
|
+
names.push("Alice");
|
|
636
|
+
names.push("Bob");
|
|
637
|
+
|
|
638
|
+
printl(names.pop()); // "Bob"
|
|
639
|
+
printl(names.peek()); // "Alice" (doesn't remove)
|
|
640
|
+
printl(names.size()); // 1
|
|
641
|
+
printl(names.isEmpty()); // false
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
**Methods:**
|
|
645
|
+
|
|
646
|
+
| Method | Description |
|
|
647
|
+
|--------|-------------|
|
|
648
|
+
| `push(value)` | Add to top |
|
|
649
|
+
| `pop()` | Remove and return top |
|
|
650
|
+
| `peek()` | View top without removing |
|
|
651
|
+
| `size()` / `length()` | Element count |
|
|
652
|
+
| `isEmpty()` / `is_empty()` | Check if empty |
|
|
653
|
+
| `contains(value)` | Check if contains |
|
|
654
|
+
| `indexOf(value)` | Find index (-1 if not found) |
|
|
655
|
+
| `toArray()` | Convert to list |
|
|
656
|
+
| `swap()` | Swap top two elements |
|
|
657
|
+
| `dup()` | Duplicate top element |
|
|
658
|
+
|
|
659
|
+
### vector\<T\> - Dynamic Array
|
|
660
|
+
|
|
661
|
+
```cssl
|
|
662
|
+
vector<int> nums;
|
|
663
|
+
nums.push(10);
|
|
664
|
+
nums.push(20);
|
|
665
|
+
|
|
666
|
+
printl(nums.at(0)); // 10
|
|
667
|
+
printl(nums.front()); // 10
|
|
668
|
+
printl(nums.back()); // 20
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
**Methods:**
|
|
672
|
+
|
|
673
|
+
| Method | Description |
|
|
674
|
+
|--------|-------------|
|
|
675
|
+
| `push(value)` / `push_back(value)` | Add to end |
|
|
676
|
+
| `push_front(value)` | Add to front |
|
|
677
|
+
| `pop_back()` | Remove from end |
|
|
678
|
+
| `pop_front()` | Remove from front |
|
|
679
|
+
| `at(index)` | Get element |
|
|
680
|
+
| `set(index, value)` | Set element |
|
|
681
|
+
| `front()` | Get first |
|
|
682
|
+
| `back()` | Get last |
|
|
683
|
+
| `size()` / `length()` | Element count |
|
|
684
|
+
| `empty()` / `isEmpty()` | Check if empty |
|
|
685
|
+
| `contains(value)` | Check if contains |
|
|
686
|
+
| `indexOf(value)` | Find first index |
|
|
687
|
+
| `lastIndexOf(value)` | Find last index |
|
|
688
|
+
| `slice(start, end)` | Get sub-vector |
|
|
689
|
+
| `join(separator)` | Join to string |
|
|
690
|
+
| `map(func)` | Apply function |
|
|
691
|
+
| `filter(predicate)` | Filter elements |
|
|
692
|
+
| `forEach(func)` | Execute for each |
|
|
693
|
+
| `every(predicate)` | Check all match |
|
|
694
|
+
| `some(predicate)` | Check any match |
|
|
695
|
+
| `reduce(func, initial)` | Reduce to value |
|
|
696
|
+
| `toArray()` | Convert to list |
|
|
697
|
+
|
|
698
|
+
### map\<K,V\> - Ordered Key-Value
|
|
699
|
+
|
|
700
|
+
```cssl
|
|
701
|
+
map<string, int> ages;
|
|
702
|
+
ages.insert("Alice", 30);
|
|
703
|
+
ages.insert("Bob", 25);
|
|
704
|
+
|
|
705
|
+
printl(ages.find("Alice")); // 30
|
|
706
|
+
printl(ages.contains("Bob")); // true
|
|
707
|
+
ages.erase("Bob");
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
**Methods:**
|
|
711
|
+
|
|
712
|
+
| Method | Description |
|
|
713
|
+
|--------|-------------|
|
|
714
|
+
| `insert(key, value)` | Insert/update pair |
|
|
715
|
+
| `find(key)` | Get value (null if not found) |
|
|
716
|
+
| `at(key)` | Get value (throws if not found) |
|
|
717
|
+
| `erase(key)` | Remove key |
|
|
718
|
+
| `contains(key)` | Check if key exists |
|
|
719
|
+
| `count(key)` | Count (0 or 1) |
|
|
720
|
+
| `size()` | Pair count |
|
|
721
|
+
| `empty()` | Check if empty |
|
|
722
|
+
| `begin()` | First key-value tuple |
|
|
723
|
+
| `end()` | Last key-value tuple |
|
|
724
|
+
| `lower_bound(key)` | First key >= given |
|
|
725
|
+
| `upper_bound(key)` | First key > given |
|
|
726
|
+
|
|
727
|
+
### datastruct\<T\> - Universal Container
|
|
728
|
+
|
|
729
|
+
Primary target for BruteInjection operations.
|
|
730
|
+
|
|
731
|
+
```cssl
|
|
732
|
+
datastruct<string> data;
|
|
733
|
+
data.add("item1");
|
|
734
|
+
data.add("item2");
|
|
735
|
+
|
|
736
|
+
printl(data.content()); // All elements
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
**Methods:**
|
|
740
|
+
|
|
741
|
+
| Method | Description |
|
|
742
|
+
|--------|-------------|
|
|
743
|
+
| `content()` | Get all elements |
|
|
744
|
+
| `add(value)` | Add element |
|
|
745
|
+
| `remove_where(predicate)` | Remove matching |
|
|
746
|
+
| `find_where(predicate)` | Find first matching |
|
|
747
|
+
| `convert(type)` | Convert first element |
|
|
748
|
+
|
|
749
|
+
### shuffled\<T\> - Multiple Returns
|
|
750
|
+
|
|
751
|
+
```cssl
|
|
752
|
+
shuffled string getInfo() {
|
|
753
|
+
return "Alice", "Bob", "Charlie";
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
a, b, c = getInfo();
|
|
757
|
+
printl(a); // "Alice"
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
---
|
|
761
|
+
|
|
762
|
+
## Built-in Functions
|
|
763
|
+
|
|
764
|
+
### String Operations
|
|
765
|
+
|
|
766
|
+
```cssl
|
|
767
|
+
string s = "Hello World";
|
|
768
|
+
|
|
769
|
+
// Case
|
|
770
|
+
upper(s); // "HELLO WORLD"
|
|
771
|
+
lower(s); // "hello world"
|
|
772
|
+
capitalize(s); // "Hello world"
|
|
773
|
+
title(s); // "Hello World"
|
|
774
|
+
|
|
775
|
+
// Trim
|
|
776
|
+
trim(" text "); // "text"
|
|
777
|
+
ltrim(" text"); // "text"
|
|
778
|
+
rtrim("text "); // "text"
|
|
779
|
+
|
|
780
|
+
// Search
|
|
781
|
+
contains(s, "World"); // true
|
|
782
|
+
startswith(s, "Hello"); // true
|
|
783
|
+
endswith(s, "World"); // true
|
|
784
|
+
indexof(s, "o"); // 4
|
|
785
|
+
lastindexof(s, "o"); // 7
|
|
786
|
+
|
|
787
|
+
// Manipulation
|
|
788
|
+
replace(s, "World", "CSSL"); // "Hello CSSL"
|
|
789
|
+
substr(s, 0, 5); // "Hello"
|
|
790
|
+
split(s, " "); // ["Hello", "World"]
|
|
791
|
+
join("-", ["a", "b"]); // "a-b"
|
|
792
|
+
repeat("ab", 3); // "ababab"
|
|
793
|
+
reverse(s); // "dlroW olleH"
|
|
794
|
+
|
|
795
|
+
// Padding
|
|
796
|
+
padleft("42", 5, "0"); // "00042"
|
|
797
|
+
padright("42", 5, "."); // "42..."
|
|
798
|
+
center("hi", 6, "-"); // "--hi--"
|
|
799
|
+
zfill("42", 5); // "00042"
|
|
800
|
+
|
|
801
|
+
// Character
|
|
802
|
+
len(s); // 11
|
|
803
|
+
chars("abc"); // ["a", "b", "c"]
|
|
804
|
+
ord("A"); // 65
|
|
805
|
+
chr(65); // "A"
|
|
806
|
+
|
|
807
|
+
// Checks
|
|
808
|
+
isalpha("abc"); // true
|
|
809
|
+
isdigit("123"); // true
|
|
810
|
+
isalnum("abc123"); // true
|
|
811
|
+
isspace(" "); // true
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
### Array/List Operations
|
|
815
|
+
|
|
816
|
+
```cssl
|
|
817
|
+
stack<int> arr = [1, 2, 3, 4, 5];
|
|
818
|
+
|
|
819
|
+
// Add/Remove
|
|
820
|
+
push(arr, 6); // Add to end
|
|
821
|
+
pop(arr); // Remove last
|
|
822
|
+
shift(arr); // Remove first
|
|
823
|
+
unshift(arr, 0); // Add to front
|
|
824
|
+
|
|
825
|
+
// Access
|
|
826
|
+
first(arr); // First element
|
|
827
|
+
last(arr); // Last element
|
|
828
|
+
slice(arr, 1, 3); // [2, 3]
|
|
829
|
+
|
|
830
|
+
// Transform
|
|
831
|
+
sort(arr); // Sort ascending
|
|
832
|
+
rsort(arr); // Sort descending
|
|
833
|
+
reversed(arr); // Reverse copy
|
|
834
|
+
shuffle(arr); // Random order
|
|
835
|
+
unique(arr); // Remove duplicates
|
|
836
|
+
flatten([[1,2],[3,4]]); // [1, 2, 3, 4]
|
|
837
|
+
|
|
838
|
+
// Search
|
|
839
|
+
find(arr, x => x > 3); // First matching
|
|
840
|
+
findindex(arr, x => x > 3);
|
|
841
|
+
every(arr, x => x > 0); // All match?
|
|
842
|
+
some(arr, x => x > 3); // Any match?
|
|
843
|
+
count(arr, 2); // Count of 2
|
|
844
|
+
|
|
845
|
+
// Functional
|
|
846
|
+
map(arr, x => x * 2); // [2, 4, 6, 8, 10]
|
|
847
|
+
filter(arr, x => x > 2); // [3, 4, 5]
|
|
848
|
+
reduce(arr, (a,b) => a+b, 0); // 15
|
|
849
|
+
|
|
850
|
+
// Utilities
|
|
851
|
+
range(5); // [0, 1, 2, 3, 4]
|
|
852
|
+
range(1, 5); // [1, 2, 3, 4]
|
|
853
|
+
range(0, 10, 2); // [0, 2, 4, 6, 8]
|
|
854
|
+
enumerate(arr); // [(0,1), (1,2), ...]
|
|
855
|
+
zip([1,2], ["a","b"]); // [(1,"a"), (2,"b")]
|
|
856
|
+
take(arr, 3); // First 3 elements
|
|
857
|
+
drop(arr, 2); // Skip first 2
|
|
858
|
+
chunk(arr, 2); // [[1,2], [3,4], [5]]
|
|
859
|
+
sample(arr, 2); // 2 random elements
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
### Dictionary Operations
|
|
863
|
+
|
|
864
|
+
```cssl
|
|
865
|
+
dict d = {"name": "Alice", "age": 30};
|
|
866
|
+
|
|
867
|
+
keys(d); // ["name", "age"]
|
|
868
|
+
values(d); // ["Alice", 30]
|
|
869
|
+
items(d); // [("name","Alice"), ...]
|
|
870
|
+
haskey(d, "name"); // true
|
|
871
|
+
getkey(d, "name"); // "Alice"
|
|
872
|
+
getkey(d, "x", "default"); // "default"
|
|
873
|
+
setkey(d, "city", "NYC"); // Add key
|
|
874
|
+
delkey(d, "age"); // Remove key
|
|
875
|
+
merge(d1, d2); // Merge dicts
|
|
876
|
+
update(d, {"new": 1}); // Update in place
|
|
877
|
+
fromkeys(["a","b"], 0); // {"a": 0, "b": 0}
|
|
878
|
+
invert({"a": 1}); // {1: "a"}
|
|
879
|
+
pick(d, "name"); // {"name": "Alice"}
|
|
880
|
+
omit(d, "age"); // {"name": "Alice"}
|
|
881
|
+
```
|
|
882
|
+
|
|
883
|
+
### Math Functions
|
|
884
|
+
|
|
885
|
+
```cssl
|
|
886
|
+
abs(-5); // 5
|
|
887
|
+
min(3, 1, 2); // 1
|
|
888
|
+
max(3, 1, 2); // 3
|
|
889
|
+
sum([1, 2, 3]); // 6
|
|
890
|
+
avg([1, 2, 3, 4, 5]); // 3.0
|
|
891
|
+
|
|
892
|
+
round(3.14159, 2); // 3.14
|
|
893
|
+
floor(3.9); // 3
|
|
894
|
+
ceil(3.1); // 4
|
|
895
|
+
|
|
896
|
+
pow(2, 3); // 8
|
|
897
|
+
sqrt(16); // 4
|
|
898
|
+
mod(7, 3); // 1
|
|
899
|
+
|
|
900
|
+
sin(0); // 0.0
|
|
901
|
+
cos(0); // 1.0
|
|
902
|
+
tan(0); // 0.0
|
|
903
|
+
asin(1); // 1.5708
|
|
904
|
+
acos(0); // 1.5708
|
|
905
|
+
atan(1); // 0.7854
|
|
906
|
+
atan2(1, 1); // 0.7854
|
|
907
|
+
|
|
908
|
+
log(e()); // 1.0
|
|
909
|
+
log10(100); // 2.0
|
|
910
|
+
exp(1); // 2.71828
|
|
911
|
+
|
|
912
|
+
pi(); // 3.14159...
|
|
913
|
+
e(); // 2.71828...
|
|
914
|
+
radians(180); // 3.14159
|
|
915
|
+
degrees(3.14159); // 180
|
|
916
|
+
|
|
917
|
+
random(); // 0.0 to 1.0
|
|
918
|
+
randint(1, 6); // 1 to 6
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
### Date/Time Functions
|
|
922
|
+
|
|
923
|
+
```cssl
|
|
924
|
+
now(); // Unix timestamp (float)
|
|
925
|
+
timestamp(); // Unix timestamp (int)
|
|
926
|
+
date(); // "2025-12-30"
|
|
927
|
+
date("%d/%m/%Y"); // "30/12/2025"
|
|
928
|
+
time(); // "14:30:45"
|
|
929
|
+
datetime(); // "2025-12-30 14:30:45"
|
|
930
|
+
strftime("%Y-%m-%d", ts);
|
|
931
|
+
|
|
932
|
+
sleep(1.5); // Wait 1.5 seconds
|
|
933
|
+
delay(500); // Wait 500 milliseconds
|
|
934
|
+
```
|
|
935
|
+
|
|
936
|
+
### File I/O Functions
|
|
937
|
+
|
|
938
|
+
```cssl
|
|
939
|
+
// Read
|
|
940
|
+
string content = read("file.txt");
|
|
941
|
+
string line5 = readline(5, "file.txt");
|
|
942
|
+
stack<string> lines = readlines("file.txt");
|
|
943
|
+
|
|
944
|
+
// Write
|
|
945
|
+
write("file.txt", "Hello");
|
|
946
|
+
writeline(3, "New line", "file.txt");
|
|
947
|
+
appendfile("file.txt", "\nMore");
|
|
948
|
+
|
|
949
|
+
// Path operations
|
|
950
|
+
basename("/path/to/file.txt"); // "file.txt"
|
|
951
|
+
dirname("/path/to/file.txt"); // "/path/to"
|
|
952
|
+
joinpath("/path", "file.txt"); // "/path/file.txt"
|
|
953
|
+
abspath("./file.txt");
|
|
954
|
+
normpath("/path/../other");
|
|
955
|
+
|
|
956
|
+
// Checks
|
|
957
|
+
pathexists("file.txt"); // true/false
|
|
958
|
+
isfile("file.txt"); // true/false
|
|
959
|
+
isdir("folder"); // true/false
|
|
960
|
+
filesize("file.txt"); // bytes
|
|
961
|
+
|
|
962
|
+
// Directory
|
|
963
|
+
listdir("./"); // ["file1", "file2"]
|
|
964
|
+
makedirs("new/folder");
|
|
965
|
+
removefile("file.txt");
|
|
966
|
+
removedir("folder");
|
|
967
|
+
copyfile("src", "dst");
|
|
968
|
+
movefile("old", "new");
|
|
969
|
+
```
|
|
970
|
+
|
|
971
|
+
### JSON Functions (json:: namespace)
|
|
972
|
+
|
|
973
|
+
```cssl
|
|
974
|
+
// File operations
|
|
975
|
+
json data = json::read("config.json");
|
|
976
|
+
json::write("output.json", data);
|
|
977
|
+
|
|
978
|
+
// Parse/Stringify
|
|
979
|
+
json obj = json::parse('{"name": "Alice"}');
|
|
980
|
+
string str = json::stringify(obj);
|
|
981
|
+
string pretty = json::pretty(obj);
|
|
982
|
+
|
|
983
|
+
// Path operations
|
|
984
|
+
json::get(data, "user.name");
|
|
985
|
+
json::get(data, "user.age", 0); // with default
|
|
986
|
+
json::set(data, "user.name", "Bob");
|
|
987
|
+
json::has(data, "user.email");
|
|
988
|
+
|
|
989
|
+
// Object operations
|
|
990
|
+
json::keys(obj); // ["name"]
|
|
991
|
+
json::values(obj); // ["Alice"]
|
|
992
|
+
json::merge(obj1, obj2); // Deep merge
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
### Instance Functions (instance:: namespace)
|
|
996
|
+
|
|
997
|
+
```cssl
|
|
998
|
+
@module = include("lib.cssl-mod");
|
|
999
|
+
|
|
1000
|
+
instance::getMethods(@module); // Method names
|
|
1001
|
+
instance::getClasses(@module); // Class names
|
|
1002
|
+
instance::getVars(@module); // Variable names
|
|
1003
|
+
instance::getAll(@module); // Categorized dict
|
|
1004
|
+
|
|
1005
|
+
instance::call(@module, "methodName", arg1);
|
|
1006
|
+
instance::has(@module, "attribute");
|
|
1007
|
+
instance::type(@module); // Type name
|
|
1008
|
+
|
|
1009
|
+
isavailable("sharedName"); // Check if exists
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
### Regex Functions
|
|
1013
|
+
|
|
1014
|
+
```cssl
|
|
1015
|
+
match("\\d+", "abc123"); // Match at start
|
|
1016
|
+
search("\\d+", "abc123"); // Search anywhere
|
|
1017
|
+
findall("\\d+", "a1b2c3"); // ["1", "2", "3"]
|
|
1018
|
+
sub("\\d", "X", "a1b2"); // "aXbX"
|
|
1019
|
+
sub("\\d", "X", "a1b2", 1); // "aXb2" (count=1)
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
### Hash Functions
|
|
1023
|
+
|
|
1024
|
+
```cssl
|
|
1025
|
+
md5("hello"); // 32 hex chars
|
|
1026
|
+
sha1("hello"); // 40 hex chars
|
|
1027
|
+
sha256("hello"); // 64 hex chars
|
|
1028
|
+
```
|
|
1029
|
+
|
|
1030
|
+
### System Functions
|
|
1031
|
+
|
|
1032
|
+
```cssl
|
|
1033
|
+
exit(0); // Exit with code
|
|
1034
|
+
input("Enter name: "); // Read user input
|
|
1035
|
+
|
|
1036
|
+
env("PATH"); // Get env variable
|
|
1037
|
+
setenv("MY_VAR", "val"); // Set env variable
|
|
1038
|
+
|
|
1039
|
+
copy(obj); // Shallow copy
|
|
1040
|
+
deepcopy(obj); // Deep copy
|
|
1041
|
+
|
|
1042
|
+
clear(); // Clear console
|
|
1043
|
+
|
|
1044
|
+
pyimport("os"); // Import Python module
|
|
1045
|
+
include("lib.cssl-mod"); // Import CSSL module
|
|
1046
|
+
payload("helper.cssl-pl"); // Load payload
|
|
1047
|
+
|
|
1048
|
+
isLinux(); // Platform checks
|
|
1049
|
+
isWindows();
|
|
1050
|
+
isMac();
|
|
1051
|
+
```
|
|
1052
|
+
|
|
1053
|
+
### Filter Functions (filter:: namespace)
|
|
1054
|
+
|
|
1055
|
+
```cssl
|
|
1056
|
+
// Register custom filter
|
|
1057
|
+
filter::register("custom", "handler", callback);
|
|
1058
|
+
filter::unregister("custom", "handler");
|
|
1059
|
+
filter::list(); // All registered filters
|
|
1060
|
+
filter::exists("custom", "handler");
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
---
|
|
1064
|
+
|
|
1065
|
+
## CodeInfusion
|
|
1066
|
+
|
|
1067
|
+
Modify functions at runtime.
|
|
1068
|
+
|
|
1069
|
+
### <<== (Replace)
|
|
1070
|
+
|
|
1071
|
+
```cssl
|
|
1072
|
+
void original() {
|
|
1073
|
+
printl("Original");
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
original() <<== {
|
|
1077
|
+
printl("Replaced");
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
original(); // "Replaced"
|
|
1081
|
+
```
|
|
1082
|
+
|
|
1083
|
+
### +<<== (Add Before)
|
|
1084
|
+
|
|
1085
|
+
```cssl
|
|
1086
|
+
void base() {
|
|
1087
|
+
printl("Base");
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
base() +<<== {
|
|
1091
|
+
printl("Added");
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
base();
|
|
1095
|
+
// Output:
|
|
1096
|
+
// Added
|
|
1097
|
+
// Base
|
|
1098
|
+
```
|
|
1099
|
+
|
|
1100
|
+
### -<<== (Remove)
|
|
1101
|
+
|
|
1102
|
+
```cssl
|
|
1103
|
+
void withExtra() {
|
|
1104
|
+
printl("Important");
|
|
1105
|
+
printl("Unimportant");
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
withExtra() -<<== {
|
|
1109
|
+
printl("Unimportant");
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
withExtra(); // Only "Important"
|
|
1113
|
+
```
|
|
1114
|
+
|
|
1115
|
+
### Exit Injection
|
|
1116
|
+
|
|
1117
|
+
```cssl
|
|
1118
|
+
exit() <<== {
|
|
1119
|
+
printl("Cleanup...");
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
exit(); // Executes injection
|
|
1123
|
+
```
|
|
1124
|
+
|
|
1125
|
+
---
|
|
1126
|
+
|
|
1127
|
+
## BruteInjection
|
|
1128
|
+
|
|
1129
|
+
Transfer data between containers.
|
|
1130
|
+
|
|
1131
|
+
### +<== (Copy)
|
|
1132
|
+
|
|
1133
|
+
```cssl
|
|
1134
|
+
stack<string> source;
|
|
1135
|
+
source.push("A");
|
|
1136
|
+
source.push("B");
|
|
1137
|
+
|
|
1138
|
+
datastruct<string> target;
|
|
1139
|
+
target +<== source; // Copy A, B (source unchanged)
|
|
1140
|
+
```
|
|
1141
|
+
|
|
1142
|
+
### -<== (Move)
|
|
1143
|
+
|
|
1144
|
+
```cssl
|
|
1145
|
+
stack<string> src;
|
|
1146
|
+
src.push("Data");
|
|
1147
|
+
|
|
1148
|
+
datastruct<string> dst;
|
|
1149
|
+
dst -<== src; // src is empty after
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
### ==> (Replace)
|
|
1153
|
+
|
|
1154
|
+
```cssl
|
|
1155
|
+
stack<string> data;
|
|
1156
|
+
data.push("New");
|
|
1157
|
+
|
|
1158
|
+
datastruct<string> container;
|
|
1159
|
+
container ==> data; // Replace container content
|
|
1160
|
+
```
|
|
1161
|
+
|
|
1162
|
+
### ==>- (Remove Matching)
|
|
1163
|
+
|
|
1164
|
+
```cssl
|
|
1165
|
+
stack<string> names;
|
|
1166
|
+
names.push("Alice");
|
|
1167
|
+
names.push("Bob");
|
|
1168
|
+
names.push("Alice");
|
|
1169
|
+
|
|
1170
|
+
stack<string> toRemove;
|
|
1171
|
+
toRemove.push("Alice");
|
|
1172
|
+
|
|
1173
|
+
names ==>- toRemove;
|
|
1174
|
+
printl(names); // ["Bob"]
|
|
1175
|
+
```
|
|
1176
|
+
|
|
1177
|
+
### Filter Syntax
|
|
1178
|
+
|
|
1179
|
+
```cssl
|
|
1180
|
+
target +<== [type::filter=value] source;
|
|
1181
|
+
|
|
1182
|
+
// String filters
|
|
1183
|
+
result +<== [string::where="Apple"] fruits;
|
|
1184
|
+
result +<== [string::not="Banana"] fruits;
|
|
1185
|
+
result +<== [string::contains="App"] fruits;
|
|
1186
|
+
result +<== [string::length=5] fruits;
|
|
1187
|
+
result +<== [string::cut=3] version;
|
|
1188
|
+
result +<== [string::cutAfter="."] version;
|
|
1189
|
+
|
|
1190
|
+
// Other filters
|
|
1191
|
+
result +<== [integer::where=42] numbers;
|
|
1192
|
+
result +<== [json::key="name"] objects;
|
|
1193
|
+
```
|
|
1194
|
+
|
|
1195
|
+
---
|
|
1196
|
+
|
|
1197
|
+
## Value Capture
|
|
1198
|
+
|
|
1199
|
+
Capture values at registration time with `%`:
|
|
1200
|
+
|
|
1201
|
+
```cssl
|
|
1202
|
+
string version = "1.0.0";
|
|
1203
|
+
savedVersion <<== { %version; }
|
|
1204
|
+
|
|
1205
|
+
version = "2.0.0";
|
|
1206
|
+
printl(savedVersion); // "1.0.0" (captured value)
|
|
1207
|
+
```
|
|
1208
|
+
|
|
1209
|
+
### Capturing Functions
|
|
1210
|
+
|
|
1211
|
+
```cssl
|
|
1212
|
+
originalExit <<== { %exit(); }
|
|
1213
|
+
|
|
1214
|
+
exit() <<== {
|
|
1215
|
+
printl("Custom cleanup");
|
|
1216
|
+
originalExit();
|
|
1217
|
+
}
|
|
1218
|
+
```
|
|
1219
|
+
|
|
1220
|
+
---
|
|
1221
|
+
|
|
1222
|
+
## Module System
|
|
1223
|
+
|
|
1224
|
+
### Import CSSL Module
|
|
1225
|
+
|
|
1226
|
+
```cssl
|
|
1227
|
+
@Math = include("mathlib.cssl-mod");
|
|
1228
|
+
int result = @Math.add(5, 3);
|
|
1229
|
+
```
|
|
1230
|
+
|
|
1231
|
+
### Import Python Module
|
|
1232
|
+
|
|
1233
|
+
```cssl
|
|
1234
|
+
@os = pyimport("os");
|
|
1235
|
+
string cwd = @os.getcwd();
|
|
1236
|
+
|
|
1237
|
+
@datetime = pyimport("datetime");
|
|
1238
|
+
@datetime.datetime.now();
|
|
1239
|
+
```
|
|
1240
|
+
|
|
1241
|
+
### Load Payload
|
|
1242
|
+
|
|
1243
|
+
```cssl
|
|
1244
|
+
payload("helpers.cssl-pl");
|
|
1245
|
+
```
|
|
1246
|
+
|
|
1247
|
+
### Create Module (CLI)
|
|
1248
|
+
|
|
1249
|
+
```bash
|
|
1250
|
+
python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
|
|
1251
|
+
```
|
|
1252
|
+
|
|
1253
|
+
---
|
|
1254
|
+
|
|
1255
|
+
## Error Handling
|
|
1256
|
+
|
|
1257
|
+
### Try / Catch
|
|
1258
|
+
|
|
1259
|
+
```cssl
|
|
1260
|
+
try {
|
|
1261
|
+
riskyOperation();
|
|
1262
|
+
} catch (error) {
|
|
1263
|
+
printl("Error: " + error);
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
try {
|
|
1267
|
+
operation();
|
|
1268
|
+
} catch (error) {
|
|
1269
|
+
printl("Error");
|
|
1270
|
+
} finally {
|
|
1271
|
+
printl("Always runs");
|
|
1272
|
+
}
|
|
1273
|
+
```
|
|
1274
|
+
|
|
1275
|
+
### Undefined Functions
|
|
1276
|
+
|
|
1277
|
+
```cssl
|
|
1278
|
+
undefined void safeOperation() {
|
|
1279
|
+
dangerousCode(); // Errors ignored
|
|
1280
|
+
}
|
|
1281
|
+
```
|
|
1282
|
+
|
|
1283
|
+
### Assert
|
|
1284
|
+
|
|
1285
|
+
```cssl
|
|
1286
|
+
assert(x > 0, "x must be positive");
|
|
1287
|
+
```
|
|
1288
|
+
|
|
1289
|
+
---
|
|
1290
|
+
|
|
1291
|
+
## Quick Reference
|
|
1292
|
+
|
|
1293
|
+
### Keywords
|
|
1294
|
+
|
|
1295
|
+
| Keyword | Description |
|
|
1296
|
+
|---------|-------------|
|
|
1297
|
+
| `void` | No return value |
|
|
1298
|
+
| `return` | Return value |
|
|
1299
|
+
| `global` | Declare global |
|
|
1300
|
+
| `if` / `else` / `elif` | Conditionals |
|
|
1301
|
+
| `switch` / `case` / `default` | Switch statement |
|
|
1302
|
+
| `for` / `foreach` / `while` | Loops |
|
|
1303
|
+
| `break` / `continue` | Loop control |
|
|
1304
|
+
| `try` / `catch` / `finally` | Error handling |
|
|
1305
|
+
| `class` / `new` / `this` | OOP |
|
|
1306
|
+
| `extends` / `overwrites` | Inheritance |
|
|
1307
|
+
| `constr` | Constructor |
|
|
1308
|
+
| `define` | Function definition |
|
|
1309
|
+
| `undefined` | Ignore errors |
|
|
1310
|
+
| `closed` / `private` | Injection protection |
|
|
1311
|
+
| `virtual` | Import-safe |
|
|
1312
|
+
| `meta` / `super` | Special function types |
|
|
1313
|
+
| `shuffled` | Multiple returns |
|
|
1314
|
+
| `open` | Any parameters |
|
|
1315
|
+
| `include` / `get` | Import modules |
|
|
1316
|
+
|
|
1317
|
+
### Injection Operators
|
|
1318
|
+
|
|
1319
|
+
| Operator | Type | Description |
|
|
1320
|
+
|----------|------|-------------|
|
|
1321
|
+
| `<<==` | CodeInfusion | Replace function |
|
|
1322
|
+
| `+<<==` | CodeInfusion | Add code before |
|
|
1323
|
+
| `-<<==` | CodeInfusion | Remove code |
|
|
1324
|
+
| `<==` | ValueCapture | Capture/assign |
|
|
1325
|
+
| `+<==` | BruteInjection | Copy data |
|
|
1326
|
+
| `-<==` | BruteInjection | Move data |
|
|
1327
|
+
| `==>` | BruteInjection | Replace data |
|
|
1328
|
+
| `==>-` | BruteInjection | Remove matching |
|
|
1329
|
+
| `++` | AppendMode | Append to parent |
|
|
1330
|
+
|
|
1331
|
+
### Special Syntax
|
|
1332
|
+
|
|
1333
|
+
| Syntax | Description |
|
|
1334
|
+
|--------|-------------|
|
|
1335
|
+
| `@name` | Global variable |
|
|
1336
|
+
| `$name` | Shared Python object |
|
|
1337
|
+
| `%name` | Captured value |
|
|
1338
|
+
| `this->` | Class member access |
|
|
1339
|
+
| `super::method()` | Parent method call |
|
|
1340
|
+
| `json::func()` | Namespace function |
|
|
1341
|
+
| `&ClassName::member` | Class member reference |
|
|
1342
|
+
| `&FunctionName ++` | Append to function |
|
|
1343
|
+
| `*func()` | Non-null function |
|
|
1344
|
+
| `*[type]func()` | Type exclusion filter |
|
|
1345
|
+
|
|
1346
|
+
---
|
|
1347
|
+
|
|
1348
|
+
*CSSL v3.9.0 - Developed as part of IncludeCPP*
|