Add support for the and and or logical operators - #26
Open
sspaink wants to merge 1 commit into
Open
Conversation
Adds the OPA future keywords `and` and `or` to the grammar at the literal level rather than inside `expr`, since they combine bodies rather than terms. Precedence, tightest first: not > and > or > with. Both operators are left-associative, and `logical_group` allows parenthesized regrouping such as `(a or b) and c`. A parenthesized `with` is also a group: a trailing modifier binds to the whole logical expression, and OPA rejects `a with x as y and b` at parse time, so parens are the only way to scope a modifier to a single operand (`(a with x as y) and b`) — `opa fmt` preserves them for that reason. Requiring a with-modifier there keeps the group disjoint from the existing expr-parens term, so `(a)` and `(not a)` remain ordinary parenthesized expressions. Includes the v1 comp+if variants (`logical_and_v1` / `logical_or_v1`), highlight queries for the new keywords, and a corpus of tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the OPA future keywords
andandor(https://github.com/open-policy-agent/opa/milestone/1), which is planned to be in the next release (v1.20.0). So getting IDE support ready.Part of open-policy-agent/opa#8999, were we are tracking the other places this update is needed e.g. open-policy-agent/vscode-opa#482