-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathoptions.h
More file actions
74 lines (60 loc) · 3.01 KB
/
options.h
File metadata and controls
74 lines (60 loc) · 3.01 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
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef THIRD_PARTY_CEL_CPP_PARSER_OPTIONS_H_
#define THIRD_PARTY_CEL_CPP_PARSER_OPTIONS_H_
#include "absl/base/attributes.h"
#include "parser/internal/options.h"
namespace cel {
// Options for configuring the limits and features of the parser.
struct ParserOptions final {
// Limit of the number of error recovery attempts made by the ANTLR parser
// when processing an input. This limit, when reached, will halt further
// parsing of the expression.
int error_recovery_limit = ::cel_parser_internal::kDefaultErrorRecoveryLimit;
// Limit on the amount of recusive parse instructions permitted when building
// the abstract syntax tree for the expression. This prevents pathological
// inputs from causing stack overflows.
int max_recursion_depth = ::cel_parser_internal::kDefaultMaxRecursionDepth;
// Limit on the number of codepoints in the input string which the parser will
// attempt to parse.
int expression_size_codepoint_limit =
::cel_parser_internal::kExpressionSizeCodepointLimit;
// Limit on the number of lookahead tokens to consume when attempting to
// recover from an error.
int error_recovery_token_lookahead_limit =
::cel_parser_internal::kDefaultErrorRecoveryTokenLookaheadLimit;
// Add macro calls to macro_calls list in source_info.
bool add_macro_calls = ::cel_parser_internal::kDefaultAddMacroCalls;
};
} // namespace cel
namespace google::api::expr::parser {
using ParserOptions = ::cel::ParserOptions;
ABSL_DEPRECATED("Use ParserOptions().error_recovery_limit instead.")
inline constexpr int kDefaultErrorRecoveryLimit =
::cel_parser_internal::kDefaultErrorRecoveryLimit;
ABSL_DEPRECATED("Use ParserOptions().max_recursion_depth instead.")
inline constexpr int kDefaultMaxRecursionDepth =
::cel_parser_internal::kDefaultMaxRecursionDepth;
ABSL_DEPRECATED("Use ParserOptions().expression_size_codepoint_limit instead.")
inline constexpr int kExpressionSizeCodepointLimit =
::cel_parser_internal::kExpressionSizeCodepointLimit;
ABSL_DEPRECATED(
"Use ParserOptions().error_recovery_token_lookahead_limit instead.")
inline constexpr int kDefaultErrorRecoveryTokenLookaheadLimit =
::cel_parser_internal::kDefaultErrorRecoveryTokenLookaheadLimit;
ABSL_DEPRECATED("Use ParserOptions().add_macro_calls instead.")
inline constexpr bool kDefaultAddMacroCalls =
::cel_parser_internal::kDefaultAddMacroCalls;
} // namespace google::api::expr::parser
#endif // THIRD_PARTY_CEL_CPP_PARSER_OPTIONS_H_