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>
137 lines
3.1 KiB
YAML
137 lines
3.1 KiB
YAML
# Copyright (c) Microsoft Corporation.
|
|
# Licensed under the MIT License.
|
|
|
|
cases:
|
|
- note: all
|
|
rego: |
|
|
package test
|
|
# One item
|
|
x = {1}
|
|
|
|
# Multiple items
|
|
y = [
|
|
2.5, "abc", [ 4, `raw`, # Trailing comma
|
|
],
|
|
# Empty array
|
|
[],
|
|
# Nested empty
|
|
[[[[[]]]]]
|
|
]
|
|
num_expressions: 17
|
|
num_statements: 0
|
|
num_queries: 0
|
|
policy:
|
|
- spec:
|
|
head:
|
|
compr:
|
|
refr:
|
|
var: x
|
|
eidx: 1
|
|
assign:
|
|
span: = {1}
|
|
op: "="
|
|
value:
|
|
set:
|
|
- number: 1
|
|
eidx: 2
|
|
eidx: 3
|
|
bodies: --skip--
|
|
|
|
- spec:
|
|
head:
|
|
compr:
|
|
refr:
|
|
var: y
|
|
eidx: 4
|
|
assign:
|
|
op: "="
|
|
value:
|
|
array:
|
|
- number: 2.5
|
|
eidx: 5
|
|
- string: abc
|
|
eidx: 6
|
|
- array:
|
|
- number: 4
|
|
eidx: 7
|
|
- rawstring: raw
|
|
eidx: 8
|
|
eidx: 9
|
|
- array: []
|
|
eidx: 10
|
|
- array:
|
|
- array:
|
|
- array:
|
|
- array:
|
|
- array: []
|
|
eidx: 11
|
|
eidx: 12
|
|
eidx: 13
|
|
eidx: 14
|
|
eidx: 15
|
|
eidx: 16
|
|
bodies: []
|
|
|
|
- note: trailing-comma
|
|
rego: |
|
|
package test
|
|
x = [1,]
|
|
y = [1,2
|
|
,]
|
|
num_expressions: 8
|
|
num_statements: 0
|
|
num_queries: 0
|
|
policy:
|
|
- spec:
|
|
head:
|
|
compr:
|
|
refr:
|
|
var: x
|
|
eidx: 1
|
|
assign:
|
|
op: "="
|
|
value:
|
|
array:
|
|
span: "[1,]"
|
|
values:
|
|
- number: 1
|
|
eidx: 2
|
|
eidx: 3
|
|
bodies: []
|
|
- spec:
|
|
head:
|
|
compr:
|
|
refr:
|
|
var: y
|
|
eidx: 4
|
|
assign:
|
|
op: "="
|
|
value:
|
|
array:
|
|
span: "[1,2\n,]"
|
|
values:
|
|
- number: 1
|
|
eidx: 5
|
|
- number: 2
|
|
eidx: 6
|
|
eidx: 7
|
|
bodies: []
|
|
|
|
- note: no-comma
|
|
rego: |
|
|
package test
|
|
x = [1 2]
|
|
error: expecting `]` while parsing array
|
|
|
|
- note: two-trailing-commas
|
|
rego: |
|
|
package test
|
|
x = [1,2,,]
|
|
error: expecting expression
|
|
|
|
- note: unclosed
|
|
rego: |
|
|
package test
|
|
x = [ 1
|
|
error: expecting `]` while parsing array
|