@@ -77,18 +77,18 @@ Unary = Member
77
77
| "-" {"-"} Member
78
78
;
79
79
Member = Primary
80
- | Member "." IDENT ["(" [ExprList] ")"]
80
+ | Member "." SELECTOR ["(" [ExprList] ")"]
81
81
| Member "[" Expr "]"
82
82
;
83
83
Primary = ["."] IDENT ["(" [ExprList] ")"]
84
84
| "(" Expr ")"
85
85
| "[" [ExprList] [","] "]"
86
86
| "{" [MapInits] [","] "}"
87
- | ["."] IDENT { "." IDENT } "{" [FieldInits] [","] "}"
87
+ | ["."] SELECTOR { "." SELECTOR } "{" [FieldInits] [","] "}"
88
88
| LITERAL
89
89
;
90
90
ExprList = Expr {"," Expr} ;
91
- FieldInits = IDENT ":" Expr {"," IDENT ":" Expr} ;
91
+ FieldInits = SELECTOR ":" Expr {"," SELECTOR ":" Expr} ;
92
92
MapInits = Expr ":" Expr {"," Expr ":" Expr} ;
93
93
```
94
94
@@ -137,7 +137,8 @@ by the grammar. Please note, that in the lexer `[]` denotes a character range,
137
137
or one occurrence.
138
138
139
139
```
140
- IDENT ::= [_a-zA-Z][_a-zA-Z0-9]* - RESERVED
140
+ IDENT ::= SELECTOR - RESERVED
141
+ SELECTOR ::= [_a-zA-Z][_a-zA-Z0-9]* - KEYWORD
141
142
LITERAL ::= INT_LIT | UINT_LIT | FLOAT_LIT | STRING_LIT | BYTES_LIT
142
143
| BOOL_LIT | NULL_LIT
143
144
INT_LIT ::= -? DIGIT+ | -? 0x HEXDIGIT+
@@ -159,8 +160,8 @@ ESCAPE ::= \ [abfnrtv\?"'`]
159
160
| \ [0-3] [0-7] [0-7]
160
161
BOOL_LIT ::= "true" | "false"
161
162
NULL_LIT ::= "null"
162
- RESERVED ::= BOOL_LIT | NULL_LIT | "in"
163
- | "as" | "break" | "const" | "continue" | "else"
163
+ KEYWORD ::= BOOL_LIT | NULL_LIT | "in"
164
+ RESERVED ::= "as" | "break" | "const" | "continue" | "else"
164
165
| "for" | "function" | "if" | "import" | "let"
165
166
| "loop" | "package" | "namespace" | "return"
166
167
| "var" | "void" | "while"
@@ -174,13 +175,13 @@ without the `r` or `R` (raw) prefix process `ESCAPE` sequences, while in strings
174
175
with the raw prefix they stay uninterpreted. See documentation of string
175
176
literals below.
176
177
177
- The following identifiers are reserved due to their use as literal values or in
178
- the syntax :
178
+ The following language keywords are reserved and cannot be used as identifiers,
179
+ function names, selectors, struct name segments, or field names :
179
180
180
181
false in null true
181
182
182
- The following identifiers are reserved to allow easier embedding of CEL into a
183
- host language.
183
+ The following tokens are reserved to allow easier embedding of CEL into a host
184
+ language and cannot be used as identifiers or function names [ ^ function-names ] :
184
185
185
186
as break const continue else for function if import let loop package
186
187
namespace return var void while
@@ -189,6 +190,9 @@ In general it is a bad idea for those defining contexts or extensions to use
189
190
identifiers that are reserved words in programming languages which might embed
190
191
CEL.
191
192
193
+ [ ^ function-names ] : Except for receiver-call-style functions, e.g. ` a.package() ` ,
194
+ which is permitted.
195
+
192
196
### Name Resolution
193
197
194
198
A CEL expression is parsed in the scope of a specific protocol buffer package or
0 commit comments