Skip to content

Support for chained comparisons#713

Merged
marcoeilers merged 9 commits into
masterfrom
meilers_chained_comp
Jul 13, 2023
Merged

Support for chained comparisons#713
marcoeilers merged 9 commits into
masterfrom
meilers_chained_comp

Conversation

@marcoeilers

@marcoeilers marcoeilers commented Jun 30, 2023

Copy link
Copy Markdown
Contributor

This PR adds support for chained comparisons as syntactic sugar.
I.e., e1 < e2 <= e3 > e4 can now be parsed and will be desugared to (e1 < e2) && (e2 <= e3) && (e3 > e4) .
The AST and ParseAST are unchanged.
Note that the in operator has the same behavior as the usual comparisons, so you can also write s1 in s2 in s3.
Parentheses can be used to force different parsing; e.g. (e1 < e2) <= e3 would not be seen as a chained comparison and would thus result in a type error (since there is a boolean value on the left hand side of a <= operator).

Additionally, this PR fixes the positions reported for other suffixed expressions. E.g., the position Viper reported for the expression e + e2 used to be the position of just the + e2 part (i.e., the suffix), without the first operand. Same for e.g. e.f.

Additionally, this PR adds a deprecation warning when the Rational type is used.

@marcoeilers marcoeilers requested a review from JonasAlaif July 4, 2023 11:38
@JonasAlaif

Copy link
Copy Markdown
Contributor

This will cause a merge conflict for my IDE changes where I fixed the position of suffixed stuff too 😢

@marcoeilers

Copy link
Copy Markdown
Contributor Author

This will cause a merge conflict for my IDE changes where I fixed the position of suffixed stuff too cry

Ah crap :/

@JonasAlaif

JonasAlaif commented Jul 12, 2023

Copy link
Copy Markdown
Contributor

At least I've essentially already done a good review for that part and I can compare our two solutions :P

@JonasAlaif

Copy link
Copy Markdown
Contributor

@marcoeilers looks good, I cleaned up some things up in the PR. If you're happy with my changes then we can merge

@marcoeilers marcoeilers merged commit d769c1e into master Jul 13, 2023
@marcoeilers marcoeilers deleted the meilers_chained_comp branch July 13, 2023 13:33
@marcoeilers marcoeilers mentioned this pull request Jul 17, 2023
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