• 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     EXPORTED_IN_TSMODULE = (1 << 9),
45 };
46 
47 DEFINE_BITOPS(VariableParsingFlags)
48 
49 enum class ExpressionParseFlags {
50     NO_OPTS = 0,
51     ACCEPT_COMMA = 1 << 0,
52     ACCEPT_REST = 1 << 1,
53     EXP_DISALLOW_AS = 1 << 2,
54     DISALLOW_ASSIGNMENT = 1 << 3,
55     DISALLOW_YIELD = 1 << 4,
56     STOP_AT_IN = 1 << 5,
57     ALLOW_TS_PARAM_TOKEN = 1 << 6,
58     MUST_BE_PATTERN = 1 << 7,
59     POTENTIALLY_IN_PATTERN = 1 << 8,
60     OBJECT_PATTERN = 1 << 9,
61     IN_REST = 1 << 10,
62 };
63 
64 DEFINE_BITOPS(ExpressionParseFlags)
65 
66 enum class StatementParsingFlags {
67     NONE = 0,
68     ALLOW_LEXICAL = 1 << 0,
69     GLOBAL = 1 << 1,
70     IF_ELSE = 1 << 2,
71     LABELLED = 1 << 3,
72 
73     STMT_LEXICAL_SCOPE_NEEDED = IF_ELSE | LABELLED,
74     STMT_GLOBAL_LEXICAL = GLOBAL | ALLOW_LEXICAL,
75 };
76 
77 DEFINE_BITOPS(StatementParsingFlags)
78 
79 enum class ForStatementKind {
80     UPDATE,
81     IN,
82     OF,
83 };
84 
85 }  // namespace panda::es2panda::parser
86 
87 #endif
88