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 ES2PANDA_PARSER_PARSER_FLAGS_H 17 #define ES2PANDA_PARSER_PARSER_FLAGS_H 18 19 #include <cstdint> 20 #include "util/enumbitops.h" 21 22 namespace panda::es2panda::parser { 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 : uint32_t { 34 NO_OPTS = 0U, 35 NO_SKIP_VAR_KIND = 1U << 0U, 36 ACCEPT_CONST_NO_INIT = 1U << 1U, 37 DISALLOW_INIT = 1U << 2U, 38 VAR = 1U << 3U, 39 LET = 1U << 4U, 40 CONST = 1U << 5U, 41 STOP_AT_IN = 1U << 6U, 42 IN_FOR = 1U << 7U, 43 FOR_OF = 1U << 8U 44 }; 45 46 DEFINE_BITOPS(VariableParsingFlags) 47 48 enum class ExpressionParseFlags : uint32_t { 49 NO_OPTS = 0U, 50 ACCEPT_COMMA = 1U << 0U, 51 ACCEPT_REST = 1U << 1U, 52 EXP_DISALLOW_AS = 1U << 2U, 53 DISALLOW_ASSIGNMENT = 1U << 3U, 54 DISALLOW_YIELD = 1U << 4U, 55 STOP_AT_IN = 1U << 5U, 56 MUST_BE_PATTERN = 1U << 6U, 57 POTENTIALLY_IN_PATTERN = 1U << 7U, 58 OBJECT_PATTERN = 1U << 8U, 59 IN_REST = 1U << 9U, 60 IMPORT = 1U << 10U, 61 POTENTIAL_CLASS_LITERAL = 1U << 11U, 62 IN_FOR = 1U << 12U, 63 INSTANCEOF = 1U << 13U, 64 }; 65 66 DEFINE_BITOPS(ExpressionParseFlags) 67 68 enum class StatementParsingFlags : uint32_t { 69 NONE = 0U, 70 ALLOW_LEXICAL = 1U << 0U, 71 GLOBAL = 1U << 1U, 72 IF_ELSE = 1U << 2U, 73 LABELLED = 1U << 3U, 74 75 STMT_LEXICAL_SCOPE_NEEDED = IF_ELSE | LABELLED, 76 STMT_GLOBAL_LEXICAL = GLOBAL | ALLOW_LEXICAL, 77 }; 78 79 DEFINE_BITOPS(StatementParsingFlags) 80 81 enum class ForStatementKind { 82 UPDATE, 83 IN, 84 OF, 85 }; 86 } // namespace panda::es2panda::parser 87 88 #endif 89