Preprocessor: conditionals, includes and foreach #7

Closed
opened 2026-10-14 01:26:53 -05:00 by jeff · 1 comment
Owner

Parent

Part of #1

What to build

<?if?>, <?ifdef?>, <?ifndef?>, <?elseif?>, <?else?> and <?endif?> with WiX's expression language; <?include?> of .wxi files, searched relative to the including file and then in each -I directory, through the file source; and <?foreach?>. A diagnostic inside an included file names the file that included it and where, all the way up.

Acceptance criteria

  • Seam 2 tests for each conditional form, nested conditionals, and the comparison and logical operators WiX documents.
  • Seam 2 tests: an include found beside the including file, one found only through -I, and one found nowhere (a diagnostic).
  • Seam 2 test: an error two includes deep reports inner.wxi:L:C: … (included from middle.wxi:L, included from main.wxs:L).
  • Seam 2 test: <?foreach?> over a semicolon-separated list.
  • Unbalanced conditionals and recursive includes are diagnostics, not hangs or crashes.
  • zixl -E output matches wixl -E for a fixture using all of the above.
## Parent Part of #1 ## What to build `<?if?>`, `<?ifdef?>`, `<?ifndef?>`, `<?elseif?>`, `<?else?>` and `<?endif?>` with WiX's expression language; `<?include?>` of `.wxi` files, searched relative to the including file and then in each `-I` directory, through the file source; and `<?foreach?>`. A diagnostic inside an included file names the file that included it and where, all the way up. ## Acceptance criteria - [ ] Seam 2 tests for each conditional form, nested conditionals, and the comparison and logical operators WiX documents. - [ ] Seam 2 tests: an include found beside the including file, one found only through `-I`, and one found nowhere (a diagnostic). - [ ] Seam 2 test: an error two includes deep reports `inner.wxi:L:C: … (included from middle.wxi:L, included from main.wxs:L)`. - [ ] Seam 2 test: `<?foreach?>` over a semicolon-separated list. - [ ] Unbalanced conditionals and recursive includes are diagnostics, not hangs or crashes. - [ ] `zixl -E` output matches `wixl -E` for a fixture using all of the above.
jeff self-assigned this 2026-10-14 03:35:07 -05:00
Author
Owner

Done in c3a8dd1; CI run 7 is green.

  • Seam 2: tests/preprocess.zig covers:
    • every conditional form, including nested ones and ones inside a branch not taken;
    • every comparison and logical operator from WiX's documented expression examples;
    • includes found beside the including file, through -I, and nowhere;
    • an error two includes deep, reported as src/inner.wxi:4:9: … (included from src/middle.wxi:2, included from src/main.wxs:3);
    • foreach, nested, with nothing leaking out of it;
    • unclosed conditionals and loops, self-including files, and stray endif/else/endforeach, all as diagnostics.
  • Compile errors in included files carry the same chain.
  • zixl -E vs wixl -E: they agree on the subset wixl gets right, which is if/else, =, ~=, or, nesting, and includes found both ways.

Where zixl follows WiX's documentation over the reference implementation:

  • wixl rejects <?ifdef?> and never takes an <?elseif?> branch.
  • It evaluates not … and (…) wrongly, and treats a bare defined variable as false.
  • It doesn't check that a compared variable is defined.
  • It evaluates 3 < 2 as true.
  • It has no <?foreach?>.
Done in c3a8dd1; CI run 7 is green. - **Seam 2:** `tests/preprocess.zig` covers: - every conditional form, including nested ones and ones inside a branch not taken; - every comparison and logical operator from WiX's documented expression examples; - includes found beside the including file, through `-I`, and nowhere; - an error two includes deep, reported as `src/inner.wxi:4:9: … (included from src/middle.wxi:2, included from src/main.wxs:3)`; - `foreach`, nested, with nothing leaking out of it; - unclosed conditionals and loops, self-including files, and stray `endif`/`else`/`endforeach`, all as diagnostics. - **Compile errors** in included files carry the same chain. - **`zixl -E` vs `wixl -E`:** they agree on the subset wixl gets right, which is `if`/`else`, `=`, `~=`, `or`, nesting, and includes found both ways. Where zixl follows WiX's documentation over the reference implementation: - wixl rejects `<?ifdef?>` and never takes an `<?elseif?>` branch. - It evaluates `not … and (…)` wrongly, and treats a bare defined variable as false. - It doesn't check that a compared variable is defined. - It evaluates `3 < 2` as true. - It has no `<?foreach?>`.
jeff closed this issue 2026-10-14 04:13:00 -05:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
jeff/zixl#7
No description provided.