Skip to content

grammar: Update to support and and or keywords - #212

Merged
charlieegan3 merged 1 commit into
masterfrom
grammar-and-or-keywords
Aug 12, 2026
Merged

grammar: Update to support and and or keywords#212
charlieegan3 merged 1 commit into
masterfrom
grammar-and-or-keywords

Conversation

@sspaink

@sspaink sspaink commented Aug 11, 2026

Copy link
Copy Markdown
Member

Adds the new and / or logical keywords to the lexer and grammar with the precedence from open-policy-agent/opa#8677 (not > and > or > with), supporting single-expression, explicit-body and parenthesized operands; this is the IDEA item of open-policy-agent/opa#8999.

Both keywords are also accepted as identifiers, since they stay identifiers in policies that do not import them, and not is now accepted after a dot in a ref so that import future.keywords.not parses.

Adds the `and` and `or` logical keywords from open-policy-agent/opa#8999
to the lexer and grammar, following the precedence defined in
open-policy-agent/opa#8677: `not` > `and` > `or` > `with`.

Operands can be a single expression (`a or b`), an explicit body
(`{a} or {b; c}`) or a parenthesized group (`(a or b) and c`). A `{...}`
operand is only read as a body when an `and`/`or` follows it, so sets,
objects and rule bodies keep parsing as before. A trailing `with`
applies to the whole expression.

Both keywords are also accepted as identifiers, as they remain
identifiers in policies that do not import them, and `not` is accepted
after a dot in a ref so that `import future.keywords.not` parses.

Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
@charlieegan3
charlieegan3 merged commit c474cf0 into master Aug 12, 2026
6 checks passed
@charlieegan3
charlieegan3 deleted the grammar-and-or-keywords branch August 12, 2026 15:22
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