Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SANY handles operator precedence incorrectly with the negative prefix operator #893

Open
ahelwer opened this issue Mar 19, 2024 · 0 comments
Labels
SANY Issues involving SANY's analysis Tools The command line tools - TLC, SANY, ...

Comments

@ahelwer
Copy link
Contributor

ahelwer commented Mar 19, 2024

Regardless of operator precedence values, there is no parse ambiguity when an infix operator has a prefix operator on its right hand side:

---- MODULE Test ----
ASSUME A & ~B
====

For all prefix operators except for negative, SANY follows this rule. The precedence range of the negative prefix operator is 12-12. Every infix operator of precedence 13 or greater (about a quarter of them) will generate a parse conflict where there should not be one; for example:

---- MODULE Test ----
ASSUME A & -B
====

There is no parse ambiguity here and yet SANY outputs a parse error:

****** SANY2 Version 2.2 created 08 July 2020

Parsing file /home/ahelwer/src/tlaplus/java-tools/tlatools/org.lamport.tlatools/Test.tla
Beginning Module definition
Beginning Begin module
Ending Begin module
Beginning Extends
Ending Extends
Beginning Module body
Beginning Definition
Beginning Identifier LHS
Ending Identifier LHS
Beginning Expression
Beginning ExtendableExpr
Beginning Primitive expression
Ending Primitive expression
Beginning Infix Op
Ending Infix Op
Beginning Infix Op
Ending Infix Op
***Parse Error***

  Precedence conflict between ops & in block line 2, col 9 to line 2, col 9 of module Test and -..

Residual stack trace follows:
ExtendableExpr starting at line 2, column 7.
Expression starting at line 2, column 7.
Definition starting at line 2, column 1.
Module body starting at line 2, column 1.
Module definition starting at line 1, column 1.


Fatal errors while parsing TLA+ spec in file Test.tla

tla2sany.semantic.AbortException
*** Abort messages: 1

In module Test

Could not parse module Test from file Test.tla

I assume this is because SANY special-cases the negative prefix operator due to its alternative -. symbol-only presentation (for example, it shows up as "minus" in prefix op expressions in the parse tree) so the logic handling these types of expressions are different than with other prefix operators.

@lemmy lemmy added Tools The command line tools - TLC, SANY, ... SANY Issues involving SANY's analysis labels Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SANY Issues involving SANY's analysis Tools The command line tools - TLC, SANY, ...
Development

No branches or pull requests

2 participants