IncludeCPP 3.7.3__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.
Files changed (49) hide show
  1. includecpp/__init__.py +59 -0
  2. includecpp/__init__.pyi +255 -0
  3. includecpp/__main__.py +4 -0
  4. includecpp/cli/__init__.py +4 -0
  5. includecpp/cli/commands.py +8270 -0
  6. includecpp/cli/config_parser.py +127 -0
  7. includecpp/core/__init__.py +19 -0
  8. includecpp/core/ai_integration.py +2132 -0
  9. includecpp/core/build_manager.py +2416 -0
  10. includecpp/core/cpp_api.py +376 -0
  11. includecpp/core/cpp_api.pyi +95 -0
  12. includecpp/core/cppy_converter.py +3448 -0
  13. includecpp/core/cssl/CSSL_DOCUMENTATION.md +2075 -0
  14. includecpp/core/cssl/__init__.py +42 -0
  15. includecpp/core/cssl/cssl_builtins.py +2271 -0
  16. includecpp/core/cssl/cssl_builtins.pyi +1393 -0
  17. includecpp/core/cssl/cssl_events.py +621 -0
  18. includecpp/core/cssl/cssl_modules.py +2803 -0
  19. includecpp/core/cssl/cssl_parser.py +2575 -0
  20. includecpp/core/cssl/cssl_runtime.py +3051 -0
  21. includecpp/core/cssl/cssl_syntax.py +488 -0
  22. includecpp/core/cssl/cssl_types.py +1512 -0
  23. includecpp/core/cssl_bridge.py +882 -0
  24. includecpp/core/cssl_bridge.pyi +488 -0
  25. includecpp/core/error_catalog.py +802 -0
  26. includecpp/core/error_formatter.py +1016 -0
  27. includecpp/core/exceptions.py +97 -0
  28. includecpp/core/path_discovery.py +77 -0
  29. includecpp/core/project_ui.py +3370 -0
  30. includecpp/core/settings_ui.py +326 -0
  31. includecpp/generator/__init__.py +1 -0
  32. includecpp/generator/parser.cpp +1903 -0
  33. includecpp/generator/parser.h +281 -0
  34. includecpp/generator/type_resolver.cpp +363 -0
  35. includecpp/generator/type_resolver.h +68 -0
  36. includecpp/py.typed +0 -0
  37. includecpp/templates/cpp.proj.template +18 -0
  38. includecpp/vscode/__init__.py +1 -0
  39. includecpp/vscode/cssl/__init__.py +1 -0
  40. includecpp/vscode/cssl/language-configuration.json +38 -0
  41. includecpp/vscode/cssl/package.json +50 -0
  42. includecpp/vscode/cssl/snippets/cssl.snippets.json +1080 -0
  43. includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +341 -0
  44. includecpp-3.7.3.dist-info/METADATA +1076 -0
  45. includecpp-3.7.3.dist-info/RECORD +49 -0
  46. includecpp-3.7.3.dist-info/WHEEL +5 -0
  47. includecpp-3.7.3.dist-info/entry_points.txt +2 -0
  48. includecpp-3.7.3.dist-info/licenses/LICENSE +21 -0
  49. includecpp-3.7.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,2075 @@
1
+ # CSSL - C-Style Scripting Language
2
+
3
+ > Version 3.7.2 | 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. [File I/O](#file-io)
19
+ 11. [JSON Functions](#json-functions)
20
+ 12. [Instance Management](#instance-management)
21
+ 13. [Live Object Sharing](#live-object-sharing)
22
+ 14. [CodeInfusion](#codeinfusion)
23
+ 15. [Value Capture](#value-capture)
24
+ 16. [BruteInjection](#bruteinjection)
25
+ 17. [Filter Syntax](#filter-syntax)
26
+ 18. [Module System](#module-system)
27
+ 19. [Parameter Bridge](#parameter-bridge)
28
+ 20. [Classes & OOP](#classes--oop)
29
+ 21. [Map Container](#map-container)
30
+ 22. [Structures](#structures)
31
+ 23. [Error Handling](#error-handling)
32
+ 24. [CLI Commands](#cli-commands)
33
+ 25. [Examples](#examples)
34
+
35
+ ---
36
+
37
+ ## Quick Start
38
+
39
+ ### Installation & Usage
40
+
41
+ ```python
42
+ from includecpp import CSSL
43
+
44
+ # Initialize CSSL
45
+ CSSL.CsslLang()
46
+
47
+ # Execute code
48
+ CSSL.exec("""
49
+ printl("Hello CSSL!");
50
+ """)
51
+
52
+ # With parameters and return value
53
+ result = CSSL.exec("""
54
+ string name = parameter.get(0);
55
+ printl("Hello " + name);
56
+ parameter.return(true);
57
+ """, "World")
58
+
59
+ print(result) # True
60
+ ```
61
+
62
+ ### CLI Execution
63
+
64
+ ```bash
65
+ # Execute CSSL file
66
+ python -m includecpp cssl exec myfile.cssl
67
+
68
+ # Create module
69
+ python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
70
+ ```
71
+
72
+ ### First Steps
73
+
74
+ ```cssl
75
+ // Declare variables
76
+ string name = "CSSL";
77
+ int version = 3;
78
+
79
+ // Output
80
+ printl("Welcome to " + name);
81
+ printl(version);
82
+
83
+ // Define function
84
+ void greet(string msg) {
85
+ printl(msg);
86
+ }
87
+ greet("Hello World!");
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Basics
93
+
94
+ ### Comments
95
+
96
+ ```cssl
97
+ // Single-line comment
98
+
99
+ /*
100
+ Multi-line
101
+ comment
102
+ */
103
+ ```
104
+
105
+ ### Output
106
+
107
+ ```cssl
108
+ printl("Text"); // With newline
109
+ printl(variable); // Print variable
110
+ printl("Value: " + var); // String concatenation
111
+ printl("Number: " + 42); // String + Int works!
112
+ ```
113
+
114
+ ### Operators
115
+
116
+ #### Arithmetic Operators
117
+
118
+ | Operator | Description | Example |
119
+ |----------|-------------|---------|
120
+ | `+` | Addition / String concatenation | `a + b` |
121
+ | `-` | Subtraction | `a - b` |
122
+ | `*` | Multiplication | `a * b` |
123
+ | `/` | Division | `a / b` |
124
+ | `%` | Modulo (remainder) | `a % b` |
125
+
126
+ #### Comparison Operators
127
+
128
+ | Operator | Description | Example |
129
+ |----------|-------------|---------|
130
+ | `==` | Equality | `a == b` |
131
+ | `!=` | Inequality | `a != b` |
132
+ | `<` | Less than | `a < b` |
133
+ | `>` | Greater than | `a > b` |
134
+ | `<=` | Less than or equal | `a <= b` |
135
+ | `>=` | Greater than or equal | `a >= b` |
136
+
137
+ #### Logical Operators
138
+
139
+ | Operator | Description | Example |
140
+ |----------|-------------|---------|
141
+ | `&&` | Logical AND | `a && b` |
142
+ | `\|\|` | Logical OR | `a \|\| b` |
143
+ | `!` | Logical NOT | `!condition` |
144
+ | `not` | Logical NOT (alternative) | `not condition` |
145
+
146
+ #### Increment/Decrement (only in C-style for-loops)
147
+
148
+ | Operator | Description | Example |
149
+ |----------|-------------|---------|
150
+ | `++` | Increment | `i++` |
151
+ | `--` | Decrement | `i--` |
152
+ | `+=` | Addition assignment | `i += 1` |
153
+ | `-=` | Subtraction assignment | `i -= 1` |
154
+
155
+ ---
156
+
157
+ ## Data Types
158
+
159
+ ### Primitive Types
160
+
161
+ | Type | Description | Example |
162
+ |------|-------------|---------|
163
+ | `string` | Text string | `string s = "Hello";` |
164
+ | `int` | Integer | `int i = 42;` |
165
+ | `float` | Floating point | `float f = 3.14;` |
166
+ | `bool` | Boolean | `bool b = true;` |
167
+ | `json` | JSON object | `json j;` |
168
+ | `dynamic` | Dynamic type | `dynamic x = "anything";` |
169
+
170
+ ### Examples
171
+
172
+ ```cssl
173
+ // String
174
+ string greeting = "Hello";
175
+ string name = "World";
176
+ string combined = greeting + " " + name;
177
+ printl(combined); // "Hello World"
178
+
179
+ // Integer
180
+ int count = 10;
181
+ int doubled = count * 2;
182
+ printl(doubled); // 20
183
+
184
+ // Float
185
+ float price = 19.99;
186
+ printl(price);
187
+
188
+ // Boolean
189
+ bool active = true;
190
+ bool disabled = false;
191
+
192
+ // Dynamic (flexible, but slower)
193
+ dynamic anything = "first string";
194
+ anything = 123; // now int
195
+ anything = 3.14; // now float
196
+ ```
197
+
198
+ ---
199
+
200
+ ## Container Types
201
+
202
+ ### stack\<T\>
203
+
204
+ LIFO data structure (Last In, First Out).
205
+
206
+ ```cssl
207
+ stack<string> names;
208
+ names.push("Alice");
209
+ names.push("Bob");
210
+ names.push("Charlie");
211
+
212
+ printl(names); // ['Alice', 'Bob', 'Charlie']
213
+ printl(names[0]); // "Alice" (index access)
214
+ printl(len(names)); // 3
215
+
216
+ string last = names.pop();
217
+ printl(last); // "Charlie"
218
+ ```
219
+
220
+ **Methods:**
221
+
222
+ | Method | Description |
223
+ |--------|-------------|
224
+ | `.push(value)` | Add element |
225
+ | `.pop()` | Remove and return last element |
226
+ | `[index]` | Get element at index |
227
+ | `len(stack)` | Number of elements |
228
+
229
+ ---
230
+
231
+ ### vector\<T\>
232
+
233
+ Dynamic array.
234
+
235
+ ```cssl
236
+ vector<int> numbers;
237
+ numbers.push(10);
238
+ numbers.push(20);
239
+ numbers.push(30);
240
+
241
+ printl(numbers); // [10, 20, 30]
242
+ printl(numbers[1]); // 20
243
+ ```
244
+
245
+ **Methods:**
246
+
247
+ | Method | Description |
248
+ |--------|-------------|
249
+ | `.push(value)` | Add element |
250
+ | `.pop()` | Remove last element |
251
+ | `[index]` | Element at index |
252
+
253
+ ---
254
+
255
+ ### array\<T\>
256
+
257
+ Static array.
258
+
259
+ ```cssl
260
+ array<string> items;
261
+ items.push("A");
262
+ items.push("B");
263
+ printl(items);
264
+ ```
265
+
266
+ ---
267
+
268
+ ### datastruct\<T\>
269
+
270
+ Universal container for BruteInjection operations.
271
+
272
+ ```cssl
273
+ datastruct<string> data;
274
+ data +<== someStack; // Copy data into it
275
+ ```
276
+
277
+ ---
278
+
279
+ ### dataspace\<T\>
280
+
281
+ Extended data space for complex operations.
282
+
283
+ ```cssl
284
+ dataspace<dynamic> storage;
285
+ ```
286
+
287
+ ---
288
+
289
+ ### combo\<T\>
290
+
291
+ Combo space for filtered searches.
292
+
293
+ ```cssl
294
+ combo<string> searchSpace;
295
+ combo<open&string> filter = combo<open&string>::like="Hannes";
296
+ ```
297
+
298
+ ---
299
+
300
+ ### iterator\<T\>
301
+
302
+ For iterations over data structures.
303
+
304
+ ```cssl
305
+ iterator<int> it;
306
+
307
+ // 2D iterator with 16 fields
308
+ iterator<iterator<int, 16>> Map;
309
+ Map.insert(3, 12);
310
+ Map.fill(0);
311
+ int value = Map.at(3);
312
+ ```
313
+
314
+ ---
315
+
316
+ ### shuffled\<T\>
317
+
318
+ Container for multiple return values.
319
+
320
+ ```cssl
321
+ shuffled<string> results;
322
+
323
+ shuffled string getMultiple() {
324
+ return "first", "second", "third";
325
+ }
326
+ ```
327
+
328
+ ---
329
+
330
+ ## Variables & Globals
331
+
332
+ ### Local Variables
333
+
334
+ ```cssl
335
+ string local = "only visible here";
336
+ int number = 42;
337
+ ```
338
+
339
+ ### Global Variables
340
+
341
+ ```cssl
342
+ // Declaration with 'global'
343
+ global myGlobal = "visible everywhere";
344
+
345
+ // Access with '@' prefix
346
+ printl(@myGlobal);
347
+
348
+ // Or access directly without '@' (since v3.5.9)
349
+ printl(myGlobal); // Works the same!
350
+
351
+ // Alternative: r@ syntax for declaration
352
+ r@anotherGlobal = "also global";
353
+ printl(@anotherGlobal);
354
+ printl(anotherGlobal); // Also works
355
+ ```
356
+
357
+ ### Lookup Order
358
+
359
+ When accessing a variable, CSSL checks in order:
360
+ 1. Local scope
361
+ 2. Global scope
362
+ 3. Promoted globals
363
+ 4. Built-in functions
364
+
365
+ ### Usage in Functions
366
+
367
+ ```cssl
368
+ global counter = 0;
369
+
370
+ void increment() {
371
+ @counter = @counter + 1;
372
+ printl(@counter);
373
+ }
374
+
375
+ increment(); // 1
376
+ increment(); // 2
377
+ increment(); // 3
378
+ ```
379
+
380
+ ---
381
+
382
+ ## Control Structures
383
+
384
+ ### If / Else If / Else
385
+
386
+ ```cssl
387
+ int x = 10;
388
+
389
+ if (x < 5) {
390
+ printl("Small");
391
+ } else if (x < 15) {
392
+ printl("Medium");
393
+ } else {
394
+ printl("Large");
395
+ }
396
+
397
+ // With logical operators
398
+ if (x > 0 && x < 100) {
399
+ printl("In range");
400
+ }
401
+
402
+ // Negation
403
+ if (!active) {
404
+ printl("Not active");
405
+ }
406
+
407
+ // Alternative negation
408
+ if (not active) {
409
+ printl("Not active");
410
+ }
411
+ ```
412
+
413
+ ---
414
+
415
+ ### Switch / Case
416
+
417
+ ```cssl
418
+ int day = 3;
419
+
420
+ switch (day) {
421
+ case 1:
422
+ printl("Monday");
423
+ break;
424
+ case 2:
425
+ printl("Tuesday");
426
+ break;
427
+ case 3:
428
+ printl("Wednesday");
429
+ break;
430
+ default:
431
+ printl("Other day");
432
+ }
433
+ ```
434
+
435
+ ---
436
+
437
+ ### While Loop
438
+
439
+ ```cssl
440
+ int i = 0;
441
+ while (i < 5) {
442
+ printl(i);
443
+ i = i + 1;
444
+ }
445
+ ```
446
+
447
+ ---
448
+
449
+ ### For Loop (Python-Style)
450
+
451
+ ```cssl
452
+ // Range-based
453
+ for (i in range(0, 5)) {
454
+ printl(i); // 0, 1, 2, 3, 4
455
+ }
456
+
457
+ // With start and end
458
+ for (x in range(10, 15)) {
459
+ printl(x); // 10, 11, 12, 13, 14
460
+ }
461
+
462
+ // With step
463
+ for (i in range(0, 10, 2)) {
464
+ printl(i); // 0, 2, 4, 6, 8
465
+ }
466
+ ```
467
+
468
+ ---
469
+
470
+ ### For Loop (C-Style)
471
+
472
+ ```cssl
473
+ // Classic C-style syntax
474
+ for (int i = 0; i < 10; i++) {
475
+ printl(i);
476
+ }
477
+
478
+ // With decrement
479
+ for (int i = 10; i > 0; i--) {
480
+ printl(i);
481
+ }
482
+
483
+ // With +=
484
+ for (int i = 0; i < 100; i += 10) {
485
+ printl(i); // 0, 10, 20, ...
486
+ }
487
+ ```
488
+
489
+ ---
490
+
491
+ ### Foreach
492
+
493
+ ```cssl
494
+ stack<string> names;
495
+ names.push("Alice");
496
+ names.push("Bob");
497
+ names.push("Charlie");
498
+
499
+ // Syntax 1: foreach (item in collection)
500
+ foreach (name in names) {
501
+ printl(name);
502
+ }
503
+
504
+ // Syntax 2: foreach collection as item
505
+ foreach names as name {
506
+ printl(name);
507
+ }
508
+ ```
509
+
510
+ ---
511
+
512
+ ### Break & Continue
513
+
514
+ ```cssl
515
+ // Break - exit loop early
516
+ for (i in range(0, 10)) {
517
+ if (i == 5) {
518
+ break; // Stops at 5
519
+ }
520
+ printl(i);
521
+ }
522
+
523
+ // Continue - skip iteration
524
+ for (i in range(0, 10)) {
525
+ if (i == 3) {
526
+ continue; // Skips 3
527
+ }
528
+ printl(i);
529
+ }
530
+ ```
531
+
532
+ ---
533
+
534
+ ## Functions
535
+
536
+ ### Basic Syntax
537
+
538
+ ```cssl
539
+ // Without return
540
+ void sayHello() {
541
+ printl("Hello!");
542
+ }
543
+
544
+ // With return
545
+ string getName() {
546
+ return "CSSL";
547
+ }
548
+
549
+ // With parameters
550
+ int add(int a, int b) {
551
+ return a + b;
552
+ }
553
+
554
+ // Call
555
+ sayHello();
556
+ string n = getName();
557
+ int sum = add(5, 3);
558
+ ```
559
+
560
+ ### Named Parameters
561
+
562
+ Functions can be called with named parameters for clarity.
563
+
564
+ ```cssl
565
+ // Define function
566
+ int calculate(int base, int multiplier, int offset) {
567
+ return base * multiplier + offset;
568
+ }
569
+
570
+ // Call with positional arguments
571
+ int r1 = calculate(10, 5, 3); // 53
572
+
573
+ // Call with named parameters
574
+ int r2 = calculate(base=10, multiplier=5, offset=3); // 53
575
+
576
+ // Mix positional and named (positional must come first)
577
+ int r3 = calculate(10, multiplier=5, offset=3); // 53
578
+
579
+ // Named parameters can be in any order
580
+ int r4 = calculate(offset=3, base=10, multiplier=5); // 53
581
+ ```
582
+
583
+ ### Nested Functions
584
+
585
+ ```cssl
586
+ void inner() {
587
+ printl("Inner function");
588
+ }
589
+
590
+ void outer() {
591
+ printl("Outer function");
592
+ inner();
593
+ }
594
+
595
+ outer();
596
+ ```
597
+
598
+ ---
599
+
600
+ ## Function Keywords
601
+
602
+ ### undefined
603
+
604
+ Function silently ignores errors.
605
+
606
+ ```cssl
607
+ undefined void mayFail() {
608
+ riskyOperation(); // Errors are ignored
609
+ }
610
+ mayFail(); // No crash
611
+ ```
612
+
613
+ ---
614
+
615
+ ### dynamic
616
+
617
+ No type declaration needed.
618
+
619
+ ```cssl
620
+ dynamic x = "string";
621
+ x = 123; // now int
622
+ x = 3.14; // now float
623
+ ```
624
+
625
+ ---
626
+
627
+ ### define
628
+
629
+ Constant function without type and return.
630
+
631
+ ```cssl
632
+ define LOG_MESSAGE() {
633
+ printl("Log message");
634
+ }
635
+ LOG_MESSAGE();
636
+ ```
637
+
638
+ ---
639
+
640
+ ### closed
641
+
642
+ Protects from external code injection.
643
+
644
+ ```cssl
645
+ closed void protectedFunc() {
646
+ printl("Protected from external injections");
647
+ }
648
+ // This injection will be BLOCKED:
649
+ protectedFunc() <<== { printl("Blocked!"); }
650
+ ```
651
+
652
+ ---
653
+
654
+ ### private
655
+
656
+ Blocks ALL injections.
657
+
658
+ ```cssl
659
+ private void superSecure() {
660
+ printl("Absolutely protected");
661
+ }
662
+ ```
663
+
664
+ ---
665
+
666
+ ### virtual
667
+
668
+ Allows import cycles.
669
+
670
+ ```cssl
671
+ virtual void safeForImport() {
672
+ printl("Import-cycle-safe");
673
+ }
674
+ ```
675
+
676
+ ---
677
+
678
+ ### meta
679
+
680
+ Declares function as source (must return).
681
+
682
+ ```cssl
683
+ meta string getSource() {
684
+ return "Meta source";
685
+ }
686
+ ```
687
+
688
+ ---
689
+
690
+ ### super
691
+
692
+ Forces execution without exceptions.
693
+
694
+ ```cssl
695
+ super void forceRun() {
696
+ printl("Will ALWAYS execute");
697
+ }
698
+ ```
699
+
700
+ ---
701
+
702
+ ### shuffled
703
+
704
+ Allows multiple return values.
705
+
706
+ ```cssl
707
+ shuffled string getNames() {
708
+ return "Alice", "Bob", "Charlie";
709
+ }
710
+ ```
711
+
712
+ ---
713
+
714
+ ### open
715
+
716
+ Accepts any parameters.
717
+
718
+ ```cssl
719
+ open define flexibleFunc(open Params) {
720
+ string name = OpenFind<string>(0);
721
+ int num = OpenFind<int>(0);
722
+ printl(name);
723
+ printl(num);
724
+ }
725
+
726
+ flexibleFunc("Hello", 123, true, "World");
727
+ ```
728
+
729
+ ---
730
+
731
+ ## String Methods
732
+
733
+ CSSL offers 40+ string methods:
734
+
735
+ ### Search & Check
736
+
737
+ ```cssl
738
+ string s = "Hello World";
739
+
740
+ // Contains
741
+ bool has = s.contains("World"); // true
742
+
743
+ // Find position
744
+ int pos = s.indexOf("o"); // 4
745
+ int last = s.lastIndexOf("o"); // 7
746
+
747
+ // Start/end check
748
+ bool start = s.startsWith("Hello"); // true
749
+ bool end = s.endsWith("World"); // true
750
+ ```
751
+
752
+ ### Manipulation
753
+
754
+ ```cssl
755
+ string s = "Hello World";
756
+
757
+ // Replace
758
+ string r1 = s.replace("World", "CSSL"); // "Hello CSSL"
759
+ string r2 = s.replaceAll("l", "L"); // "HeLLo WorLd"
760
+
761
+ // Case
762
+ string upper = s.toUpperCase(); // "HELLO WORLD"
763
+ string lower = s.toLowerCase(); // "hello world"
764
+
765
+ // Trim
766
+ string padded = " text ";
767
+ string trimmed = padded.trim(); // "text"
768
+
769
+ // Repeat
770
+ string rep = "ab".repeat(3); // "ababab"
771
+
772
+ // Reverse
773
+ string rev = s.reverse(); // "dlroW olleH"
774
+ ```
775
+
776
+ ### Split & Join
777
+
778
+ ```cssl
779
+ string csv = "a,b,c,d";
780
+
781
+ // Split
782
+ stack<string> parts = csv.split(","); // ["a", "b", "c", "d"]
783
+
784
+ // Join
785
+ string joined = parts.join("-"); // "a-b-c-d"
786
+ ```
787
+
788
+ ### Extract
789
+
790
+ ```cssl
791
+ string s = "Hello World";
792
+
793
+ // Substring
794
+ string sub = s.substring(0, 5); // "Hello"
795
+ string slc = s.slice(6, 11); // "World"
796
+
797
+ // Character
798
+ string ch = s.charAt(0); // "H"
799
+ int code = s.charCodeAt(0); // 72
800
+ ```
801
+
802
+ ### Padding
803
+
804
+ ```cssl
805
+ string num = "42";
806
+
807
+ string padded1 = num.padStart(5, "0"); // "00042"
808
+ string padded2 = num.padEnd(5, "."); // "42..."
809
+ ```
810
+
811
+ ### All String Methods
812
+
813
+ | Method | Description |
814
+ |--------|-------------|
815
+ | `.contains(str)` | Check if string contains |
816
+ | `.indexOf(str)` | First position of str |
817
+ | `.lastIndexOf(str)` | Last position of str |
818
+ | `.startsWith(str)` | Starts with str? |
819
+ | `.endsWith(str)` | Ends with str? |
820
+ | `.find(str)` | Find position (-1 if not found) |
821
+ | `.split(delimiter)` | Split into array |
822
+ | `.join(delimiter)` | Join array to string |
823
+ | `.replace(old, new)` | Replace first occurrence |
824
+ | `.replaceAll(old, new)` | Replace all occurrences |
825
+ | `.substring(start, end)` | Extract substring |
826
+ | `.slice(start, end)` | Substring (like substring) |
827
+ | `.substr(start, length)` | Substring with length |
828
+ | `.toLowerCase()` | To lowercase |
829
+ | `.toUpperCase()` | To uppercase |
830
+ | `.trim()` | Remove whitespace |
831
+ | `.charAt(index)` | Character at position |
832
+ | `.charCodeAt(index)` | ASCII code at position |
833
+ | `.padStart(len, char)` | Pad left |
834
+ | `.padEnd(len, char)` | Pad right |
835
+ | `.repeat(n)` | Repeat n times |
836
+ | `.reverse()` | Reverse |
837
+ | `.count(str)` | Count occurrences |
838
+ | `len(string)` | String length |
839
+
840
+ ---
841
+
842
+ ## File I/O
843
+
844
+ CSSL provides built-in functions for file operations.
845
+
846
+ ### Basic File Operations
847
+
848
+ ```cssl
849
+ // Read entire file
850
+ string content = read("/path/to/file.txt");
851
+ printl(content);
852
+
853
+ // Read specific line (1-indexed)
854
+ string line5 = readline(5, "/path/to/file.txt");
855
+ printl(line5);
856
+
857
+ // Write to file (overwrites)
858
+ write("/path/to/file.txt", "Hello World");
859
+
860
+ // Write/replace specific line
861
+ writeline(3, "New line content", "/path/to/file.txt");
862
+ ```
863
+
864
+ ### Extended File Functions
865
+
866
+ ```cssl
867
+ // Read all lines as array
868
+ stack<string> lines = readlines("/path/to/file.txt");
869
+
870
+ // Append to file
871
+ appendfile("/path/to/file.txt", "\nNew content");
872
+
873
+ // File checks
874
+ bool exists = pathexists("/path/to/file.txt");
875
+ bool isFile = isfile("/path/to/file.txt");
876
+ bool isDir = isdir("/path/to/folder");
877
+
878
+ // File size
879
+ int size = filesize("/path/to/file.txt");
880
+
881
+ // Directory listing
882
+ stack<string> files = listdir("/path/to/folder");
883
+ ```
884
+
885
+ ### Path Functions
886
+
887
+ ```cssl
888
+ // Path manipulation
889
+ string base = basename("/path/to/file.txt"); // "file.txt"
890
+ string dir = dirname("/path/to/file.txt"); // "/path/to"
891
+ string full = joinpath("/path", "to", "file.txt"); // "/path/to/file.txt"
892
+ string abs = abspath("./file.txt"); // "/current/dir/file.txt"
893
+ ```
894
+
895
+ ### All File I/O Functions
896
+
897
+ | Function | Description |
898
+ |----------|-------------|
899
+ | `read(path)` | Read entire file content |
900
+ | `readline(line, path)` | Read specific line (1-indexed) |
901
+ | `write(path, content)` | Write content to file |
902
+ | `writeline(line, content, path)` | Write/replace specific line |
903
+ | `readfile(path)` | Read file (alias for read) |
904
+ | `writefile(path, content)` | Write file (alias for write) |
905
+ | `readlines(path)` | Read all lines as array |
906
+ | `appendfile(path, content)` | Append to file |
907
+ | `pathexists(path)` | Check if path exists |
908
+ | `isfile(path)` | Check if is file |
909
+ | `isdir(path)` | Check if is directory |
910
+ | `filesize(path)` | Get file size in bytes |
911
+ | `listdir(path)` | List directory contents |
912
+ | `makedirs(path)` | Create directories |
913
+ | `removefile(path)` | Delete file |
914
+ | `removedir(path)` | Delete empty directory |
915
+ | `copyfile(src, dst)` | Copy file |
916
+ | `movefile(src, dst)` | Move file |
917
+
918
+ ---
919
+
920
+ ## JSON Functions
921
+
922
+ CSSL provides namespace-style JSON functions with the `json::` prefix.
923
+
924
+ ### Reading & Writing JSON Files
925
+
926
+ ```cssl
927
+ // Read and parse JSON file
928
+ json data = json::read("/path/to/config.json");
929
+ printl(data.name);
930
+
931
+ // Write data to JSON file
932
+ json::write("/path/to/output.json", data);
933
+ ```
934
+
935
+ ### JSON Parsing & Stringifying
936
+
937
+ ```cssl
938
+ // Parse JSON string
939
+ string jsonStr = '{"name": "Alice", "age": 30}';
940
+ json obj = json::parse(jsonStr);
941
+
942
+ // Convert to JSON string
943
+ string str = json::stringify(obj);
944
+
945
+ // Pretty print with indentation
946
+ string pretty = json::pretty(obj);
947
+ printl(pretty);
948
+ ```
949
+
950
+ ### JSON Path Operations
951
+
952
+ ```cssl
953
+ json data = json::read("config.json");
954
+
955
+ // Get value by dot-path
956
+ string name = json::get(data, "user.name");
957
+ int age = json::get(data, "user.profile.age");
958
+ string city = json::get(data, "address.city", "Unknown"); // with default
959
+
960
+ // Set value by dot-path
961
+ data = json::set(data, "user.name", "Bob");
962
+ data = json::set(data, "settings.theme", "dark");
963
+
964
+ // Check if path exists
965
+ if (json::has(data, "user.email")) {
966
+ printl("Email exists");
967
+ }
968
+ ```
969
+
970
+ ### JSON Object Operations
971
+
972
+ ```cssl
973
+ json obj = json::read("data.json");
974
+
975
+ // Get all keys
976
+ stack<string> keys = json::keys(obj);
977
+ foreach (key in keys) {
978
+ printl(key);
979
+ }
980
+
981
+ // Get all values
982
+ stack<dynamic> values = json::values(obj);
983
+
984
+ // Deep merge objects
985
+ json merged = json::merge(obj1, obj2, obj3);
986
+ ```
987
+
988
+ ### All JSON Functions
989
+
990
+ | Function | Description |
991
+ |----------|-------------|
992
+ | `json::read(path)` | Read and parse JSON file |
993
+ | `json::write(path, data)` | Write data to JSON file |
994
+ | `json::parse(str)` | Parse JSON string to object |
995
+ | `json::stringify(data)` | Convert to JSON string |
996
+ | `json::pretty(data)` | Pretty print JSON |
997
+ | `json::get(data, path, default)` | Get value by dot-path |
998
+ | `json::set(data, path, value)` | Set value by dot-path |
999
+ | `json::has(data, path)` | Check if path exists |
1000
+ | `json::keys(data)` | Get all keys |
1001
+ | `json::values(data)` | Get all values |
1002
+ | `json::merge(obj1, obj2, ...)` | Deep merge objects |
1003
+
1004
+ ---
1005
+
1006
+ ## Instance Management
1007
+
1008
+ CSSL provides `instance<"name">` syntax and `instance::` namespace for working with shared instances.
1009
+
1010
+ ### Instance Declaration
1011
+
1012
+ ```cssl
1013
+ // Get/create shared instance by name
1014
+ instance<"MyApp"> app;
1015
+
1016
+ // With initialization
1017
+ instance<"tk"> tk = include("tkinter.cssl-mod");
1018
+
1019
+ // Register object as shared instance
1020
+ myModule ==> $AppModule
1021
+ // Or using instance syntax:
1022
+ myModule ==> instance<"AppModule">
1023
+ ```
1024
+
1025
+ ### Instance Introspection
1026
+
1027
+ ```cssl
1028
+ @tk = include("tk.cssl-mod");
1029
+
1030
+ // Get all methods from module
1031
+ stack<string> methods = instance::getMethods(@tk);
1032
+ foreach (m in methods) {
1033
+ printl("Method: " + m);
1034
+ }
1035
+
1036
+ // Get all classes
1037
+ stack<string> classes = instance::getClasses(@tk);
1038
+
1039
+ // Get all variables
1040
+ stack<string> vars = instance::getVars(@tk);
1041
+
1042
+ // Get everything categorized
1043
+ json all = instance::getAll(@tk);
1044
+ printl(all.methods); // ["method1", "method2", ...]
1045
+ printl(all.classes); // ["Class1", "Class2", ...]
1046
+ printl(all.vars); // ["var1", "var2", ...]
1047
+ ```
1048
+
1049
+ ### Dynamic Method Calls
1050
+
1051
+ ```cssl
1052
+ // Call method dynamically by name
1053
+ result = instance::call(@module, "methodName", arg1, arg2);
1054
+
1055
+ // Check if method/attribute exists
1056
+ if (instance::has(@module, "initialize")) {
1057
+ instance::call(@module, "initialize");
1058
+ }
1059
+
1060
+ // Get type name
1061
+ string typeName = instance::type(@module);
1062
+ printl(typeName); // "module"
1063
+ ```
1064
+
1065
+ ### All Instance Functions
1066
+
1067
+ | Function | Description |
1068
+ |----------|-------------|
1069
+ | `instance<"name"> var` | Declare instance variable |
1070
+ | `obj ==> instance<"name">` | Register as shared instance |
1071
+ | `instance::getMethods(obj)` | Get all method names |
1072
+ | `instance::getClasses(obj)` | Get all class names |
1073
+ | `instance::getVars(obj)` | Get all variable names |
1074
+ | `instance::getAll(obj)` | Get categorized dict |
1075
+ | `instance::call(obj, 'name', ...)` | Call method dynamically |
1076
+ | `instance::has(obj, 'name')` | Check if attribute exists |
1077
+ | `instance::type(obj)` | Get type name |
1078
+ | `isavailable("name")` | Check if shared instance exists |
1079
+ | `instance::exists("name")` | Alias for isavailable |
1080
+
1081
+ ---
1082
+
1083
+ ## Live Object Sharing
1084
+
1085
+ Share Python objects with CSSL. Changes in CSSL reflect back to Python.
1086
+
1087
+ ### Python Side
1088
+
1089
+ ```python
1090
+ from includecpp import CSSL
1091
+
1092
+ class Counter:
1093
+ def __init__(self):
1094
+ self.value = 100
1095
+
1096
+ counter = Counter()
1097
+ cssl = CSSL.CsslLang()
1098
+ cssl.share(counter, "cnt")
1099
+
1100
+ # Changes in CSSL will reflect in Python!
1101
+ cssl.exec('''
1102
+ $cnt.value = $cnt.value - 10;
1103
+ printl($cnt.value); // 90
1104
+ ''')
1105
+
1106
+ print(counter.value) # 90 - Changed!
1107
+ ```
1108
+
1109
+ ### CSSL Syntax
1110
+
1111
+ | Syntax | Description |
1112
+ |--------|-------------|
1113
+ | `$name` | Access shared object |
1114
+ | `$name.property` | Access/modify properties |
1115
+ | `$name.method()` | Call methods |
1116
+ | `delete("name")` | Remove shared object |
1117
+
1118
+ ### Loop Modifications
1119
+
1120
+ ```python
1121
+ # Python
1122
+ class Stats:
1123
+ def __init__(self):
1124
+ self.total = 100
1125
+
1126
+ stats = Stats()
1127
+ cssl = CSSL.CsslLang()
1128
+ cssl.share(stats, "s")
1129
+
1130
+ cssl.exec('''
1131
+ for (i in range(0, 5)) {
1132
+ $s.total = $s.total - 10;
1133
+ }
1134
+ printl($s.total); // 50
1135
+ ''')
1136
+
1137
+ print(stats.total) # 50 - Persisted!
1138
+ ```
1139
+
1140
+ ---
1141
+
1142
+ ## CodeInfusion
1143
+
1144
+ CodeInfusion enables modifying functions at runtime.
1145
+
1146
+ ### <<== (Replace)
1147
+
1148
+ Replaces function content.
1149
+
1150
+ ```cssl
1151
+ void original() {
1152
+ printl("Original");
1153
+ }
1154
+
1155
+ original() <<== {
1156
+ printl("Replaced");
1157
+ }
1158
+
1159
+ original(); // "Replaced"
1160
+ ```
1161
+
1162
+ ---
1163
+
1164
+ ### +<<== (Add)
1165
+
1166
+ Adds code to function (executes BEFORE original).
1167
+
1168
+ ```cssl
1169
+ void base() {
1170
+ printl("Base");
1171
+ }
1172
+
1173
+ base() +<<== {
1174
+ printl("Added");
1175
+ }
1176
+
1177
+ base();
1178
+ // Output:
1179
+ // Added
1180
+ // Base
1181
+ ```
1182
+
1183
+ ---
1184
+
1185
+ ### -<<== (Remove)
1186
+
1187
+ Removes code from function.
1188
+
1189
+ ```cssl
1190
+ void withExtra() {
1191
+ printl("Important");
1192
+ printl("Unimportant");
1193
+ }
1194
+
1195
+ withExtra() -<<== {
1196
+ printl("Unimportant");
1197
+ }
1198
+
1199
+ withExtra(); // Only "Important"
1200
+ ```
1201
+
1202
+ ---
1203
+
1204
+ ### exit() Injection
1205
+
1206
+ Special injection for program end.
1207
+
1208
+ ```cssl
1209
+ exit() <<== {
1210
+ printl("Cleanup before exit...");
1211
+ }
1212
+
1213
+ // Later:
1214
+ exit(); // Executes injection
1215
+ ```
1216
+
1217
+ ---
1218
+
1219
+ ## Value Capture
1220
+
1221
+ The `%identifier` syntax captures values at registration time, useful for saving original functions before replacement.
1222
+
1223
+ ### Capturing Variables
1224
+
1225
+ ```cssl
1226
+ string version = "1.0.0";
1227
+
1228
+ // Capture current value
1229
+ v <== { %version; }
1230
+ printl(v); // "1.0.0"
1231
+
1232
+ // Even if version changes later, v keeps captured value
1233
+ version = "2.0.0";
1234
+ printl(v); // Still "1.0.0"
1235
+ ```
1236
+
1237
+ ### Capturing Functions
1238
+
1239
+ ```cssl
1240
+ // Save original exit function before replacing
1241
+ originalExit <<== { %exit(); }
1242
+
1243
+ // Replace exit with custom behavior
1244
+ exit() <<== {
1245
+ printl("Custom cleanup...");
1246
+ originalExit(); // Call saved original
1247
+ }
1248
+
1249
+ exit();
1250
+ // Output:
1251
+ // Custom cleanup...
1252
+ // (original exit behavior)
1253
+ ```
1254
+
1255
+ ### Use Cases
1256
+
1257
+ ```cssl
1258
+ // 1. Preserving original behavior
1259
+ void myFunc() {
1260
+ printl("Original");
1261
+ }
1262
+
1263
+ savedFunc <<== { %myFunc(); }
1264
+
1265
+ myFunc() <<== {
1266
+ printl("Modified");
1267
+ }
1268
+
1269
+ myFunc(); // "Modified"
1270
+ savedFunc(); // "Original"
1271
+
1272
+ // 2. Capturing configuration at startup
1273
+ global config = loadConfig();
1274
+ startupConfig <== { %config; }
1275
+
1276
+ // 3. Snapshot values for later comparison
1277
+ int counter = 0;
1278
+ initial <== { %counter; }
1279
+ // ... operations ...
1280
+ if (counter != initial) {
1281
+ printl("Counter changed!");
1282
+ }
1283
+ ```
1284
+
1285
+ ---
1286
+
1287
+ ## BruteInjection
1288
+
1289
+ BruteInjection copies/moves data between containers.
1290
+
1291
+ ### +<== (Copy)
1292
+
1293
+ Copies data to target (source unchanged).
1294
+
1295
+ ```cssl
1296
+ stack<string> source;
1297
+ source.push("A");
1298
+ source.push("B");
1299
+
1300
+ datastruct<string> target;
1301
+ target +<== source; // Copies A, B
1302
+ ```
1303
+
1304
+ ---
1305
+
1306
+ ### -<== (Move)
1307
+
1308
+ Moves data (removes from source).
1309
+
1310
+ ```cssl
1311
+ stack<string> src;
1312
+ src.push("Data");
1313
+
1314
+ datastruct<string> dst;
1315
+ dst -<== src; // src is empty after
1316
+ ```
1317
+
1318
+ ---
1319
+
1320
+ ### ==> (Replace)
1321
+
1322
+ Replaces target data completely.
1323
+
1324
+ ```cssl
1325
+ stack<string> data;
1326
+ data.push("New");
1327
+
1328
+ datastruct<string> container;
1329
+ container ==> data;
1330
+ ```
1331
+
1332
+ ---
1333
+
1334
+ ### ==>- (Receive Minus)
1335
+
1336
+ Removes matching items from target.
1337
+
1338
+ ```cssl
1339
+ stack<string> names;
1340
+ names.push("Alice");
1341
+ names.push("Bob");
1342
+ names.push("Alice");
1343
+
1344
+ stack<string> toRemove;
1345
+ toRemove.push("Alice");
1346
+
1347
+ // Remove all "Alice" from names
1348
+ names ==>- toRemove;
1349
+ printl(names); // ["Bob"]
1350
+ ```
1351
+
1352
+ ---
1353
+
1354
+ ## Filter Syntax
1355
+
1356
+ Filters enable targeted data operations in BruteInjection.
1357
+
1358
+ ### Syntax
1359
+
1360
+ ```cssl
1361
+ target +<== [type::filter=value] source;
1362
+ ```
1363
+
1364
+ ### String Filters
1365
+
1366
+ ```cssl
1367
+ stack<string> fruits;
1368
+ fruits.push("Apple");
1369
+ fruits.push("Banana");
1370
+ fruits.push("Apricot");
1371
+
1372
+ datastruct<string> result;
1373
+
1374
+ // Exact match
1375
+ result +<== [string::where="Apple"] fruits;
1376
+
1377
+ // Everything except
1378
+ result +<== [string::not="Banana"] fruits;
1379
+
1380
+ // Contains substring
1381
+ result +<== [string::contains="App"] fruits; // Apple, Apricot
1382
+
1383
+ // String length
1384
+ result +<== [string::length=5] fruits; // Apple
1385
+ ```
1386
+
1387
+ ### String Cutting Filters
1388
+
1389
+ Cut strings at specific positions or substrings.
1390
+
1391
+ ```cssl
1392
+ string version = "1.0.0-beta";
1393
+
1394
+ // Cut at position (integer index)
1395
+ x = <==[string::cut=3] version;
1396
+ printl(x); // "1.0" (first 3 chars)
1397
+
1398
+ // Cut at substring position
1399
+ x = <==[string::cut="0-"] version;
1400
+ printl(x); // "1.0." (before "0-")
1401
+
1402
+ // Get everything after substring
1403
+ x = <==[string::cutAfter=".0."] version;
1404
+ printl(x); // "0-beta" (after ".0.")
1405
+
1406
+ // Cut after at position
1407
+ x = <==[string::cutAfter=4] version;
1408
+ printl(x); // ".0-beta" (after index 4)
1409
+ ```
1410
+
1411
+ ### All Filters
1412
+
1413
+ | Filter | Description |
1414
+ |--------|-------------|
1415
+ | `string::where=VALUE` | Exact string match |
1416
+ | `string::not=VALUE` | Everything except this value |
1417
+ | `string::contains=VALUE` | Contains substring |
1418
+ | `string::length=LENGTH` | Exact string length |
1419
+ | `string::cut=INDEX` | Cut at index (returns first N chars) |
1420
+ | `string::cut="SUBSTR"` | Cut at substring position |
1421
+ | `string::cutAfter=INDEX` | Get everything after index |
1422
+ | `string::cutAfter="SUBSTR"` | Get everything after substring |
1423
+ | `integer::where=VALUE` | Exact int match |
1424
+ | `json::key=KEYNAME` | Filter by JSON key |
1425
+ | `json::value=VALUE` | Filter by JSON value |
1426
+ | `array::index=INDEX` | By array index |
1427
+ | `vector::where=VALUE` | Exact vector match |
1428
+ | `combo::filterdb` | Combo FilterDB |
1429
+
1430
+ ---
1431
+
1432
+ ## Module System
1433
+
1434
+ ### Create Module
1435
+
1436
+ Create CSSL module from Python file:
1437
+
1438
+ ```bash
1439
+ python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
1440
+ ```
1441
+
1442
+ ### Import Module
1443
+
1444
+ ```cssl
1445
+ // Import Python module
1446
+ @Math = include("mymath.cssl-mod");
1447
+
1448
+ // Import CSSL file
1449
+ @Utils = include("utils.cssl");
1450
+
1451
+ // Call module functions
1452
+ int result = @Math.add(5, 3);
1453
+ string text = @Utils.format("Hello");
1454
+ ```
1455
+
1456
+ ### Example: Python Module
1457
+
1458
+ **mathlib.py:**
1459
+ ```python
1460
+ def add(a, b):
1461
+ return a + b
1462
+
1463
+ def multiply(a, b):
1464
+ return a * b
1465
+
1466
+ def square(x):
1467
+ return x * x
1468
+ ```
1469
+
1470
+ **Create module:**
1471
+ ```bash
1472
+ python -m includecpp cssl makemodule mathlib.py -o mathlib.cssl-mod
1473
+ ```
1474
+
1475
+ **Use in CSSL:**
1476
+ ```cssl
1477
+ @Math = include("mathlib.cssl-mod");
1478
+
1479
+ int sum = @Math.add(10, 20); // 30
1480
+ int product = @Math.multiply(5, 6); // 30
1481
+ int sq = @Math.square(8); // 64
1482
+
1483
+ printl(sum);
1484
+ printl(product);
1485
+ printl(sq);
1486
+ ```
1487
+
1488
+ ---
1489
+
1490
+ ## Parameter Bridge
1491
+
1492
+ Communication between Python and CSSL.
1493
+
1494
+ ### parameter.get()
1495
+
1496
+ Receive parameters from Python:
1497
+
1498
+ ```cssl
1499
+ // In CSSL
1500
+ string name = parameter.get(0); // First parameter
1501
+ int count = parameter.get(1); // Second parameter
1502
+ printl(name);
1503
+ printl(count);
1504
+ ```
1505
+
1506
+ ```python
1507
+ # In Python
1508
+ CSSL.exec(code, "Alice", 42)
1509
+ ```
1510
+
1511
+ ### parameter.return()
1512
+
1513
+ Return value to Python:
1514
+
1515
+ ```cssl
1516
+ // In CSSL
1517
+ int result = 10 + 20;
1518
+ parameter.return(result);
1519
+ ```
1520
+
1521
+ ```python
1522
+ # In Python
1523
+ result = CSSL.exec(code)
1524
+ print(result) # 30
1525
+ ```
1526
+
1527
+ ### Complete Example
1528
+
1529
+ ```python
1530
+ from includecpp import CSSL
1531
+
1532
+ CSSL.CsslLang()
1533
+
1534
+ code = """
1535
+ int a = parameter.get(0);
1536
+ int b = parameter.get(1);
1537
+ int sum = a + b;
1538
+ parameter.return(sum);
1539
+ """
1540
+
1541
+ result = CSSL.exec(code, 15, 27)
1542
+ print(f"Result: {result}") # Result: 42
1543
+ ```
1544
+
1545
+ ### Supported Return Types
1546
+
1547
+ ```cssl
1548
+ parameter.return(true); // bool
1549
+ parameter.return(42); // int
1550
+ parameter.return(3.14); // float
1551
+ parameter.return("Hello"); // string
1552
+ parameter.return(myStack); // stack/array
1553
+ parameter.return(myObject); // JSON/dict
1554
+ ```
1555
+
1556
+ ---
1557
+
1558
+ ## Classes & OOP
1559
+
1560
+ CSSL supports object-oriented programming with classes, constructors, and the `this->` keyword for member access.
1561
+
1562
+ ### Defining a Class
1563
+
1564
+ ```cssl
1565
+ class Person {
1566
+ // Member variables
1567
+ string name;
1568
+ int age;
1569
+
1570
+ // Constructor (same name as class)
1571
+ void Person(string n, int a) {
1572
+ this->name = n;
1573
+ this->age = a;
1574
+ }
1575
+
1576
+ // Methods
1577
+ void greet() {
1578
+ printl("Hello, I'm " + this->name);
1579
+ }
1580
+
1581
+ string getName() {
1582
+ return this->name;
1583
+ }
1584
+
1585
+ void setAge(int a) {
1586
+ this->age = a;
1587
+ }
1588
+ }
1589
+ ```
1590
+
1591
+ ### Creating Instances
1592
+
1593
+ ```cssl
1594
+ // Use 'new' keyword to instantiate
1595
+ Person p = new Person("Alice", 30);
1596
+
1597
+ // Call methods
1598
+ p.greet(); // prints: "Hello, I'm Alice"
1599
+ string name = p.getName(); // returns "Alice"
1600
+
1601
+ // Access members (if public)
1602
+ printl(p.name); // prints: "Alice"
1603
+ p.age = 31; // set member directly
1604
+ ```
1605
+
1606
+ ### The `this->` Keyword
1607
+
1608
+ Inside class methods, use `this->` to access instance members:
1609
+
1610
+ ```cssl
1611
+ class Counter {
1612
+ int count;
1613
+
1614
+ void Counter() {
1615
+ this->count = 0;
1616
+ }
1617
+
1618
+ void increment() {
1619
+ this->count = this->count + 1;
1620
+ }
1621
+
1622
+ void add(int n) {
1623
+ this->count = this->count + n;
1624
+ }
1625
+
1626
+ int get() {
1627
+ return this->count;
1628
+ }
1629
+ }
1630
+
1631
+ Counter c = new Counter();
1632
+ c.increment();
1633
+ c.add(5);
1634
+ printl(c.get()); // prints: 6
1635
+ ```
1636
+
1637
+ ### Constructor Variations
1638
+
1639
+ ```cssl
1640
+ class MyClass {
1641
+ // Constructor with same name as class
1642
+ void MyClass(int x) {
1643
+ this->value = x;
1644
+ }
1645
+ }
1646
+
1647
+ // Alternative: use __init__
1648
+ class MyClass2 {
1649
+ void __init__(int x) {
1650
+ this->value = x;
1651
+ }
1652
+ }
1653
+ ```
1654
+
1655
+ ### Method Chaining
1656
+
1657
+ ```cssl
1658
+ class Builder {
1659
+ string result;
1660
+
1661
+ void Builder() {
1662
+ this->result = "";
1663
+ }
1664
+
1665
+ Builder add(string s) {
1666
+ this->result = this->result + s;
1667
+ return this;
1668
+ }
1669
+
1670
+ string build() {
1671
+ return this->result;
1672
+ }
1673
+ }
1674
+
1675
+ Builder b = new Builder();
1676
+ string result = b.add("Hello ").add("World!").build();
1677
+ printl(result); // prints: "Hello World!"
1678
+ ```
1679
+
1680
+ ---
1681
+
1682
+ ## Map Container
1683
+
1684
+ The `map<>` type provides C++ style ordered key-value storage.
1685
+
1686
+ ### Creating Maps
1687
+
1688
+ ```cssl
1689
+ map<string, int> ages;
1690
+ map<string, string> config;
1691
+ ```
1692
+
1693
+ ### Basic Operations
1694
+
1695
+ ```cssl
1696
+ map<string, int> ages;
1697
+
1698
+ // Insert values
1699
+ ages.insert("Alice", 30);
1700
+ ages.insert("Bob", 25);
1701
+
1702
+ // Find values
1703
+ int age = ages.find("Alice"); // returns 30
1704
+
1705
+ // Check existence
1706
+ if (ages.contains("Alice")) {
1707
+ printl("Found!");
1708
+ }
1709
+
1710
+ // Erase entries
1711
+ ages.erase("Bob");
1712
+
1713
+ // Get with exception if not found
1714
+ int a = ages.at("Alice"); // throws if not found
1715
+
1716
+ // Size and empty check
1717
+ int size = ages.size();
1718
+ bool empty = ages.empty();
1719
+ ```
1720
+
1721
+ ### Iteration and Bounds
1722
+
1723
+ ```cssl
1724
+ map<string, int> data;
1725
+ data.insert("apple", 1);
1726
+ data.insert("banana", 2);
1727
+ data.insert("cherry", 3);
1728
+
1729
+ // Get first/last elements
1730
+ tuple first = data.begin(); // ("apple", 1)
1731
+ tuple last = data.end(); // ("cherry", 3)
1732
+
1733
+ // Find bounds (for sorted keys)
1734
+ string lb = data.lower_bound("b"); // "banana" (first key >= "b")
1735
+ string ub = data.upper_bound("b"); // "cherry" (first key > "b")
1736
+ ```
1737
+
1738
+ ---
1739
+
1740
+ ## Structures
1741
+
1742
+ Structures are user-defined data types.
1743
+
1744
+ ```cssl
1745
+ structure Person {
1746
+ string name;
1747
+ int age;
1748
+ string email;
1749
+ }
1750
+
1751
+ // Create instance
1752
+ Person user;
1753
+ user.name = "Max";
1754
+ user.age = 25;
1755
+ user.email = "max@example.com";
1756
+
1757
+ printl(user.name); // "Max"
1758
+ printl(user.age); // 25
1759
+ ```
1760
+
1761
+ ### With Functions
1762
+
1763
+ ```cssl
1764
+ structure Rectangle {
1765
+ int width;
1766
+ int height;
1767
+ }
1768
+
1769
+ int calculateArea(Rectangle rect) {
1770
+ return rect.width * rect.height;
1771
+ }
1772
+
1773
+ Rectangle r;
1774
+ r.width = 10;
1775
+ r.height = 5;
1776
+ int area = calculateArea(r);
1777
+ printl(area); // 50
1778
+ ```
1779
+
1780
+ ---
1781
+
1782
+ ## Error Handling
1783
+
1784
+ ### Try / Catch
1785
+
1786
+ ```cssl
1787
+ try {
1788
+ // Risky code
1789
+ int result = riskyOperation();
1790
+ printl(result);
1791
+ } catch {
1792
+ printl("An error occurred");
1793
+ }
1794
+ ```
1795
+
1796
+ ### With undefined
1797
+
1798
+ ```cssl
1799
+ undefined void safeOperation() {
1800
+ // Errors are silently ignored
1801
+ dangerousCode();
1802
+ }
1803
+
1804
+ safeOperation(); // No crash
1805
+ ```
1806
+
1807
+ ---
1808
+
1809
+ ## CLI Commands
1810
+
1811
+ ### Execute
1812
+
1813
+ ```bash
1814
+ # Execute CSSL file
1815
+ python -m includecpp cssl exec script.cssl
1816
+
1817
+ # Execute CSSL code directly
1818
+ python -m includecpp cssl exec -c "printl('Hello');"
1819
+ ```
1820
+
1821
+ ### Create Module
1822
+
1823
+ ```bash
1824
+ # From Python file
1825
+ python -m includecpp cssl makemodule mylib.py -o mylib.cssl-mod
1826
+
1827
+ # With output path
1828
+ python -m includecpp cssl makemodule src/utils.py -o modules/utils.cssl-mod
1829
+ ```
1830
+
1831
+ ### Help
1832
+
1833
+ ```bash
1834
+ python -m includecpp cssl --help
1835
+ python -m includecpp cssl exec --help
1836
+ python -m includecpp cssl makemodule --help
1837
+ ```
1838
+
1839
+ ---
1840
+
1841
+ ## Examples
1842
+
1843
+ ### Tkinter GUI Calendar
1844
+
1845
+ ```cssl
1846
+ // Import modules
1847
+ @Gui = include("modules/tkgui.cssl-mod");
1848
+
1849
+ // Global state
1850
+ global currentMonth = 0;
1851
+ global currentYear = 0;
1852
+
1853
+ // Initialize
1854
+ void init() {
1855
+ @currentYear = @Gui.get_current_year();
1856
+ @currentMonth = @Gui.get_current_month();
1857
+ }
1858
+
1859
+ // Build calendar
1860
+ void buildCalendar() {
1861
+ stack<string> days;
1862
+ days.push("Mo");
1863
+ days.push("Tu");
1864
+ days.push("We");
1865
+ days.push("Th");
1866
+ days.push("Fr");
1867
+ days.push("Sa");
1868
+ days.push("Su");
1869
+
1870
+ // Header with for-loop
1871
+ for (i in range(0, 7)) {
1872
+ @Gui.add_label(days[i], i * 40, 50);
1873
+ }
1874
+
1875
+ // Days with C-style for
1876
+ int daysInMonth = @Gui.get_days_in_month(@currentYear, @currentMonth);
1877
+ for (int d = 1; d <= daysInMonth; d++) {
1878
+ @Gui.add_button("" + d, d);
1879
+ }
1880
+ }
1881
+
1882
+ // Main
1883
+ init();
1884
+ @Gui.create_window("CSSL Calendar", 350, 400);
1885
+ buildCalendar();
1886
+ @Gui.run();
1887
+ ```
1888
+
1889
+ ---
1890
+
1891
+ ### Task Manager with CodeInfusion
1892
+
1893
+ ```cssl
1894
+ global tasks = stack<string>;
1895
+
1896
+ void addTask(string task) {
1897
+ @tasks.push(task);
1898
+ printl("+ " + task);
1899
+ }
1900
+
1901
+ void showTasks() {
1902
+ printl("=== Tasks ===");
1903
+ foreach (task in @tasks) {
1904
+ printl("- " + task);
1905
+ }
1906
+ }
1907
+
1908
+ void completeTask() {
1909
+ string done = @tasks.pop();
1910
+ printl("Completed: " + done);
1911
+ }
1912
+
1913
+ // Add logging via CodeInfusion
1914
+ addTask() +<<== {
1915
+ printl("[LOG] Adding task...");
1916
+ }
1917
+
1918
+ // Exit handler
1919
+ exit() <<== {
1920
+ printl("Shutting down Task Manager...");
1921
+ }
1922
+
1923
+ // Application
1924
+ addTask("Write code");
1925
+ addTask("Run tests");
1926
+ addTask("Update documentation");
1927
+ showTasks();
1928
+ completeTask();
1929
+ exit();
1930
+ ```
1931
+
1932
+ ---
1933
+
1934
+ ### Data Pipeline with BruteInjection
1935
+
1936
+ ```cssl
1937
+ // Source data
1938
+ stack<string> rawData;
1939
+ rawData.push("Alice");
1940
+ rawData.push("Bob");
1941
+ rawData.push("Charlie");
1942
+ rawData.push("Alex");
1943
+ rawData.push("Anna");
1944
+
1945
+ // Filter: Only names containing "A"
1946
+ datastruct<string> aNames;
1947
+ aNames +<== [string::contains="A"] rawData;
1948
+
1949
+ // Output
1950
+ printl("Names with A:");
1951
+ foreach (name in aNames) {
1952
+ printl(" - " + name);
1953
+ }
1954
+ // Output: Alice, Alex, Anna
1955
+ ```
1956
+
1957
+ ---
1958
+
1959
+ ### Python-CSSL Bridge
1960
+
1961
+ ```python
1962
+ from includecpp import CSSL
1963
+
1964
+ CSSL.CsslLang()
1965
+
1966
+ # Syntax checker in CSSL
1967
+ checker = """
1968
+ global errors = stack<string>;
1969
+
1970
+ void checkLine(string line) {
1971
+ if (line.startsWith("def ") && !line.endsWith(":")) {
1972
+ @errors.push("Missing colon after def");
1973
+ }
1974
+ if (line.startsWith("if ") && !line.endsWith(":")) {
1975
+ @errors.push("Missing colon after if");
1976
+ }
1977
+ }
1978
+
1979
+ define analyze() {
1980
+ string code = parameter.get(0);
1981
+ stack<string> lines = code.split("\\n");
1982
+
1983
+ foreach (line in lines) {
1984
+ checkLine(line);
1985
+ }
1986
+
1987
+ if (len(@errors) == 0) {
1988
+ parameter.return("OK");
1989
+ } else {
1990
+ parameter.return(@errors);
1991
+ }
1992
+ }
1993
+
1994
+ analyze();
1995
+ """
1996
+
1997
+ # Check Python code
1998
+ test_code = """def hello()
1999
+ print("world")"""
2000
+
2001
+ result = CSSL.exec(checker, test_code)
2002
+ print(result) # ["Missing colon after def"]
2003
+ ```
2004
+
2005
+ ---
2006
+
2007
+ ## Reference Table
2008
+
2009
+ ### Keywords
2010
+
2011
+ | Keyword | Description |
2012
+ |---------|-------------|
2013
+ | `void` | Function without return |
2014
+ | `return` | Return value |
2015
+ | `global` | Declare global variable |
2016
+ | `r@` | Alternative global syntax |
2017
+ | `@` | Access global variable |
2018
+ | `if` / `else if` / `else` | Conditions |
2019
+ | `switch` / `case` / `default` | Switch statement |
2020
+ | `for` / `foreach` / `while` | Loops |
2021
+ | `break` / `continue` | Loop control |
2022
+ | `try` / `catch` | Error handling |
2023
+ | `undefined` | Ignore errors |
2024
+ | `dynamic` | Dynamic type |
2025
+ | `define` | Constant function |
2026
+ | `closed` | Block external injection |
2027
+ | `private` | Block all injections |
2028
+ | `virtual` | Import-cycle-safe |
2029
+ | `meta` | Source function |
2030
+ | `super` | Forced execution |
2031
+ | `shuffled` | Multiple returns |
2032
+ | `open` | Any parameters |
2033
+ | `structure` | User-defined type |
2034
+ | `include` | Import module |
2035
+
2036
+ ### Injection Operators
2037
+
2038
+ | Operator | Type | Description |
2039
+ |----------|------|-------------|
2040
+ | `<<==` | CodeInfusion | Replace function |
2041
+ | `+<<==` | CodeInfusion | Add code (before) |
2042
+ | `-<<==` | CodeInfusion | Remove code |
2043
+ | `<==` | ValueCapture | Capture/assign value |
2044
+ | `+<==` | BruteInjection | Copy data |
2045
+ | `-<==` | BruteInjection | Move data |
2046
+ | `==>` | BruteInjection | Replace data |
2047
+ | `==>-` | BruteInjection | Remove matching items |
2048
+
2049
+ ### Special Syntax
2050
+
2051
+ | Syntax | Description |
2052
+ |--------|-------------|
2053
+ | `%identifier` | Capture value at registration time |
2054
+ | `json::func()` | Namespace function call |
2055
+ | `@name` | Access global variable |
2056
+ | `$name` | Access shared Python object |
2057
+ | `s@name` | Self-reference to struct |
2058
+ | `r@name` | Global variable declaration |
2059
+
2060
+ ---
2061
+
2062
+ ## Tips & Best Practices
2063
+
2064
+ 1. **Type Safety**: Use explicit types instead of `dynamic` for better performance
2065
+ 2. **Global Variables**: Use sparingly, always access with `@`
2066
+ 3. **For Loops**: Python-style for simple iterations, C-style when `++`/`--` needed
2067
+ 4. **CodeInfusion**: Protect with `closed`/`private` when necessary
2068
+ 5. **Modules**: Python modules for complex logic, CSSL for business logic
2069
+ 6. **Error Handling**: `try/catch` for external calls, `undefined` for optional operations
2070
+ 7. **String Operations**: Use built-in methods instead of manual manipulation
2071
+ 8. **Live Objects**: Use `$name` syntax for bidirectional Python-CSSL data sharing
2072
+
2073
+ ---
2074
+
2075
+ *CSSL v3.6.3 - Developed as part of IncludeCPP*