Coverage Report

Created: 2023-11-19 06:10

/proc/self/cwd/parser/parser.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2021 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef THIRD_PARTY_CEL_CPP_PARSER_PARSER_H_
16
#define THIRD_PARTY_CEL_CPP_PARSER_PARSER_H_
17
18
#include "google/api/expr/v1alpha1/syntax.pb.h"
19
#include "absl/status/statusor.h"
20
#include "absl/types/optional.h"
21
#include "parser/macro.h"
22
#include "parser/options.h"
23
#include "parser/source_factory.h"
24
25
namespace google::api::expr::parser {
26
27
class VerboseParsedExpr {
28
 public:
29
  VerboseParsedExpr(google::api::expr::v1alpha1::ParsedExpr parsed_expr,
30
                    EnrichedSourceInfo enriched_source_info)
31
      : parsed_expr_(std::move(parsed_expr)),
32
2.13k
        enriched_source_info_(std::move(enriched_source_info)) {}
33
34
2.13k
  const google::api::expr::v1alpha1::ParsedExpr& parsed_expr() const {
35
2.13k
    return parsed_expr_;
36
2.13k
  }
37
0
  const EnrichedSourceInfo& enriched_source_info() const {
38
0
    return enriched_source_info_;
39
0
  }
40
41
 private:
42
  google::api::expr::v1alpha1::ParsedExpr parsed_expr_;
43
  EnrichedSourceInfo enriched_source_info_;
44
};
45
46
absl::StatusOr<VerboseParsedExpr> EnrichedParse(
47
    absl::string_view expression, const std::vector<Macro>& macros,
48
    absl::string_view description = "<input>",
49
    const ParserOptions& options = ParserOptions());
50
51
absl::StatusOr<google::api::expr::v1alpha1::ParsedExpr> Parse(
52
    absl::string_view expression, absl::string_view description = "<input>",
53
    const ParserOptions& options = ParserOptions());
54
55
absl::StatusOr<google::api::expr::v1alpha1::ParsedExpr> ParseWithMacros(
56
    absl::string_view expression, const std::vector<Macro>& macros,
57
    absl::string_view description = "<input>",
58
    const ParserOptions& options = ParserOptions());
59
60
}  // namespace google::api::expr::parser
61
62
#endif  // THIRD_PARTY_CEL_CPP_PARSER_PARSER_H_