Commit ce86030
committed
Implement double bar (||) operator for partial string lists
Adds support for the double bar operator as specified in:
https://www.complang.tuwien.ac.at/ulrich/iso-prolog/double_bar
Changes:
- Lexer: Added DoubleBar token, detects || vs single |
- Parser: Handles "string"||Tail syntax with priority 1
- Validates that || only appears after string literals
- Rejects || after variables: K||[] => syntax_error
- Rejects || after parenthesized expressions: ("a")||[] => syntax_error
- Creates PartialString for non-empty strings
- Replaces list tail for code lists
- Empty strings correctly collapse (""||K unifies with K)
- Tests: Comprehensive Prolog integration tests covering:
- All spec examples including multi-line with comments
- Edge cases (empty strings, chaining)
- Syntax validation for all invalid cases
All Prolog tests pass. Examples:
- "abc"||K => [a,b,c|K]
- "a"||"b"||"c" => [a,b,c]
- ""||K => K
- "a"|| % comment
"b"||"c" => [a,b,c]
- K||[] => syntax_error (as required)
- ("a")||[] => syntax_error (as required)1 parent e4d9692 commit ce86030
File tree
4 files changed
+153
-1
lines changed- src
- parser
- tests
- tests/scryer/cli/src_tests
4 files changed
+153
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
1035 | 1036 | | |
1036 | 1037 | | |
1037 | 1038 | | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
1038 | 1044 | | |
1039 | 1045 | | |
1040 | 1046 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
312 | 314 | | |
313 | 315 | | |
314 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
315 | 334 | | |
316 | 335 | | |
317 | 336 | | |
| 337 | + | |
318 | 338 | | |
319 | 339 | | |
320 | 340 | | |
| |||
332 | 352 | | |
333 | 353 | | |
334 | 354 | | |
335 | | - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
336 | 377 | | |
337 | 378 | | |
338 | 379 | | |
| |||
422 | 463 | | |
423 | 464 | | |
424 | 465 | | |
| 466 | + | |
425 | 467 | | |
426 | 468 | | |
427 | 469 | | |
| |||
1041 | 1083 | | |
1042 | 1084 | | |
1043 | 1085 | | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
1044 | 1123 | | |
1045 | 1124 | | |
1046 | 1125 | | |
| |||
1051 | 1130 | | |
1052 | 1131 | | |
1053 | 1132 | | |
| 1133 | + | |
1054 | 1134 | | |
1055 | 1135 | | |
1056 | 1136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments