IncludeCPP 3.4.8__py3-none-any.whl → 3.4.21__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.
@@ -0,0 +1,1482 @@
1
+ # CSSL - C-Style Scripting Language
2
+
3
+ > Version 3.4.20 | A modern scripting language with C++-style syntax and unique features like CodeInfusion and BruteInjection.
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [Quick Start](#quick-start)
10
+ 2. [Basics](#basics)
11
+ 3. [Data Types](#data-types)
12
+ 4. [Container Types](#container-types)
13
+ 5. [Variables & Globals](#variables--globals)
14
+ 6. [Control Structures](#control-structures)
15
+ 7. [Functions](#functions)
16
+ 8. [Function Keywords](#function-keywords)
17
+ 9. [String Methods](#string-methods)
18
+ 10. [Live Object Sharing](#live-object-sharing)
19
+ 11. [CodeInfusion](#codeinfusion)
20
+ 12. [BruteInjection](#bruteinjection)
21
+ 13. [Filter Syntax](#filter-syntax)
22
+ 14. [Module System](#module-system)
23
+ 15. [Parameter Bridge](#parameter-bridge)
24
+ 16. [Structures](#structures)
25
+ 17. [Error Handling](#error-handling)
26
+ 18. [CLI Commands](#cli-commands)
27
+ 19. [Examples](#examples)
28
+
29
+ ---
30
+
31
+ ## Quick Start
32
+
33
+ ### Installation & Usage
34
+
35
+ ```python
36
+ from includecpp import CSSL
37
+
38
+ # Initialize CSSL
39
+ CSSL.CsslLang()
40
+
41
+ # Execute code
42
+ CSSL.exec("""
43
+ printl("Hello CSSL!");
44
+ """)
45
+
46
+ # With parameters and return value
47
+ result = CSSL.exec("""
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
63
+ python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
64
+ ```
65
+
66
+ ### First Steps
67
+
68
+ ```cssl
69
+ // Declare variables
70
+ string name = "CSSL";
71
+ int version = 3;
72
+
73
+ // Output
74
+ printl("Welcome to " + name);
75
+ printl(version);
76
+
77
+ // Define function
78
+ void greet(string msg) {
79
+ printl(msg);
80
+ }
81
+ greet("Hello World!");
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Basics
87
+
88
+ ### Comments
89
+
90
+ ```cssl
91
+ // Single-line comment
92
+
93
+ /*
94
+ Multi-line
95
+ comment
96
+ */
97
+ ```
98
+
99
+ ### Output
100
+
101
+ ```cssl
102
+ printl("Text"); // With newline
103
+ printl(variable); // Print variable
104
+ printl("Value: " + var); // String concatenation
105
+ printl("Number: " + 42); // String + Int works!
106
+ ```
107
+
108
+ ### Operators
109
+
110
+ #### Arithmetic Operators
111
+
112
+ | Operator | Description | Example |
113
+ |----------|-------------|---------|
114
+ | `+` | Addition / String concatenation | `a + b` |
115
+ | `-` | Subtraction | `a - b` |
116
+ | `*` | Multiplication | `a * b` |
117
+ | `/` | Division | `a / b` |
118
+ | `%` | Modulo (remainder) | `a % b` |
119
+
120
+ #### Comparison Operators
121
+
122
+ | Operator | Description | Example |
123
+ |----------|-------------|---------|
124
+ | `==` | Equality | `a == b` |
125
+ | `!=` | Inequality | `a != b` |
126
+ | `<` | Less than | `a < b` |
127
+ | `>` | Greater than | `a > b` |
128
+ | `<=` | Less than or equal | `a <= b` |
129
+ | `>=` | Greater than or equal | `a >= b` |
130
+
131
+ #### Logical Operators
132
+
133
+ | Operator | Description | Example |
134
+ |----------|-------------|---------|
135
+ | `&&` | Logical AND | `a && b` |
136
+ | `\|\|` | Logical OR | `a \|\| b` |
137
+ | `!` | Logical NOT | `!condition` |
138
+ | `not` | Logical NOT (alternative) | `not condition` |
139
+
140
+ #### Increment/Decrement (only in C-style for-loops)
141
+
142
+ | Operator | Description | Example |
143
+ |----------|-------------|---------|
144
+ | `++` | Increment | `i++` |
145
+ | `--` | Decrement | `i--` |
146
+ | `+=` | Addition assignment | `i += 1` |
147
+ | `-=` | Subtraction assignment | `i -= 1` |
148
+
149
+ ---
150
+
151
+ ## Data Types
152
+
153
+ ### Primitive Types
154
+
155
+ | Type | Description | Example |
156
+ |------|-------------|---------|
157
+ | `string` | Text string | `string s = "Hello";` |
158
+ | `int` | Integer | `int i = 42;` |
159
+ | `float` | Floating point | `float f = 3.14;` |
160
+ | `bool` | Boolean | `bool b = true;` |
161
+ | `json` | JSON object | `json j;` |
162
+ | `dynamic` | Dynamic type | `dynamic x = "anything";` |
163
+
164
+ ### Examples
165
+
166
+ ```cssl
167
+ // String
168
+ string greeting = "Hello";
169
+ string name = "World";
170
+ string combined = greeting + " " + name;
171
+ printl(combined); // "Hello World"
172
+
173
+ // Integer
174
+ int count = 10;
175
+ int doubled = count * 2;
176
+ printl(doubled); // 20
177
+
178
+ // Float
179
+ float price = 19.99;
180
+ printl(price);
181
+
182
+ // Boolean
183
+ bool active = true;
184
+ bool disabled = false;
185
+
186
+ // Dynamic (flexible, but slower)
187
+ dynamic anything = "first string";
188
+ anything = 123; // now int
189
+ anything = 3.14; // now float
190
+ ```
191
+
192
+ ---
193
+
194
+ ## Container Types
195
+
196
+ ### stack\<T\>
197
+
198
+ LIFO data structure (Last In, First Out).
199
+
200
+ ```cssl
201
+ stack<string> names;
202
+ names.push("Alice");
203
+ names.push("Bob");
204
+ names.push("Charlie");
205
+
206
+ printl(names); // ['Alice', 'Bob', 'Charlie']
207
+ printl(names[0]); // "Alice" (index access)
208
+ printl(len(names)); // 3
209
+
210
+ string last = names.pop();
211
+ printl(last); // "Charlie"
212
+ ```
213
+
214
+ **Methods:**
215
+
216
+ | Method | Description |
217
+ |--------|-------------|
218
+ | `.push(value)` | Add element |
219
+ | `.pop()` | Remove and return last element |
220
+ | `[index]` | Get element at index |
221
+ | `len(stack)` | Number of elements |
222
+
223
+ ---
224
+
225
+ ### vector\<T\>
226
+
227
+ Dynamic array.
228
+
229
+ ```cssl
230
+ vector<int> numbers;
231
+ numbers.push(10);
232
+ numbers.push(20);
233
+ numbers.push(30);
234
+
235
+ printl(numbers); // [10, 20, 30]
236
+ printl(numbers[1]); // 20
237
+ ```
238
+
239
+ **Methods:**
240
+
241
+ | Method | Description |
242
+ |--------|-------------|
243
+ | `.push(value)` | Add element |
244
+ | `.pop()` | Remove last element |
245
+ | `[index]` | Element at index |
246
+
247
+ ---
248
+
249
+ ### array\<T\>
250
+
251
+ Static array.
252
+
253
+ ```cssl
254
+ array<string> items;
255
+ items.push("A");
256
+ items.push("B");
257
+ printl(items);
258
+ ```
259
+
260
+ ---
261
+
262
+ ### datastruct\<T\>
263
+
264
+ Universal container for BruteInjection operations.
265
+
266
+ ```cssl
267
+ datastruct<string> data;
268
+ data +<== someStack; // Copy data into it
269
+ ```
270
+
271
+ ---
272
+
273
+ ### dataspace\<T\>
274
+
275
+ Extended data space for complex operations.
276
+
277
+ ```cssl
278
+ dataspace<dynamic> storage;
279
+ ```
280
+
281
+ ---
282
+
283
+ ### combo\<T\>
284
+
285
+ Combo space for filtered searches.
286
+
287
+ ```cssl
288
+ combo<string> searchSpace;
289
+ combo<open&string> filter = combo<open&string>::like="Hannes";
290
+ ```
291
+
292
+ ---
293
+
294
+ ### iterator\<T\>
295
+
296
+ For iterations over data structures.
297
+
298
+ ```cssl
299
+ iterator<int> it;
300
+
301
+ // 2D iterator with 16 fields
302
+ iterator<iterator<int, 16>> Map;
303
+ Map.insert(3, 12);
304
+ Map.fill(0);
305
+ int value = Map.at(3);
306
+ ```
307
+
308
+ ---
309
+
310
+ ### shuffled\<T\>
311
+
312
+ Container for multiple return values.
313
+
314
+ ```cssl
315
+ shuffled<string> results;
316
+
317
+ shuffled string getMultiple() {
318
+ return "first", "second", "third";
319
+ }
320
+ ```
321
+
322
+ ---
323
+
324
+ ## Variables & Globals
325
+
326
+ ### Local Variables
327
+
328
+ ```cssl
329
+ string local = "only visible here";
330
+ int number = 42;
331
+ ```
332
+
333
+ ### Global Variables
334
+
335
+ ```cssl
336
+ // Declaration with 'global'
337
+ global myGlobal = "visible everywhere";
338
+
339
+ // Access with '@'
340
+ printl(@myGlobal);
341
+
342
+ // Alternative: r@ syntax
343
+ r@anotherGlobal = "also global";
344
+ printl(@anotherGlobal);
345
+ ```
346
+
347
+ ### Usage in Functions
348
+
349
+ ```cssl
350
+ global counter = 0;
351
+
352
+ void increment() {
353
+ @counter = @counter + 1;
354
+ printl(@counter);
355
+ }
356
+
357
+ increment(); // 1
358
+ increment(); // 2
359
+ increment(); // 3
360
+ ```
361
+
362
+ ---
363
+
364
+ ## Control Structures
365
+
366
+ ### If / Else If / Else
367
+
368
+ ```cssl
369
+ int x = 10;
370
+
371
+ if (x < 5) {
372
+ printl("Small");
373
+ } else if (x < 15) {
374
+ printl("Medium");
375
+ } else {
376
+ printl("Large");
377
+ }
378
+
379
+ // With logical operators
380
+ if (x > 0 && x < 100) {
381
+ printl("In range");
382
+ }
383
+
384
+ // Negation
385
+ if (!active) {
386
+ printl("Not active");
387
+ }
388
+
389
+ // Alternative negation
390
+ if (not active) {
391
+ printl("Not active");
392
+ }
393
+ ```
394
+
395
+ ---
396
+
397
+ ### Switch / Case
398
+
399
+ ```cssl
400
+ int day = 3;
401
+
402
+ switch (day) {
403
+ case 1:
404
+ printl("Monday");
405
+ break;
406
+ case 2:
407
+ printl("Tuesday");
408
+ break;
409
+ case 3:
410
+ printl("Wednesday");
411
+ break;
412
+ default:
413
+ printl("Other day");
414
+ }
415
+ ```
416
+
417
+ ---
418
+
419
+ ### While Loop
420
+
421
+ ```cssl
422
+ int i = 0;
423
+ while (i < 5) {
424
+ printl(i);
425
+ i = i + 1;
426
+ }
427
+ ```
428
+
429
+ ---
430
+
431
+ ### For Loop (Python-Style)
432
+
433
+ ```cssl
434
+ // Range-based
435
+ for (i in range(0, 5)) {
436
+ printl(i); // 0, 1, 2, 3, 4
437
+ }
438
+
439
+ // With start and end
440
+ for (x in range(10, 15)) {
441
+ printl(x); // 10, 11, 12, 13, 14
442
+ }
443
+
444
+ // With step
445
+ for (i in range(0, 10, 2)) {
446
+ printl(i); // 0, 2, 4, 6, 8
447
+ }
448
+ ```
449
+
450
+ ---
451
+
452
+ ### For Loop (C-Style)
453
+
454
+ ```cssl
455
+ // Classic C-style syntax
456
+ for (int i = 0; i < 10; i++) {
457
+ printl(i);
458
+ }
459
+
460
+ // With decrement
461
+ for (int i = 10; i > 0; i--) {
462
+ printl(i);
463
+ }
464
+
465
+ // With +=
466
+ for (int i = 0; i < 100; i += 10) {
467
+ printl(i); // 0, 10, 20, ...
468
+ }
469
+ ```
470
+
471
+ ---
472
+
473
+ ### Foreach
474
+
475
+ ```cssl
476
+ stack<string> names;
477
+ names.push("Alice");
478
+ names.push("Bob");
479
+ names.push("Charlie");
480
+
481
+ // Syntax 1: foreach (item in collection)
482
+ foreach (name in names) {
483
+ printl(name);
484
+ }
485
+
486
+ // Syntax 2: foreach collection as item
487
+ foreach names as name {
488
+ printl(name);
489
+ }
490
+ ```
491
+
492
+ ---
493
+
494
+ ### Break & Continue
495
+
496
+ ```cssl
497
+ // Break - exit loop early
498
+ for (i in range(0, 10)) {
499
+ if (i == 5) {
500
+ break; // Stops at 5
501
+ }
502
+ printl(i);
503
+ }
504
+
505
+ // Continue - skip iteration
506
+ for (i in range(0, 10)) {
507
+ if (i == 3) {
508
+ continue; // Skips 3
509
+ }
510
+ printl(i);
511
+ }
512
+ ```
513
+
514
+ ---
515
+
516
+ ## Functions
517
+
518
+ ### Basic Syntax
519
+
520
+ ```cssl
521
+ // Without return
522
+ void sayHello() {
523
+ printl("Hello!");
524
+ }
525
+
526
+ // With return
527
+ string getName() {
528
+ return "CSSL";
529
+ }
530
+
531
+ // With parameters
532
+ int add(int a, int b) {
533
+ return a + b;
534
+ }
535
+
536
+ // Call
537
+ sayHello();
538
+ string n = getName();
539
+ int sum = add(5, 3);
540
+ ```
541
+
542
+ ### Nested Functions
543
+
544
+ ```cssl
545
+ void inner() {
546
+ printl("Inner function");
547
+ }
548
+
549
+ void outer() {
550
+ printl("Outer function");
551
+ inner();
552
+ }
553
+
554
+ outer();
555
+ ```
556
+
557
+ ---
558
+
559
+ ## Function Keywords
560
+
561
+ ### undefined
562
+
563
+ Function silently ignores errors.
564
+
565
+ ```cssl
566
+ undefined void mayFail() {
567
+ riskyOperation(); // Errors are ignored
568
+ }
569
+ mayFail(); // No crash
570
+ ```
571
+
572
+ ---
573
+
574
+ ### dynamic
575
+
576
+ No type declaration needed.
577
+
578
+ ```cssl
579
+ dynamic x = "string";
580
+ x = 123; // now int
581
+ x = 3.14; // now float
582
+ ```
583
+
584
+ ---
585
+
586
+ ### define
587
+
588
+ Constant function without type and return.
589
+
590
+ ```cssl
591
+ define LOG_MESSAGE() {
592
+ printl("Log message");
593
+ }
594
+ LOG_MESSAGE();
595
+ ```
596
+
597
+ ---
598
+
599
+ ### closed
600
+
601
+ Protects from external code injection.
602
+
603
+ ```cssl
604
+ closed void protectedFunc() {
605
+ printl("Protected from external injections");
606
+ }
607
+ // This injection will be BLOCKED:
608
+ protectedFunc() <<== { printl("Blocked!"); }
609
+ ```
610
+
611
+ ---
612
+
613
+ ### private
614
+
615
+ Blocks ALL injections.
616
+
617
+ ```cssl
618
+ private void superSecure() {
619
+ printl("Absolutely protected");
620
+ }
621
+ ```
622
+
623
+ ---
624
+
625
+ ### virtual
626
+
627
+ Allows import cycles.
628
+
629
+ ```cssl
630
+ virtual void safeForImport() {
631
+ printl("Import-cycle-safe");
632
+ }
633
+ ```
634
+
635
+ ---
636
+
637
+ ### meta
638
+
639
+ Declares function as source (must return).
640
+
641
+ ```cssl
642
+ meta string getSource() {
643
+ return "Meta source";
644
+ }
645
+ ```
646
+
647
+ ---
648
+
649
+ ### super
650
+
651
+ Forces execution without exceptions.
652
+
653
+ ```cssl
654
+ super void forceRun() {
655
+ printl("Will ALWAYS execute");
656
+ }
657
+ ```
658
+
659
+ ---
660
+
661
+ ### shuffled
662
+
663
+ Allows multiple return values.
664
+
665
+ ```cssl
666
+ shuffled string getNames() {
667
+ return "Alice", "Bob", "Charlie";
668
+ }
669
+ ```
670
+
671
+ ---
672
+
673
+ ### open
674
+
675
+ Accepts any parameters.
676
+
677
+ ```cssl
678
+ open define flexibleFunc(open Params) {
679
+ string name = OpenFind<string>(0);
680
+ int num = OpenFind<int>(0);
681
+ printl(name);
682
+ printl(num);
683
+ }
684
+
685
+ flexibleFunc("Hello", 123, true, "World");
686
+ ```
687
+
688
+ ---
689
+
690
+ ## String Methods
691
+
692
+ CSSL offers 40+ string methods:
693
+
694
+ ### Search & Check
695
+
696
+ ```cssl
697
+ string s = "Hello World";
698
+
699
+ // Contains
700
+ bool has = s.contains("World"); // true
701
+
702
+ // Find position
703
+ int pos = s.indexOf("o"); // 4
704
+ int last = s.lastIndexOf("o"); // 7
705
+
706
+ // Start/end check
707
+ bool start = s.startsWith("Hello"); // true
708
+ bool end = s.endsWith("World"); // true
709
+ ```
710
+
711
+ ### Manipulation
712
+
713
+ ```cssl
714
+ string s = "Hello World";
715
+
716
+ // Replace
717
+ string r1 = s.replace("World", "CSSL"); // "Hello CSSL"
718
+ string r2 = s.replaceAll("l", "L"); // "HeLLo WorLd"
719
+
720
+ // Case
721
+ string upper = s.toUpperCase(); // "HELLO WORLD"
722
+ string lower = s.toLowerCase(); // "hello world"
723
+
724
+ // Trim
725
+ string padded = " text ";
726
+ string trimmed = padded.trim(); // "text"
727
+
728
+ // Repeat
729
+ string rep = "ab".repeat(3); // "ababab"
730
+
731
+ // Reverse
732
+ string rev = s.reverse(); // "dlroW olleH"
733
+ ```
734
+
735
+ ### Split & Join
736
+
737
+ ```cssl
738
+ string csv = "a,b,c,d";
739
+
740
+ // Split
741
+ stack<string> parts = csv.split(","); // ["a", "b", "c", "d"]
742
+
743
+ // Join
744
+ string joined = parts.join("-"); // "a-b-c-d"
745
+ ```
746
+
747
+ ### Extract
748
+
749
+ ```cssl
750
+ string s = "Hello World";
751
+
752
+ // Substring
753
+ string sub = s.substring(0, 5); // "Hello"
754
+ string slc = s.slice(6, 11); // "World"
755
+
756
+ // Character
757
+ string ch = s.charAt(0); // "H"
758
+ int code = s.charCodeAt(0); // 72
759
+ ```
760
+
761
+ ### Padding
762
+
763
+ ```cssl
764
+ string num = "42";
765
+
766
+ string padded1 = num.padStart(5, "0"); // "00042"
767
+ string padded2 = num.padEnd(5, "."); // "42..."
768
+ ```
769
+
770
+ ### All String Methods
771
+
772
+ | Method | Description |
773
+ |--------|-------------|
774
+ | `.contains(str)` | Check if string contains |
775
+ | `.indexOf(str)` | First position of str |
776
+ | `.lastIndexOf(str)` | Last position of str |
777
+ | `.startsWith(str)` | Starts with str? |
778
+ | `.endsWith(str)` | Ends with str? |
779
+ | `.find(str)` | Find position (-1 if not found) |
780
+ | `.split(delimiter)` | Split into array |
781
+ | `.join(delimiter)` | Join array to string |
782
+ | `.replace(old, new)` | Replace first occurrence |
783
+ | `.replaceAll(old, new)` | Replace all occurrences |
784
+ | `.substring(start, end)` | Extract substring |
785
+ | `.slice(start, end)` | Substring (like substring) |
786
+ | `.substr(start, length)` | Substring with length |
787
+ | `.toLowerCase()` | To lowercase |
788
+ | `.toUpperCase()` | To uppercase |
789
+ | `.trim()` | Remove whitespace |
790
+ | `.charAt(index)` | Character at position |
791
+ | `.charCodeAt(index)` | ASCII code at position |
792
+ | `.padStart(len, char)` | Pad left |
793
+ | `.padEnd(len, char)` | Pad right |
794
+ | `.repeat(n)` | Repeat n times |
795
+ | `.reverse()` | Reverse |
796
+ | `.count(str)` | Count occurrences |
797
+ | `len(string)` | String length |
798
+
799
+ ---
800
+
801
+ ## Live Object Sharing
802
+
803
+ Share Python objects with CSSL. Changes in CSSL reflect back to Python.
804
+
805
+ ### Python Side
806
+
807
+ ```python
808
+ from includecpp import CSSL
809
+
810
+ class Counter:
811
+ def __init__(self):
812
+ self.value = 100
813
+
814
+ counter = Counter()
815
+ cssl = CSSL.CsslLang()
816
+ cssl.share(counter, "cnt")
817
+
818
+ # Changes in CSSL will reflect in Python!
819
+ cssl.exec('''
820
+ $cnt.value = $cnt.value - 10;
821
+ printl($cnt.value); // 90
822
+ ''')
823
+
824
+ print(counter.value) # 90 - Changed!
825
+ ```
826
+
827
+ ### CSSL Syntax
828
+
829
+ | Syntax | Description |
830
+ |--------|-------------|
831
+ | `$name` | Access shared object |
832
+ | `$name.property` | Access/modify properties |
833
+ | `$name.method()` | Call methods |
834
+ | `delete("name")` | Remove shared object |
835
+
836
+ ### Loop Modifications
837
+
838
+ ```python
839
+ # Python
840
+ class Stats:
841
+ def __init__(self):
842
+ self.total = 100
843
+
844
+ stats = Stats()
845
+ cssl = CSSL.CsslLang()
846
+ cssl.share(stats, "s")
847
+
848
+ cssl.exec('''
849
+ for (i in range(0, 5)) {
850
+ $s.total = $s.total - 10;
851
+ }
852
+ printl($s.total); // 50
853
+ ''')
854
+
855
+ print(stats.total) # 50 - Persisted!
856
+ ```
857
+
858
+ ---
859
+
860
+ ## CodeInfusion
861
+
862
+ CodeInfusion enables modifying functions at runtime.
863
+
864
+ ### <<== (Replace)
865
+
866
+ Replaces function content.
867
+
868
+ ```cssl
869
+ void original() {
870
+ printl("Original");
871
+ }
872
+
873
+ original() <<== {
874
+ printl("Replaced");
875
+ }
876
+
877
+ original(); // "Replaced"
878
+ ```
879
+
880
+ ---
881
+
882
+ ### +<<== (Add)
883
+
884
+ Adds code to function (executes BEFORE original).
885
+
886
+ ```cssl
887
+ void base() {
888
+ printl("Base");
889
+ }
890
+
891
+ base() +<<== {
892
+ printl("Added");
893
+ }
894
+
895
+ base();
896
+ // Output:
897
+ // Added
898
+ // Base
899
+ ```
900
+
901
+ ---
902
+
903
+ ### -<<== (Remove)
904
+
905
+ Removes code from function.
906
+
907
+ ```cssl
908
+ void withExtra() {
909
+ printl("Important");
910
+ printl("Unimportant");
911
+ }
912
+
913
+ withExtra() -<<== {
914
+ printl("Unimportant");
915
+ }
916
+
917
+ withExtra(); // Only "Important"
918
+ ```
919
+
920
+ ---
921
+
922
+ ### exit() Injection
923
+
924
+ Special injection for program end.
925
+
926
+ ```cssl
927
+ exit() <<== {
928
+ printl("Cleanup before exit...");
929
+ }
930
+
931
+ // Later:
932
+ exit(); // Executes injection
933
+ ```
934
+
935
+ ---
936
+
937
+ ## BruteInjection
938
+
939
+ BruteInjection copies/moves data between containers.
940
+
941
+ ### +<== (Copy)
942
+
943
+ Copies data to target (source unchanged).
944
+
945
+ ```cssl
946
+ stack<string> source;
947
+ source.push("A");
948
+ source.push("B");
949
+
950
+ datastruct<string> target;
951
+ target +<== source; // Copies A, B
952
+ ```
953
+
954
+ ---
955
+
956
+ ### -<== (Move)
957
+
958
+ Moves data (removes from source).
959
+
960
+ ```cssl
961
+ stack<string> src;
962
+ src.push("Data");
963
+
964
+ datastruct<string> dst;
965
+ dst -<== src; // src is empty after
966
+ ```
967
+
968
+ ---
969
+
970
+ ### ==> (Replace)
971
+
972
+ Replaces target data completely.
973
+
974
+ ```cssl
975
+ stack<string> data;
976
+ data.push("New");
977
+
978
+ datastruct<string> container;
979
+ container ==> data;
980
+ ```
981
+
982
+ ---
983
+
984
+ ## Filter Syntax
985
+
986
+ Filters enable targeted data operations in BruteInjection.
987
+
988
+ ### Syntax
989
+
990
+ ```cssl
991
+ target +<== [type::filter=value] source;
992
+ ```
993
+
994
+ ### String Filters
995
+
996
+ ```cssl
997
+ stack<string> fruits;
998
+ fruits.push("Apple");
999
+ fruits.push("Banana");
1000
+ fruits.push("Apricot");
1001
+
1002
+ datastruct<string> result;
1003
+
1004
+ // Exact match
1005
+ result +<== [string::where="Apple"] fruits;
1006
+
1007
+ // Everything except
1008
+ result +<== [string::not="Banana"] fruits;
1009
+
1010
+ // Contains substring
1011
+ result +<== [string::contains="App"] fruits; // Apple, Apricot
1012
+
1013
+ // String length
1014
+ result +<== [string::length=5] fruits; // Apple
1015
+ ```
1016
+
1017
+ ### All Filters
1018
+
1019
+ | Filter | Description |
1020
+ |--------|-------------|
1021
+ | `string::where=VALUE` | Exact string match |
1022
+ | `string::not=VALUE` | Everything except this value |
1023
+ | `string::contains=VALUE` | Contains substring |
1024
+ | `string::length=LENGTH` | Exact string length |
1025
+ | `integer::where=VALUE` | Exact int match |
1026
+ | `json::key=KEYNAME` | Filter by JSON key |
1027
+ | `json::value=VALUE` | Filter by JSON value |
1028
+ | `array::index=INDEX` | By array index |
1029
+ | `vector::where=VALUE` | Exact vector match |
1030
+ | `combo::filterdb` | Combo FilterDB |
1031
+
1032
+ ---
1033
+
1034
+ ## Module System
1035
+
1036
+ ### Create Module
1037
+
1038
+ Create CSSL module from Python file:
1039
+
1040
+ ```bash
1041
+ python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
1042
+ ```
1043
+
1044
+ ### Import Module
1045
+
1046
+ ```cssl
1047
+ // Import Python module
1048
+ @Math = include("mymath.cssl-mod");
1049
+
1050
+ // Import CSSL file
1051
+ @Utils = include("utils.cssl");
1052
+
1053
+ // Call module functions
1054
+ int result = @Math.add(5, 3);
1055
+ string text = @Utils.format("Hello");
1056
+ ```
1057
+
1058
+ ### Example: Python Module
1059
+
1060
+ **mathlib.py:**
1061
+ ```python
1062
+ def add(a, b):
1063
+ return a + b
1064
+
1065
+ def multiply(a, b):
1066
+ return a * b
1067
+
1068
+ def square(x):
1069
+ return x * x
1070
+ ```
1071
+
1072
+ **Create module:**
1073
+ ```bash
1074
+ python -m includecpp cssl makemodule mathlib.py -o mathlib.cssl-mod
1075
+ ```
1076
+
1077
+ **Use in CSSL:**
1078
+ ```cssl
1079
+ @Math = include("mathlib.cssl-mod");
1080
+
1081
+ int sum = @Math.add(10, 20); // 30
1082
+ int product = @Math.multiply(5, 6); // 30
1083
+ int sq = @Math.square(8); // 64
1084
+
1085
+ printl(sum);
1086
+ printl(product);
1087
+ printl(sq);
1088
+ ```
1089
+
1090
+ ---
1091
+
1092
+ ## Parameter Bridge
1093
+
1094
+ Communication between Python and CSSL.
1095
+
1096
+ ### parameter.get()
1097
+
1098
+ Receive parameters from Python:
1099
+
1100
+ ```cssl
1101
+ // In CSSL
1102
+ string name = parameter.get(0); // First parameter
1103
+ int count = parameter.get(1); // Second parameter
1104
+ printl(name);
1105
+ printl(count);
1106
+ ```
1107
+
1108
+ ```python
1109
+ # In Python
1110
+ CSSL.exec(code, "Alice", 42)
1111
+ ```
1112
+
1113
+ ### parameter.return()
1114
+
1115
+ Return value to Python:
1116
+
1117
+ ```cssl
1118
+ // In CSSL
1119
+ int result = 10 + 20;
1120
+ parameter.return(result);
1121
+ ```
1122
+
1123
+ ```python
1124
+ # In Python
1125
+ result = CSSL.exec(code)
1126
+ print(result) # 30
1127
+ ```
1128
+
1129
+ ### Complete Example
1130
+
1131
+ ```python
1132
+ from includecpp import CSSL
1133
+
1134
+ CSSL.CsslLang()
1135
+
1136
+ code = """
1137
+ int a = parameter.get(0);
1138
+ int b = parameter.get(1);
1139
+ int sum = a + b;
1140
+ parameter.return(sum);
1141
+ """
1142
+
1143
+ result = CSSL.exec(code, 15, 27)
1144
+ print(f"Result: {result}") # Result: 42
1145
+ ```
1146
+
1147
+ ### Supported Return Types
1148
+
1149
+ ```cssl
1150
+ parameter.return(true); // bool
1151
+ parameter.return(42); // int
1152
+ parameter.return(3.14); // float
1153
+ parameter.return("Hello"); // string
1154
+ parameter.return(myStack); // stack/array
1155
+ parameter.return(myObject); // JSON/dict
1156
+ ```
1157
+
1158
+ ---
1159
+
1160
+ ## Structures
1161
+
1162
+ Structures are user-defined data types.
1163
+
1164
+ ```cssl
1165
+ structure Person {
1166
+ string name;
1167
+ int age;
1168
+ string email;
1169
+ }
1170
+
1171
+ // Create instance
1172
+ Person user;
1173
+ user.name = "Max";
1174
+ user.age = 25;
1175
+ user.email = "max@example.com";
1176
+
1177
+ printl(user.name); // "Max"
1178
+ printl(user.age); // 25
1179
+ ```
1180
+
1181
+ ### With Functions
1182
+
1183
+ ```cssl
1184
+ structure Rectangle {
1185
+ int width;
1186
+ int height;
1187
+ }
1188
+
1189
+ int calculateArea(Rectangle rect) {
1190
+ return rect.width * rect.height;
1191
+ }
1192
+
1193
+ Rectangle r;
1194
+ r.width = 10;
1195
+ r.height = 5;
1196
+ int area = calculateArea(r);
1197
+ printl(area); // 50
1198
+ ```
1199
+
1200
+ ---
1201
+
1202
+ ## Error Handling
1203
+
1204
+ ### Try / Catch
1205
+
1206
+ ```cssl
1207
+ try {
1208
+ // Risky code
1209
+ int result = riskyOperation();
1210
+ printl(result);
1211
+ } catch {
1212
+ printl("An error occurred");
1213
+ }
1214
+ ```
1215
+
1216
+ ### With undefined
1217
+
1218
+ ```cssl
1219
+ undefined void safeOperation() {
1220
+ // Errors are silently ignored
1221
+ dangerousCode();
1222
+ }
1223
+
1224
+ safeOperation(); // No crash
1225
+ ```
1226
+
1227
+ ---
1228
+
1229
+ ## CLI Commands
1230
+
1231
+ ### Execute
1232
+
1233
+ ```bash
1234
+ # Execute CSSL file
1235
+ python -m includecpp cssl exec script.cssl
1236
+
1237
+ # Execute CSSL code directly
1238
+ python -m includecpp cssl exec -c "printl('Hello');"
1239
+ ```
1240
+
1241
+ ### Create Module
1242
+
1243
+ ```bash
1244
+ # From Python file
1245
+ python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
1246
+
1247
+ # With output path
1248
+ python -m includecpp cssl makemodule src/utils.py -o modules/utils.cssl-mod
1249
+ ```
1250
+
1251
+ ### Help
1252
+
1253
+ ```bash
1254
+ python -m includecpp cssl --help
1255
+ python -m includecpp cssl exec --help
1256
+ python -m includecpp cssl makemodule --help
1257
+ ```
1258
+
1259
+ ---
1260
+
1261
+ ## Examples
1262
+
1263
+ ### Tkinter GUI Calendar
1264
+
1265
+ ```cssl
1266
+ // Import modules
1267
+ @Gui = include("modules/tkgui.cssl-mod");
1268
+
1269
+ // Global state
1270
+ global currentMonth = 0;
1271
+ global currentYear = 0;
1272
+
1273
+ // Initialize
1274
+ void init() {
1275
+ @currentYear = @Gui.get_current_year();
1276
+ @currentMonth = @Gui.get_current_month();
1277
+ }
1278
+
1279
+ // Build calendar
1280
+ void buildCalendar() {
1281
+ stack<string> days;
1282
+ days.push("Mo");
1283
+ days.push("Tu");
1284
+ days.push("We");
1285
+ days.push("Th");
1286
+ days.push("Fr");
1287
+ days.push("Sa");
1288
+ days.push("Su");
1289
+
1290
+ // Header with for-loop
1291
+ for (i in range(0, 7)) {
1292
+ @Gui.add_label(days[i], i * 40, 50);
1293
+ }
1294
+
1295
+ // Days with C-style for
1296
+ int daysInMonth = @Gui.get_days_in_month(@currentYear, @currentMonth);
1297
+ for (int d = 1; d <= daysInMonth; d++) {
1298
+ @Gui.add_button("" + d, d);
1299
+ }
1300
+ }
1301
+
1302
+ // Main
1303
+ init();
1304
+ @Gui.create_window("CSSL Calendar", 350, 400);
1305
+ buildCalendar();
1306
+ @Gui.run();
1307
+ ```
1308
+
1309
+ ---
1310
+
1311
+ ### Task Manager with CodeInfusion
1312
+
1313
+ ```cssl
1314
+ global tasks = stack<string>;
1315
+
1316
+ void addTask(string task) {
1317
+ @tasks.push(task);
1318
+ printl("+ " + task);
1319
+ }
1320
+
1321
+ void showTasks() {
1322
+ printl("=== Tasks ===");
1323
+ foreach (task in @tasks) {
1324
+ printl("- " + task);
1325
+ }
1326
+ }
1327
+
1328
+ void completeTask() {
1329
+ string done = @tasks.pop();
1330
+ printl("Completed: " + done);
1331
+ }
1332
+
1333
+ // Add logging via CodeInfusion
1334
+ addTask() +<<== {
1335
+ printl("[LOG] Adding task...");
1336
+ }
1337
+
1338
+ // Exit handler
1339
+ exit() <<== {
1340
+ printl("Shutting down Task Manager...");
1341
+ }
1342
+
1343
+ // Application
1344
+ addTask("Write code");
1345
+ addTask("Run tests");
1346
+ addTask("Update documentation");
1347
+ showTasks();
1348
+ completeTask();
1349
+ exit();
1350
+ ```
1351
+
1352
+ ---
1353
+
1354
+ ### Data Pipeline with BruteInjection
1355
+
1356
+ ```cssl
1357
+ // Source data
1358
+ stack<string> rawData;
1359
+ rawData.push("Alice");
1360
+ rawData.push("Bob");
1361
+ rawData.push("Charlie");
1362
+ rawData.push("Alex");
1363
+ rawData.push("Anna");
1364
+
1365
+ // Filter: Only names containing "A"
1366
+ datastruct<string> aNames;
1367
+ aNames +<== [string::contains="A"] rawData;
1368
+
1369
+ // Output
1370
+ printl("Names with A:");
1371
+ foreach (name in aNames) {
1372
+ printl(" - " + name);
1373
+ }
1374
+ // Output: Alice, Alex, Anna
1375
+ ```
1376
+
1377
+ ---
1378
+
1379
+ ### Python-CSSL Bridge
1380
+
1381
+ ```python
1382
+ from includecpp import CSSL
1383
+
1384
+ CSSL.CsslLang()
1385
+
1386
+ # Syntax checker in CSSL
1387
+ checker = """
1388
+ global errors = stack<string>;
1389
+
1390
+ void checkLine(string line) {
1391
+ if (line.startsWith("def ") && !line.endsWith(":")) {
1392
+ @errors.push("Missing colon after def");
1393
+ }
1394
+ if (line.startsWith("if ") && !line.endsWith(":")) {
1395
+ @errors.push("Missing colon after if");
1396
+ }
1397
+ }
1398
+
1399
+ define analyze() {
1400
+ string code = parameter.get(0);
1401
+ stack<string> lines = code.split("\\n");
1402
+
1403
+ foreach (line in lines) {
1404
+ checkLine(line);
1405
+ }
1406
+
1407
+ if (len(@errors) == 0) {
1408
+ parameter.return("OK");
1409
+ } else {
1410
+ parameter.return(@errors);
1411
+ }
1412
+ }
1413
+
1414
+ analyze();
1415
+ """
1416
+
1417
+ # Check Python code
1418
+ test_code = """def hello()
1419
+ print("world")"""
1420
+
1421
+ result = CSSL.exec(checker, test_code)
1422
+ print(result) # ["Missing colon after def"]
1423
+ ```
1424
+
1425
+ ---
1426
+
1427
+ ## Reference Table
1428
+
1429
+ ### Keywords
1430
+
1431
+ | Keyword | Description |
1432
+ |---------|-------------|
1433
+ | `void` | Function without return |
1434
+ | `return` | Return value |
1435
+ | `global` | Declare global variable |
1436
+ | `r@` | Alternative global syntax |
1437
+ | `@` | Access global variable |
1438
+ | `if` / `else if` / `else` | Conditions |
1439
+ | `switch` / `case` / `default` | Switch statement |
1440
+ | `for` / `foreach` / `while` | Loops |
1441
+ | `break` / `continue` | Loop control |
1442
+ | `try` / `catch` | Error handling |
1443
+ | `undefined` | Ignore errors |
1444
+ | `dynamic` | Dynamic type |
1445
+ | `define` | Constant function |
1446
+ | `closed` | Block external injection |
1447
+ | `private` | Block all injections |
1448
+ | `virtual` | Import-cycle-safe |
1449
+ | `meta` | Source function |
1450
+ | `super` | Forced execution |
1451
+ | `shuffled` | Multiple returns |
1452
+ | `open` | Any parameters |
1453
+ | `structure` | User-defined type |
1454
+ | `include` | Import module |
1455
+
1456
+ ### Injection Operators
1457
+
1458
+ | Operator | Type | Description |
1459
+ |----------|------|-------------|
1460
+ | `<<==` | CodeInfusion | Replace |
1461
+ | `+<<==` | CodeInfusion | Add |
1462
+ | `-<<==` | CodeInfusion | Remove |
1463
+ | `+<==` | BruteInjection | Copy |
1464
+ | `-<==` | BruteInjection | Move |
1465
+ | `==>` | BruteInjection | Replace |
1466
+
1467
+ ---
1468
+
1469
+ ## Tips & Best Practices
1470
+
1471
+ 1. **Type Safety**: Use explicit types instead of `dynamic` for better performance
1472
+ 2. **Global Variables**: Use sparingly, always access with `@`
1473
+ 3. **For Loops**: Python-style for simple iterations, C-style when `++`/`--` needed
1474
+ 4. **CodeInfusion**: Protect with `closed`/`private` when necessary
1475
+ 5. **Modules**: Python modules for complex logic, CSSL for business logic
1476
+ 6. **Error Handling**: `try/catch` for external calls, `undefined` for optional operations
1477
+ 7. **String Operations**: Use built-in methods instead of manual manipulation
1478
+ 8. **Live Objects**: Use `$name` syntax for bidirectional Python-CSSL data sharing
1479
+
1480
+ ---
1481
+
1482
+ *CSSL v3.4.20 - Developed as part of IncludeCPP*