• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2025 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 RULES_H
17 #define RULES_H
18 
19 #include <vector>
20 #include "rule.h"
21 
22 namespace ark::es2panda::lsp {
23 
24 struct RuleSpec {
25 public:
RuleSpecRuleSpec26     explicit RuleSpec(Rule &rule, std::vector<TokenRange> &leftTokenRange, std::vector<TokenRange> &rightTokenRange)
27         : rule_(rule), leftTokenRange_(leftTokenRange), rightTokenRange_(rightTokenRange)
28     {
29     }
30 
GetRuleRuleSpec31     Rule &GetRule()
32     {
33         return rule_;
34     }
35 
GetRuleRuleSpec36     const Rule &GetRule() const
37     {
38         return rule_;
39     }
40 
GetLeftTokenRangeRuleSpec41     std::vector<TokenRange> &GetLeftTokenRange()
42     {
43         return leftTokenRange_;
44     }
45 
GetLeftTokenRangeRuleSpec46     const std::vector<TokenRange> &GetLeftTokenRange() const
47     {
48         return leftTokenRange_;
49     }
50 
GetRightTokenRangeRuleSpec51     std::vector<TokenRange> &GetRightTokenRange()
52     {
53         return rightTokenRange_;
54     }
55 
GetRightTokenRangeRuleSpec56     const std::vector<TokenRange> &GetRightTokenRange() const
57     {
58         return rightTokenRange_;
59     }
60 
61 private:
62     Rule rule_;
63     std::vector<TokenRange> leftTokenRange_;
64     std::vector<TokenRange> rightTokenRange_;
65 };
66 
67 std::vector<RuleSpec> GetAllRules();
68 
69 }  // namespace ark::es2panda::lsp
70 
71 #endif