• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021 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 ES2PANDA_PARSER_PARSER_FLAGS_H
17 #define ES2PANDA_PARSER_PARSER_FLAGS_H
18 
19 #include <util/enumbitops.h>
20 
21 namespace panda::es2panda::parser {
22 
23 enum class LexicalScopeType {
24     BLOCK,
25     STRICT_BLOCK,
26     CATCH,
27     FUNCTION_PARAM,
28     TS_TYPE_LITERAL,
29 };
30 
31 DEFINE_BITOPS(LexicalScopeType)
32 
33 enum class VariableParsingFlags {
34     NO_OPTS = 0,
35     NO_SKIP_VAR_KIND = (1 << 0),
36     ACCEPT_CONST_NO_INIT = (1 << 1),
37     DISALLOW_INIT = (1 << 2),
38     VAR = (1 << 3),
39     LET = (1 << 4),
40     CONST = (1 << 5),
41     STOP_AT_IN = (1 << 6),
42     EXPORTED = (1 << 7),
43     IN_FOR = (1 << 8),
44 };
45 
46 DEFINE_BITOPS(VariableParsingFlags)
47 
48 enum class ExpressionParseFlags {
49     NO_OPTS = 0,
50     ACCEPT_COMMA = 1 << 0,
51     ACCEPT_REST = 1 << 1,
52     EXP_DISALLOW_AS = 1 << 2,
53     DISALLOW_ASSIGNMENT = 1 << 3,
54     DISALLOW_YIELD = 1 << 4,
55     STOP_AT_IN = 1 << 5,
56     ALLOW_TS_PARAM_TOKEN = 1 << 6,
57     MUST_BE_PATTERN = 1 << 7,
58     POTENTIALLY_IN_PATTERN = 1 << 8,
59     OBJECT_PATTERN = 1 << 9,
60     IN_REST = 1 << 10,
61 };
62 
63 DEFINE_BITOPS(ExpressionParseFlags)
64 
65 enum class StatementParsingFlags {
66     NONE = 0,
67     ALLOW_LEXICAL = 1 << 0,
68     GLOBAL = 1 << 1,
69     IF_ELSE = 1 << 2,
70     LABELLED = 1 << 3,
71 
72     STMT_LEXICAL_SCOPE_NEEDED = IF_ELSE | LABELLED,
73     STMT_GLOBAL_LEXICAL = GLOBAL | ALLOW_LEXICAL,
74 };
75 
76 DEFINE_BITOPS(StatementParsingFlags)
77 
78 enum class ForStatementKind {
79     UPDATE,
80     IN,
81     OF,
82 };
83 
84 }  // namespace panda::es2panda::parser
85 
86 #endif
87