Repository navigation
Expand file tree
/
Copy pathparse.textproto
More file actions
176 lines (175 loc) · 9.2 KB
/
Copy pathparse.textproto
File metadata and controls
176 lines (175 loc) · 9.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# proto-file: ../../../proto/cel/expr/conformance/test/simple.proto
# proto-message: cel.expr.conformance.test.SimpleTestFile
name: "parse"
description: "End-to-end parsing tests."
section {
name: "nest"
description: "Deep parse trees which all implementations must support."
test {
name: "list_index"
description: "Member = Member '[' Expr ']'. Nested indices are supported up to 12 times."
expr: "a[a[a[a[a[a[a[a[a[a[a[a[0]]]]]]]]]]]]"
type_env {
name: "a"
ident { type { list_type { elem_type { primitive: INT64 } } } }
}
bindings {
key: "a"
value { value { list_value { values { int64_value: 0 } } } }
}
value { int64_value: 0 }
}
test {
name: "message_literal"
description: "Member = Member '{' [FieldInits] '}'. Nested messages supported up to 12 levels deep."
container: "cel.expr.conformance.proto3"
expr: "NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{child: NestedTestAllTypes{payload: TestAllTypes{single_int64: 137}}}}}}}}}}}}.payload.single_int64"
value { int64_value: 0 }
}
test {
name: "funcall"
description: "Primary = ['.'] IDENT ['(' [ExprList] ')']. Nested function calls supported up to 12 levels deep."
expr: "int(uint(int(uint(int(uint(int(uint(int(uint(int(uint(7))))))))))))"
value { int64_value: 7 }
}
test {
name: "list_literal"
description: "Primary = '[' [ExprList] ']'. Nested list literals up to 12 levels deep."
expr: "size([[[[[[[[[[[[0]]]]]]]]]]]])"
value { int64_value: 1 }
}
test {
name: "map_literal"
description: "Primary = '{' [MapInits] '}'. Nested map literals up to 12 levels deep."
expr: "size({0: {0: {0: {0: {0: {0: {0: {0: {0: {0: {0: {0: 'foo'}}}}}}}}}}}})"
value { int64_value: 1 }
}
test {
name: "parens"
description: "Primary = '(' Expr ')'"
expr: "((((((((((((((((((((((((((((((((7))))))))))))))))))))))))))))))))"
value { int64_value: 7 }
}
}
section {
name: "repeat"
description: "Repetitive parse trees which all implementations must support."
test {
name: "conditional"
description: "Expr = ConditionalOr ['?' ConditionalOr ':' Expr]. Chained ternary operators up to 24 levels."
expr: "true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : true ? true : false"
value { bool_value: true }
}
test {
name: "or"
description: "ConditionalOr = [ConditionalOr '||'] ConditionalAnd. Logical OR statements with 32 conditions."
expr: "false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || false || true"
value { bool_value: true }
}
test {
name: "and"
description: "ConditionalAnd = [ConditionalAnd '&&'] Relation. Logical AND statements with 32 conditions."
expr: "true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && true && false"
value { bool_value: false }
}
test {
name: "add_sub"
description: "Addition = [Addition ('+' | '-')] Multiplication. Addition operators are supported up to 24 times consecutively."
expr: "3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3 - 3 + 3"
value { int64_value: 3 }
}
test {
name: "mul_div"
description: "Multiplication = [Multiplication ('*' | '/' | '%')] Unary. Multiplication operators are supported up to 24 times consecutively."
expr: "4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4 * 4 / 4"
value { int64_value: 4 }
}
test {
name: "not"
description: "Unary = '!' {'!'} Member"
expr: "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!true"
value { bool_value: true }
}
test {
name: "unary_neg"
description: "Unary = '-' {'-'} Member"
expr: "--------------------------------19"
value { int64_value: 19 }
}
test {
name: "select"
description: "Member = Member '.' IDENT ['(' [ExprList] ')']. Selection is supported up to 12 times consecutively."
container: "cel.expr.conformance.proto3"
expr: "NestedTestAllTypes{}.child.child.child.child.child.child.child.child.child.child.payload.single_int32"
value { int64_value: 0 }
}
test {
name: "index"
description: "Member = Member '[' Expr ']'. Indexing is supported up to 12 times consecutively."
expr: "[[[[[[[[[[[['foo']]]]]]]]]]]][0][0][0][0][0][0][0][0][0][0][0][0]"
value { string_value: "foo" }
}
test {
name: "list_literal"
description: "Primary = '[' [ExprList] ']'. List literals with up to 32 elements."
expr: "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31][17]"
value { int64_value: 17 }
}
test {
name: "map_literal"
description: "Primary = '{' [MapInits] '}'. Map literals with up to 32 entries."
expr: "{0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 21: 'twenty-one', 22: 'twenty-two', 23: 'twenty-three', 24: 'twenty-four', 25: 'twenty-five', 26: 'twenty-six', 27: 'twenty-seven', 28: 'twenty-eight', 29: 'twenty-nine', 30: 'thirty', 31: 'thirty-one'}[17]"
value { string_value: 'seventeen' }
}
test {
name: "message_literal"
description: "Member = Member '{' [FieldInits] '}'. Message literals with up to 32 fields."
container: "cel.expr.conformance.proto3"
expr: "TestAllTypes{single_int32: 5, single_int64: 10, single_uint32: 15u, single_uint64: 20u, single_sint32: 25, single_sint64: 30, single_fixed32: 35u, single_fixed64: 40u, single_float: 45.0, single_double: 50.0, single_bool: true, single_string: 'sixty', single_bytes: b'sixty-five', single_value: 70.0, single_int64_wrapper: 75, single_int32_wrapper: 80, single_double_wrapper: 85.0, single_float_wrapper: 90.0, single_uint64_wrapper: 95u, single_uint32_wrapper: 100u, single_string_wrapper: 'one hundred five', single_bool_wrapper: true, repeated_int32: [115], repeated_int64: [120], repeated_uint32: [125u], repeated_uint64: [130u], repeated_sint32: [135], repeated_sint64: [140], repeated_fixed32: [145u], repeated_fixed64: [150u], repeated_sfixed32: [155], repeated_float: [160.0]}.single_sint64"
value { int64_value: 30 }
}
}
section {
name: "whitespace"
description: "Check that whitespace is ignored by the grammar."
test {
name: "spaces"
description: "Check that spaces are ignored."
expr: "[ . cel. expr .conformance. proto3. TestAllTypes { single_int64 : int ( 17 ) } . single_int64 ] [ 0 ] == ( 18 - 1 ) && ! false ? 1 : 2"
value { int64_value: 1 }
}
test {
name: "tabs"
description: "Check that tabs (`\\t`) are ignored."
expr: "[\t.\tcel.\texpr\t.conformance.\tproto3.\tTestAllTypes\t{\tsingle_int64\t:\tint\t(\t17\t)\t}\t.\tsingle_int64\t]\t[\t0\t]\t==\t(\t18\t-\t1\t)\t&&\t!\tfalse\t?\t1\t:\t2"
value { int64_value: 1 }
}
test {
name: "new_lines"
description: "Check that new lines (`\\n`) are ignored."
expr: "[\n.\ncel.\nexpr\n.conformance.\nproto3.\nTestAllTypes\n{\nsingle_int64\n:\nint\n(\n17\n)\n}\n.\nsingle_int64\n]\n[\n0\n]\n==\n(\n18\n-\n1\n)\n&&\n!\nfalse\n?\n1\n:\n2"
value { int64_value: 1 }
}
test {
name: "new_pages"
description: "Check that new pages (`\\f`) are ignored."
expr: "[\f.\fcel.\fexpr\f.conformance.\fproto3.\fTestAllTypes\f{\fsingle_int64\f:\fint\f(\f17\f)\f}\f.\fsingle_int64\f]\f[\f0\f]\f==\f(\f18\f-\f1\f)\f&&\f!\ffalse\f?\f1\f:\f2"
value { int64_value: 1 }
}
test {
name: "carriage_returns"
description: "Check that carriage returns (`\\r`) are ignored."
expr: "[\r.\rcel.\rexpr\r.conformance.\rproto3.\rTestAllTypes\r{\rsingle_int64\r:\rint\r(\r17\r)\r}\r.\rsingle_int64\r]\r[\r0\r]\r==\r(\r18\r-\r1\r)\r&&\r!\rfalse\r?\r1\r:\r2"
value { int64_value: 1 }
}
}
section {
name: "comments"
description: "Check that comments are ignored by the grammar. Note that carriage returns alone cannot terminate comments."
test {
name: "new_line_terminated"
description: "Check that new-line-terminated comments are ignored."
expr: "[// @\n.// @\ncel.// @\nexpr// @\n.conformance.// @\nproto3.// @\nTestAllTypes// @\n{// @\nsingle_int64// @\n:// @\nint// @\n(// @\n17// @\n)// @\n}// @\n.// @\nsingle_int64// @\n]// @\n[// @\n0// @\n]// @\n==// @\n(// @\n18// @\n-// @\n1// @\n)// @\n&&// @\n!// @\nfalse// @\n?// @\n1// @\n:// @\n2"
value { int64_value: 1 }
}
}