Files
regorus/tests/parser/cases/expressions/membership.yaml
Anand Krishnamoorthi 444b2970a1 feat!: Indexes for nodes in the AST (#414)
Indexes allow associating extra data with nodes in the AST
using an array and then quickly looking up the array to fetch
the extra data.

- Index eidx for expressions
- Index sidx for statements
- Index qidx for queries.

AST nodes are not cloneable. Therefore once a module is created,
it is not possible to accidentally create two nodes with the same
index inadvertently via clone.

Also added IndexChecker in debug builds. When a module is parsed,
it will assert that indexes have been constructed correctly.

AST Cleanup
- Make literal expressions (null, val, number, string etc) also structs
  to match all other expressions
- Merge True and False nodes into a single Bool node.

Also update dependencies.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2025-06-20 15:09:07 -05:00

67 lines
1.6 KiB
YAML

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
cases:
- note: basic
rego: |
package test
import future.keywords.in
# key, value in collection
x = 0, 5 in [5]
# Chained in-exprs
y = 0, 5 in c in d
num_expressions: 17
policy:
- spec:
head:
compr:
refr:
var: x
eidx: 4
assign:
op: "="
value:
inexpr:
key:
number: 0
eidx: 5
value:
number: 5
eidx: 6
collection:
array:
- number: 5
eidx: 7
eidx: 8
eidx: 9
bodies: []
- spec:
head:
compr:
refr:
var: y
eidx: 10
assign:
op: "="
value:
inexpr:
value:
inexpr:
key:
number: 0
eidx: 11
value:
number: 5
eidx: 12
collection:
var: c
eidx: 13
eidx: 14
collection:
var: d
eidx: 15
eidx: 16
bodies: []