Skip to content

Implement is not and not in operators - #454

Merged
cirras merged 3 commits into
masterfrom
delphi-13-operators
Aug 24, 2026
Merged

Implement is not and not in operators#454
cirras merged 3 commits into
masterfrom
delphi-13-operators

Conversation

@cirras

@cirras cirras commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

This PR implements the new binary operators added in Delphi 13.

In terms of parsing, operator precedence, and type resolution, this wasn't a difficult implementation. There were other challenges.

"Compound" operators with multiple tokens make previous AST modeling of binary and unary expression nodes a little tricky. The operators in these expressions are now modeled as their own typed child nodes.

This required me to build binary expressions a little differently, which made me drop the resetBinaryExpressionTokens fix introduced in 041a0d9. In doing so, I had to wrestle with node text range calculation for (probably) the 27th time. The new shape seems to work well.

Closes #408, #409.

@cirras
cirras requested a review from fourls August 10, 2026 06:19
@cirras cirras linked an issue Aug 10, 2026 that may be closed by this pull request
2 tasks
Comment thread delphi-frontend/src/main/antlr3/au/com/integradev/delphi/antlr/Delphi.g Outdated
Comment thread CHANGELOG.md
cirras added 3 commits August 13, 2026 14:16
Delphi treats a non-constant `{$IF}` condition expression as true, but
we were treating every unevaluable expression as false.

Unevaluable expressions now come in 2 flavors:
- `UNKNOWN` for badly-formed expressions or unresolvable references.
  Evaluates to false.
- `NON_CONSTANT` for well-formed non-constant expressions.
  Evaluates to true.
String ordering comparisons like `'foo' > 'bar'` previously evaluated to
an UNKNOWN expression in preprocessor directive expressions.
In terms of parsing, operator precedence, and type resolution, this
wasn't a difficult implementation. There were other challenges.

"Compound" operators with multiple tokens make previous AST modeling of
binary and unary expression nodes a little tricky. The operators in
these expressions are now modeled as their own typed child nodes.

This required me to build binary expressions a little differently, which
made me drop the `resetBinaryExpressionTokens` fix introduced in
041a0d9. In doing so, I had to wrestle with node text range calculation
for (probably) the 27th time. The new shape seems to work well.
@cirras
cirras force-pushed the delphi-13-operators branch from 4eecf1d to d933342 Compare August 13, 2026 04:26
@cirras
cirras requested a review from fourls August 13, 2026 04:32

@fourls fourls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@cirras
cirras merged commit c70c751 into master Aug 24, 2026
4 checks passed
@cirras
cirras deleted the delphi-13-operators branch August 24, 2026 01:54
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.

Support not in operator Support is not operator

2 participants