Skip to content

feat(compiler): ternary conditional operator cond ? a : b (Wave 56, R-CG-5) - #826

Closed
gHashTag wants to merge 2 commits into
masterfrom
feat/wave-56/ternary-operator
Closed

gHashTag wants to merge 2 commits into
masterfrom
feat/wave-56/ternary-operator

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

Closes #825

Wave 56 — R-CG-5: Ternary conditional operator cond ? a : b

What changed

  • TokenKind::Question + NodeKind::ExprTernary
  • ? added to lexer single-char scanner
  • Parser: right-associative, lowest expression precedence
  • Verilog/C/Zig: cond ? a : b
  • Rust: if cond { a } else { b }

Example

pub fn clamp(val: u8, lo: u8, hi: u8) -> u8 {
    return val < lo ? lo : (val > hi ? hi : val)
}

Test results

9 new tests. All pass.

claude added 2 commits May 24, 2026 13:31
…#823)

Wave 55 adds ExprConcat: {a, b, c} for Verilog bit concatenation.
- Verilog: emits {a, b, c} (native concatenation)
- C/Rust: emits /* concat(a, b, c) */ 0 (width-aware shift+or deferred)
- Parser distinguishes {expr, expr} from struct literal Name{field: val}
- Supports nested concatenation {{a, b}, c}

11 new tests (parse, Verilog, C, Rust, nested, assignment, literals).
All pass.
…oses #825)

Wave 56 adds ExprTernary: cond ? a : b for concise conditional expressions.
- Verilog/C/Zig: emit cond ? a : b (native ternary)
- Rust: emit if cond { a } else { b } (idiomatic)
- Right-associative: a ? x : b ? y : z parses correctly
- Works with comparisons: val < lo ? lo : val

9 new tests (parse, 4 backends, nested, assignment, comparison, right-assoc).
All pass.
This was referenced May 24, 2026
@gHashTag

Copy link
Copy Markdown
Owner Author

Закрываю в рамках уборки backlog. Этот PR — часть последовательного стека host-драйвера (Wave 40–98), который был заброшен после 2026-05-24; проект переключился на numeric-SSOT работу (#914–#977). PR конфликтует с master (общие файлы host/mod.rs, main.rs, compiler.rs, docs/NOW.md) и не может быть смержен в исходном виде. При необходимости работу можно переоткрыть и заново отребейзить от master. Ветка сохраняется.

@gHashTag gHashTag closed this May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ternary conditional operator cond ? a : b (R-CG-5)

2 participants