mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
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>
79 lines
2.1 KiB
YAML
79 lines
2.1 KiB
YAML
# Copyright (c) Microsoft Corporation.
|
|
# Licensed under the MIT License.
|
|
|
|
cases:
|
|
- note: basic
|
|
rego: |
|
|
package test
|
|
import future.keywords.in
|
|
|
|
x = 5 in [4, 5]
|
|
|
|
# in-exprs are left associative and ahve lower-precedence than bin-expr.
|
|
# The following will be parsed as
|
|
# (5 in [4, 5]) in (set() | {true})
|
|
z = 5 in [4, 5] in set() | {true}
|
|
num_expressions: 21
|
|
num_statements: 0
|
|
num_queries: 0
|
|
policy:
|
|
- spec:
|
|
head:
|
|
compr:
|
|
refr:
|
|
var: x
|
|
eidx: 4
|
|
assign:
|
|
op: "="
|
|
value:
|
|
inexpr:
|
|
value:
|
|
number: 5
|
|
eidx: 5
|
|
collection:
|
|
array:
|
|
- number: 4
|
|
eidx: 6
|
|
- number: 5
|
|
eidx: 7
|
|
eidx: 8
|
|
eidx: 9
|
|
bodies: []
|
|
- spec:
|
|
head:
|
|
compr:
|
|
refr:
|
|
var: z
|
|
eidx: 10
|
|
assign:
|
|
op: "="
|
|
value:
|
|
inexpr:
|
|
value:
|
|
inexpr:
|
|
value:
|
|
number: 5
|
|
eidx: 11
|
|
collection:
|
|
array:
|
|
- number: 4
|
|
eidx: 12
|
|
- number: 5
|
|
eidx: 13
|
|
eidx: 14
|
|
eidx: 15
|
|
collection:
|
|
binexpr:
|
|
op: "|"
|
|
lhs:
|
|
set: []
|
|
eidx: 16
|
|
rhs:
|
|
set:
|
|
- bool: true
|
|
eidx: 17
|
|
eidx: 18
|
|
eidx: 19
|
|
eidx: 20
|
|
bodies: []
|