Skip to content

feat(ast): implement conditional expression (ternary ?:) - #64

Merged
rieske merged 1 commit into
masterfrom
feature/ternary-conditional-exp
Jul 24, 2026
Merged

feat(ast): implement conditional expression (ternary ?:)#64
rieske merged 1 commit into
masterfrom
feature/ternary-conditional-exp

Conversation

@rieske

@rieske rieske commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implement cond ? then : else via new ConditionalExpression AST node (grammar production already existed; CSNB threw).
  • Semantic analysis: type-check arms, result temp + falsy/exit labels; constant folding for global init.
  • Codegen: branch on condition, evaluate only the taken arm at runtime, join on exit label.
  • Functional tests: true/false, variables, nesting, expression context, side-effect arms, constant global init.

Stack

PR 1/6 of finish-for-git extraction (ternary → do-while → goto → switch → recursive Type → structs).

Test plan

  • Full local ctest
  • Ternary functional suite
  • CI green

Add ConditionalExpression AST node, CSNB builder for the existing
grammar production, and semantic/codegen/XML visitors. Functional tests
cover true/false arms, nesting, side-effect short-circuit, and constant
global init folding.
@mergify

mergify Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 92.199% (+0.1%) from 92.084% — feature/ternary-conditional-exp into master

@rieske
rieske merged commit e3b6cca into master Jul 24, 2026
4 checks passed
@rieske
rieske deleted the feature/ternary-conditional-exp branch July 24, 2026 07:03
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.

2 participants