• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
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  * http://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 
16 #ifndef PANDA_VERIFIER_DEBUG_METHOD_GROUP_PARSER_H_
17 #define PANDA_VERIFIER_DEBUG_METHOD_GROUP_PARSER_H_
18 
19 #include "verification/util/parser/parser.h"
20 #include "runtime/include/mem/panda_string.h"
21 
22 namespace ark::verifier {
23 
24 template <typename Parser, typename RegexHandler>
MethodGroupParser(RegexHandler & regexHandler)25 const auto &MethodGroupParser(RegexHandler &regexHandler)
26 {
27     using ark::parser::Action;
28     using ark::parser::Charset;
29     // using ark::parser::Parser;
30 
31     struct MethodGroup;
32 
33     using P = typename Parser::template Next<MethodGroup>;
34     using P1 = typename P::P;
35 
36     static const auto QUOTE = P::OfString("'");
37     static const auto NON_QUOTES = P1::OfCharset(!Charset("'"));
38 
39     static const auto REGEX_HANDLER = [&regexHandler](Action a, typename P::Ctx &c, auto from, auto to) {
40         if (a == Action::PARSED) {
41             auto *start = from;
42             // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
43             ++start;
44             auto *end = to;
45             // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
46             --end;
47             return regexHandler(c, PandaString {start, end});
48         }
49         return true;
50     };
51 
52     static const auto REGEX = QUOTE >> NON_QUOTES >> QUOTE |= REGEX_HANDLER;
53 
54     return REGEX;
55 }
56 
57 }  // namespace ark::verifier
58 
59 #endif  // PANDA_VERIFIER_DEBUG_METHOD_GROUP_PARSER_H_
60