about summary refs log tree commit diff stats
path: root/js/scripting-lang/baba-yaga-c/ROADMAP.md
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/baba-yaga-c/ROADMAP.md')
-rw-r--r--js/scripting-lang/baba-yaga-c/ROADMAP.md143
1 files changed, 143 insertions, 0 deletions
diff --git a/js/scripting-lang/baba-yaga-c/ROADMAP.md b/js/scripting-lang/baba-yaga-c/ROADMAP.md
new file mode 100644
index 0000000..963c46f
--- /dev/null
+++ b/js/scripting-lang/baba-yaga-c/ROADMAP.md
@@ -0,0 +1,143 @@
+# Baba Yaga C Implementation Roadmap
+
+## Current Status
+- ✅ **Core Language**: Complete and stable (25/27 tests passing)
+- ✅ **Table Pattern Matching**: Fixed and working
+- ✅ **When Expressions**: Fixed and working
+- ✅ **Computed Table Keys**: Fixed and working (Task 1.1 complete)
+- ✅ **Multi-value Pattern Expressions**: Fixed and working (Task 1.2 complete)
+- ✅ **Pattern Matching Memory**: Fixed and working (Task 1.3 complete)
+- ✅ **Partial Application Support**: Fixed and working (Task 2.3 complete)
+- ❌ **2 Remaining Issues**: Test 22 parser issue, Integration Test 02 file reading issue
+
+## Quick Reference
+- **Test Command**: `./bin/baba-yaga tests/22_parser_limitations.txt`
+- **Key Files**: `src/parser.c` (parser_parse_when_pattern), `tests/22_parser_limitations.txt`
+- **Current Error**: `Parse error: Expected 'is' after test expression`
+- **Working Test**: `echo "test_multi_expr : x y -> when (x % 2) (y % 2) is 0 0 then \"both even\";" | ./bin/baba-yaga`
+
+## Implementation Plan
+
+### **Phase 1: Core Language Features** ✅ **COMPLETE**
+All core language features are now working correctly.
+
+### **Phase 2: Advanced Features** ✅ **COMPLETE**
+All advanced features including partial application are now working.
+
+### **Phase 3: Final Polish** 🔄 **IN PROGRESS**
+
+#### **Task 3.1: Test 22 Parser Issue** (Test 22) 🔍 **INVESTIGATED**
+**Issue**: `Parse error: Expected 'is' after test expression`
+**Current**: Core multi-value pattern functionality works correctly
+**Status**: Identified specific parser edge case - needs investigation
+
+**Investigation Findings**:
+- ✅ **Individual functions work**: Multi-value patterns parse and execute correctly when tested individually
+- ✅ **Isolated syntax works**: Same syntax works perfectly when tested via `echo`
+- ❌ **File-specific issue**: The error only occurs when the complete test file is processed
+- 🔍 **Parser edge case**: The issue appears to be in how the parser handles multiple patterns in sequence within a file context
+- 📍 **Error location**: Parser fails to recognize the `is` keyword in multi-value pattern context when processing the full file
+
+**Root Cause Analysis**:
+- The parser's `parser_parse_when_pattern` function may have an edge case when processing multiple patterns in sequence
+- The error suggests the parser is not correctly transitioning between pattern parsing states
+- This is likely a subtle parsing state management issue rather than a fundamental syntax problem
+
+#### **Task 3.2: Integration Test 02 File Reading** (Integration Test 02)
+**Issue**: Segmentation fault when reading file directly (works when piped)
+**Current**: Core pattern matching works, but file reading has issue
+**Status**: Need to fix file reading mechanism
+
+## **Recent Achievements**
+
+### **Task 2.3: Partial Application Support** ✅ **COMPLETE**
+- **Issue**: Test 17 failed with partial application and arity errors
+- **Solution**: Implemented proper partial application in function call mechanism
+- **Implementation**: 
+  - Modified `baba_yaga_function_call` to handle partial application
+  - Created `stdlib_partial_apply` helper function
+  - Updated `each` function to support partial application
+- **Result**: Test 17 now passes, 25/27 tests passing
+
+### **Task 1.2: Multi-value Pattern Expressions** ✅ **COMPLETE**
+- **Issue**: `when (x % 2) (y % 2) is` not supported
+- **Solution**: Enhanced parser to handle expressions in parentheses for multi-parameter patterns
+- **Implementation**: Added detection for multi-parameter patterns with expressions
+- **Result**: Multi-value pattern expressions now work correctly
+
+### **Task 1.3: Pattern Matching Memory** ✅ **COMPLETE**
+- **Issue**: Segmentation fault in complex pattern matching
+- **Solution**: Implemented sequence-to-sequence pattern matching for multi-parameter patterns
+- **Implementation**: Added element-by-element comparison logic for multi-parameter patterns
+- **Result**: Complex nested pattern matching now works correctly
+
+## **Next Priority**
+**Task 3.1**: Fix Test 22 parser edge case to achieve 26/27 tests passing
+**Task 3.2**: Fix Integration Test 02 file reading issue to achieve 27/27 tests passing
+
+## **Integration Test 02 Segfault Investigation**
+
+### Findings So Far
+- Recursive function calls (e.g., `factorial 5`) cause a segmentation fault **only when run from a file**, not when piped via `cat` or `echo`.
+- Non-recursive function calls, arithmetic, and function definitions all work as expected.
+- The segfault occurs instantly, not after deep recursion (not a stack overflow).
+- The function is defined in the global scope, and recursive lookup should work.
+- The bug is **not** in the recursion logic itself.
+
+### Hypothesis
+- The root cause is likely a memory or buffer issue in file reading, string handling, or tokenization.
+- There may be a difference in how the source buffer is loaded from a file vs. piped input (e.g., BOM, encoding, or invisible characters).
+
+### Next Steps
+1. Add debug output to print the raw contents of the buffer loaded by `read_file()` for `tests/integration_02_pattern_matching.txt` before it is passed to the interpreter.
+2. Compare the buffer content from file vs. piped input.
+3. Check for buffer overflows, uninitialized memory, or off-by-one errors in file reading and tokenization.
+4. Check for non-ASCII, BOM, or invisible characters in the test file.
+
+---
+
+## Technical Notes
+
+### **Partial Application Implementation**
+- **Function Call Mechanism**: Modified `baba_yaga_function_call` to detect insufficient arguments
+- **Partial Function Creation**: Creates new function with bound arguments stored in scope
+- **Argument Combination**: `stdlib_partial_apply` combines bound and new arguments
+- **Scope Management**: Uses temporary scope variables to store partial application data
+
+### **Pattern Matching Enhancements**
+- **Multi-parameter Support**: Handles `when (expr1) (expr2) is` syntax
+- **Sequence Comparison**: Element-by-element comparison for multi-value patterns
+- **Wildcard Support**: `_` pattern matches any value in multi-parameter contexts
+
+### **Parser Investigation Results**
+- **Multi-value patterns work correctly** in isolation and individual function definitions
+- **File processing edge case** identified in `parser_parse_when_pattern` function
+- **State management issue** suspected when processing multiple patterns in sequence
+- **Error occurs specifically** when the complete test file is processed, not in isolated tests
+
+### **Memory Management**
+- **Reference Counting**: Proper cleanup of function references
+- **Scope Cleanup**: Automatic cleanup of temporary scope variables
+- **Error Handling**: Graceful handling of memory allocation failures
+
+## Next Action
+**Continue with Task 3.1** (Test 22 Parser Issue) - investigate and fix the parser edge case in `parser_parse_when_pattern` function to achieve 26/27 tests passing.
+
+## Implementation Guide
+
+### **For Task 3.1: Test 22 Parser Issue**
+1. **Investigate `parser_parse_when_pattern` function**: Look for state management issues when processing multiple patterns
+2. **Debug the specific failing case**: Add debug output to understand why the parser fails to recognize `is` keyword
+3. **Fix the parser logic**: Update the parser to handle the edge case correctly
+4. **Test the fix**: Verify that Test 22 now passes
+
+### **For Task 3.2: Integration Test 02 File Reading**
+1. **Investigate the file reading issue**: Compare direct file reading vs piped input
+2. **Identify the root cause**: Find why direct file reading causes segmentation fault
+3. **Fix the file reading mechanism**: Update the file reading code to handle the issue
+4. **Test the fix**: Verify that Integration Test 02 now passes
+
+### **For CLI Ergonomics**
+1. **Simplify the REPL**: Make it more minimal and interactive
+2. **Improve error messages**: Better error reporting and debugging
+3. **Add helpful features**: Command history, line editing, etc.
\ No newline at end of file
tter Grzegorz Adam Hankiewicz <gradha@imap.cc> 2014-07-27 22:48:40 +0200 Documents nimcache file naming scheme. Refs #852.' href='/ahoang/Nim/commit/doc/nimrodc.txt?h=devel&id=2ade6ab94da40043186fbc2fbbf038c0f497b4e4'>2ade6ab94 ^
dbf9117c5 ^
2ade6ab94 ^

f9b3f7f98 ^


































f0dd96fa5 ^

dbf9117c5 ^
f9b3f7f98 ^




f0dd96fa5 ^





f9b3f7f98 ^

















752cddb91 ^














559980c89 ^
752cddb91 ^

f9b3f7f98 ^
752cddb91 ^
f9b3f7f98 ^

4aba7421f ^
1785c6877 ^
9fbee85cc ^
d43febf81 ^
4c7c612ef ^
752cddb91 ^

f9b3f7f98 ^













































































6bab7a5bd ^

61ded5ab6 ^
6bab7a5bd ^

dbf9117c5 ^
6bab7a5bd ^




dbf9117c5 ^
6bab7a5bd ^



61ded5ab6 ^
6bab7a5bd ^

dbf9117c5 ^
6bab7a5bd ^




dbf9117c5 ^
6bab7a5bd ^


f9b3f7f98 ^













0a0b74bc2 ^
f9b3f7f98 ^



0a0b74bc2 ^
f9b3f7f98 ^

fdf996925 ^



f9b3f7f98 ^

dbe71c715 ^





f9b3f7f98 ^
9ed984201 ^
dbe71c715 ^
f9b3f7f98 ^
dbe71c715 ^

f9b3f7f98 ^


















dbe71c715 ^
f9b3f7f98 ^





dbe71c715 ^
f9b3f7f98 ^


dbe71c715 ^










f9b3f7f98 ^
dbe71c715 ^
f9b3f7f98 ^
dbe71c715 ^








































































































































f9b3f7f98 ^


9ed984201 ^




f9b3f7f98 ^







































139562cc6 ^




dbf9117c5 ^
f9b3f7f98 ^
139562cc6 ^

dbf9117c5 ^
139562cc6 ^




132b6b3ef ^




61ded5ab6 ^
132b6b3ef ^


dbf9117c5 ^
132b6b3ef ^
f9b3f7f98 ^
132b6b3ef ^
f9b3f7f98 ^









































c085a1b4f ^




f9b3f7f98 ^
c085a1b4f ^
61ded5ab6 ^
c085a1b4f ^



dbf9117c5 ^
6a2bb0058 ^








dbf9117c5 ^
6a2bb0058 ^

dbf9117c5 ^

91ae5a358 ^
dbf9117c5 ^
91ae5a358 ^


f9b3f7f98 ^





















752cddb91 ^

dbf9117c5 ^

752cddb91 ^
dbe71c715 ^
559980c89 ^
752cddb91 ^


f9b3f7f98 ^
752cddb91 ^

52851b722 ^
f9b3f7f98 ^
dbf9117c5 ^
52851b722 ^
dbe71c715 ^


52851b722 ^
f9b3f7f98 ^
7e7c514df ^
dbf9117c5 ^

7e7c514df ^
f9b3f7f98 ^
7e7c514df ^

f9b3f7f98 ^




















































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869