1425bb815Sopenharmony_ci/* Copyright JS Foundation and other contributors, http://js.foundation 2425bb815Sopenharmony_ci * 3425bb815Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4425bb815Sopenharmony_ci * you may not use this file except in compliance with the License. 5425bb815Sopenharmony_ci * You may obtain a copy of the License at 6425bb815Sopenharmony_ci * 7425bb815Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8425bb815Sopenharmony_ci * 9425bb815Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10425bb815Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS 11425bb815Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12425bb815Sopenharmony_ci * See the License for the specific language governing permissions and 13425bb815Sopenharmony_ci * limitations under the License. 14425bb815Sopenharmony_ci */ 15425bb815Sopenharmony_ci 16425bb815Sopenharmony_ci#ifndef JS_LEXER_H 17425bb815Sopenharmony_ci#define JS_LEXER_H 18425bb815Sopenharmony_ci 19425bb815Sopenharmony_ci/** \addtogroup parser Parser 20425bb815Sopenharmony_ci * @{ 21425bb815Sopenharmony_ci * 22425bb815Sopenharmony_ci * \addtogroup jsparser JavaScript 23425bb815Sopenharmony_ci * @{ 24425bb815Sopenharmony_ci * 25425bb815Sopenharmony_ci * \addtogroup jsparser_lexer Lexer 26425bb815Sopenharmony_ci * @{ 27425bb815Sopenharmony_ci */ 28425bb815Sopenharmony_ci 29425bb815Sopenharmony_ci/** 30425bb815Sopenharmony_ci * Lexer token types. 31425bb815Sopenharmony_ci */ 32425bb815Sopenharmony_citypedef enum 33425bb815Sopenharmony_ci{ 34425bb815Sopenharmony_ci LEXER_EOS, /**< end of source */ 35425bb815Sopenharmony_ci 36425bb815Sopenharmony_ci /* Primary expressions */ 37425bb815Sopenharmony_ci LEXER_LITERAL, /**< literal token */ 38425bb815Sopenharmony_ci LEXER_KEYW_THIS, /**< this */ 39425bb815Sopenharmony_ci LEXER_LIT_TRUE, /**< true (not a keyword!) */ 40425bb815Sopenharmony_ci LEXER_LIT_FALSE, /**< false (not a keyword!) */ 41425bb815Sopenharmony_ci LEXER_LIT_NULL, /**< null (not a keyword!) */ 42425bb815Sopenharmony_ci#if ENABLED (JERRY_ES2015) 43425bb815Sopenharmony_ci LEXER_TEMPLATE_LITERAL, /**< multi segment template literal */ 44425bb815Sopenharmony_ci LEXER_THREE_DOTS, /**< ... (rest or spread operator) */ 45425bb815Sopenharmony_ci#endif /* ENABLED (JERRY_ES2015) */ 46425bb815Sopenharmony_ci 47425bb815Sopenharmony_ci /* Unary operators 48425bb815Sopenharmony_ci * IMPORTANT: update CBC_UNARY_OP_TOKEN_TO_OPCODE and 49425bb815Sopenharmony_ci * CBC_UNARY_LVALUE_OP_TOKEN_TO_OPCODE after changes. */ 50425bb815Sopenharmony_ci#define LEXER_IS_UNARY_OP_TOKEN(token_type) \ 51425bb815Sopenharmony_ci ((token_type) >= LEXER_PLUS && (token_type) <= LEXER_DECREASE) 52425bb815Sopenharmony_ci#define LEXER_IS_UNARY_LVALUE_OP_TOKEN(token_type) \ 53425bb815Sopenharmony_ci ((token_type) >= LEXER_KEYW_DELETE && (token_type) <= LEXER_DECREASE) 54425bb815Sopenharmony_ci 55425bb815Sopenharmony_ci LEXER_PLUS, /**< "+" */ 56425bb815Sopenharmony_ci LEXER_NEGATE, /**< "-" */ 57425bb815Sopenharmony_ci LEXER_LOGICAL_NOT, /**< "!" */ 58425bb815Sopenharmony_ci LEXER_BIT_NOT, /**< "~" */ 59425bb815Sopenharmony_ci LEXER_KEYW_VOID, /**< void */ 60425bb815Sopenharmony_ci LEXER_KEYW_TYPEOF, /**< typeof */ 61425bb815Sopenharmony_ci#if ENABLED (JERRY_ES2015) 62425bb815Sopenharmony_ci LEXER_KEYW_AWAIT, /**< await */ 63425bb815Sopenharmony_ci#endif /* ENABLED (JERRY_ES2015) */ 64425bb815Sopenharmony_ci LEXER_KEYW_DELETE, /**< delete */ 65425bb815Sopenharmony_ci LEXER_INCREASE, /**< "++" */ 66425bb815Sopenharmony_ci LEXER_DECREASE, /**< "--" */ 67425bb815Sopenharmony_ci 68425bb815Sopenharmony_ci /* Binary operators 69425bb815Sopenharmony_ci * IMPORTANT: update CBC_BINARY_OP_TOKEN_TO_OPCODE, 70425bb815Sopenharmony_ci * CBC_BINARY_LVALUE_OP_TOKEN_TO_OPCODE and 71425bb815Sopenharmony_ci * parser_binary_precedence_table after changes. */ 72425bb815Sopenharmony_ci#if ENABLED (JERRY_ES2015) 73425bb815Sopenharmony_ci#define LEXER_IS_BINARY_OP_TOKEN(token_type) \ 74425bb815Sopenharmony_ci ((token_type) >= LEXER_ASSIGN && (token_type) <= LEXER_EXPONENTIATION) 75425bb815Sopenharmony_ci#else /* !ENABLED (JERRY_ES2015) */ 76425bb815Sopenharmony_ci#define LEXER_IS_BINARY_OP_TOKEN(token_type) \ 77425bb815Sopenharmony_ci ((token_type) >= LEXER_ASSIGN && (token_type) <= LEXER_MODULO) 78425bb815Sopenharmony_ci#endif /* ENABLED (JERRY_ES2015) */ 79425bb815Sopenharmony_ci 80425bb815Sopenharmony_ci#define LEXER_IS_BINARY_LVALUE_TOKEN(token_type) \ 81425bb815Sopenharmony_ci ((token_type) >= LEXER_ASSIGN && (token_type) <= LEXER_ASSIGN_BIT_XOR) 82425bb815Sopenharmony_ci 83425bb815Sopenharmony_ci#define LEXER_FIRST_BINARY_OP LEXER_ASSIGN 84425bb815Sopenharmony_ci 85425bb815Sopenharmony_ci LEXER_ASSIGN, /**< "=" (prec: 3) */ 86425bb815Sopenharmony_ci LEXER_ASSIGN_ADD, /**< "+=" (prec: 3) */ 87425bb815Sopenharmony_ci LEXER_ASSIGN_SUBTRACT, /**< "-=" (prec: 3) */ 88425bb815Sopenharmony_ci LEXER_ASSIGN_MULTIPLY, /**< "*=" (prec: 3) */ 89425bb815Sopenharmony_ci LEXER_ASSIGN_DIVIDE, /**< "/=" (prec: 3) */ 90425bb815Sopenharmony_ci LEXER_ASSIGN_MODULO, /**< "%=" (prec: 3) */ 91425bb815Sopenharmony_ci#if ENABLED (JERRY_ES2015) 92425bb815Sopenharmony_ci LEXER_ASSIGN_EXPONENTIATION, /**< "**=" (prec: 3) */ 93425bb815Sopenharmony_ci#endif /* ENABLED (JERRY_ES2015) */ 94425bb815Sopenharmony_ci LEXER_ASSIGN_LEFT_SHIFT, /**< "<<=" (prec: 3) */ 95425bb815Sopenharmony_ci LEXER_ASSIGN_RIGHT_SHIFT, /**< ">>=" (prec: 3) */ 96425bb815Sopenharmony_ci LEXER_ASSIGN_UNS_RIGHT_SHIFT, /**< ">>>=" (prec: 3) */ 97425bb815Sopenharmony_ci LEXER_ASSIGN_BIT_AND, /**< "&=" (prec: 3) */ 98425bb815Sopenharmony_ci LEXER_ASSIGN_BIT_OR, /**< "|=" (prec: 3) */ 99425bb815Sopenharmony_ci LEXER_ASSIGN_BIT_XOR, /**< "^=" (prec: 3) */ 100425bb815Sopenharmony_ci LEXER_QUESTION_MARK, /**< "?" (prec: 4) */ 101425bb815Sopenharmony_ci LEXER_LOGICAL_OR, /**< "||" (prec: 5) */ 102425bb815Sopenharmony_ci LEXER_LOGICAL_AND, /**< "&&" (prec: 6) */ 103425bb815Sopenharmony_ci LEXER_BIT_OR, /**< "|" (prec: 7) */ 104425bb815Sopenharmony_ci LEXER_BIT_XOR, /**< "^" (prec: 8) */ 105425bb815Sopenharmony_ci LEXER_BIT_AND, /**< "&" (prec: 9) */ 106425bb815Sopenharmony_ci LEXER_EQUAL, /**< "==" (prec: 10) */ 107425bb815Sopenharmony_ci LEXER_NOT_EQUAL, /**< "!=" (prec: 10) */ 108425bb815Sopenharmony_ci LEXER_STRICT_EQUAL, /**< "===" (prec: 10) */ 109425bb815Sopenharmony_ci LEXER_STRICT_NOT_EQUAL, /**< "!==" (prec: 10) */ 110425bb815Sopenharmony_ci LEXER_LESS, /**< "<" (prec: 11) */ 111425bb815Sopenharmony_ci LEXER_GREATER, /**< ">" (prec: 11) */ 112425bb815Sopenharmony_ci LEXER_LESS_EQUAL, /**< "<=" (prec: 11) */ 113425bb815Sopenharmony_ci LEXER_GREATER_EQUAL, /**< ">=" (prec: 11) */ 114425bb815Sopenharmony_ci LEXER_KEYW_IN, /**< in (prec: 11) */ 115425bb815Sopenharmony_ci LEXER_KEYW_INSTANCEOF, /**< instanceof (prec: 11) */ 116425bb815Sopenharmony_ci LEXER_LEFT_SHIFT, /**< "<<" (prec: 12) */ 117425bb815Sopenharmony_ci LEXER_RIGHT_SHIFT, /**< ">>" (prec: 12) */ 118425bb815Sopenharmony_ci LEXER_UNS_RIGHT_SHIFT, /**< ">>>" (prec: 12) */ 119425bb815Sopenharmony_ci LEXER_ADD, /**< "+" (prec: 13) */ 120425bb815Sopenharmony_ci LEXER_SUBTRACT, /**< "-" (prec: 13) */ 121425bb815Sopenharmony_ci LEXER_MULTIPLY, /**< "*" (prec: 14) */ 122425bb815Sopenharmony_ci LEXER_DIVIDE, /**< "/" (prec: 14) */ 123425bb815Sopenharmony_ci LEXER_MODULO, /**< "%" (prec: 14) */ 124425bb815Sopenharmony_ci#if ENABLED (JERRY_ES2015) 125425bb815Sopenharmony_ci LEXER_EXPONENTIATION, /**< "**" (prec: 15) */ 126425bb815Sopenharmony_ci#endif /* ENABLED (JERRY_ES2015) */ 127425bb815Sopenharmony_ci 128425bb815Sopenharmony_ci LEXER_LEFT_BRACE, /**< "{" */ 129425bb815Sopenharmony_ci LEXER_LEFT_PAREN, /**< "(" */ 130425bb815Sopenharmony_ci LEXER_LEFT_SQUARE, /**< "[" */ 131425bb815Sopenharmony_ci LEXER_RIGHT_BRACE, /**< "}" */ 132425bb815Sopenharmony_ci LEXER_RIGHT_PAREN, /**< ")" */ 133425bb815Sopenharmony_ci LEXER_RIGHT_SQUARE, /**< "]" */ 134425bb815Sopenharmony_ci LEXER_DOT, /**< "." */ 135425bb815Sopenharmony_ci LEXER_SEMICOLON, /**< ";" */ 136425bb815Sopenharmony_ci LEXER_COLON, /**< ":" */ 137425bb815Sopenharmony_ci LEXER_COMMA, /**< "," */ 138425bb815Sopenharmony_ci#if ENABLED (JERRY_ES2015) 139425bb815Sopenharmony_ci LEXER_ARROW, /**< "=>" */ 140425bb815Sopenharmony_ci#endif /* ENABLED (JERRY_ES2015) */ 141425bb815Sopenharmony_ci 142425bb815Sopenharmony_ci LEXER_KEYW_BREAK, /**< break */ 143425bb815Sopenharmony_ci LEXER_KEYW_DO, /**< do */ 144425bb815Sopenharmony_ci LEXER_KEYW_CASE, /**< case */ 145425bb815Sopenharmony_ci LEXER_KEYW_ELSE, /**< else */ 146425bb815Sopenharmony_ci LEXER_KEYW_NEW, /**< new */ 147425bb815Sopenharmony_ci LEXER_KEYW_VAR, /**< var */ 148425bb815Sopenharmony_ci LEXER_KEYW_CATCH, /**< catch */ 149425bb815Sopenharmony_ci LEXER_KEYW_FINALLY, /**< finally */ 150425bb815Sopenharmony_ci LEXER_KEYW_RETURN, /**< return */ 151425bb815Sopenharmony_ci LEXER_KEYW_CONTINUE, /**< continue */ 152425bb815Sopenharmony_ci LEXER_KEYW_FOR, /**< for */ 153425bb815Sopenharmony_ci LEXER_KEYW_SWITCH, /**< switch */ 154425bb815Sopenharmony_ci LEXER_KEYW_WHILE, /**< while */ 155425bb815Sopenharmony_ci LEXER_KEYW_DEBUGGER, /**< debugger */ 156425bb815Sopenharmony_ci LEXER_KEYW_FUNCTION, /**< function */ 157425bb815Sopenharmony_ci LEXER_KEYW_WITH, /**< with */ 158425bb815Sopenharmony_ci LEXER_KEYW_DEFAULT, /**< default */ 159425bb815Sopenharmony_ci LEXER_KEYW_IF, /**< if */ 160425bb815Sopenharmony_ci LEXER_KEYW_THROW, /**< throw */ 161425bb815Sopenharmony_ci LEXER_KEYW_TRY, /**< try */ 162425bb815Sopenharmony_ci 163425bb815Sopenharmony_ci LEXER_KEYW_CLASS, /**< class */ 164425bb815Sopenharmony_ci LEXER_KEYW_EXTENDS, /**< extends */ 165425bb815Sopenharmony_ci LEXER_KEYW_SUPER, /**< super */ 166425bb815Sopenharmony_ci LEXER_KEYW_CONST, /**< const */ 167425bb815Sopenharmony_ci LEXER_KEYW_EXPORT, /**< export */ 168425bb815Sopenharmony_ci LEXER_KEYW_IMPORT, /**< import */ 169425bb815Sopenharmony_ci LEXER_KEYW_ENUM, /**< enum */ 170425bb815Sopenharmony_ci 171425bb815Sopenharmony_ci /* These are virtual tokens. */ 172425bb815Sopenharmony_ci LEXER_EXPRESSION_START, /**< expression start */ 173425bb815Sopenharmony_ci LEXER_PROPERTY_GETTER, /**< property getter function */ 174425bb815Sopenharmony_ci LEXER_PROPERTY_SETTER, /**< property setter function */ 175425bb815Sopenharmony_ci LEXER_COMMA_SEP_LIST, /**< comma separated bracketed expression list */ 176425bb815Sopenharmony_ci#if ENABLED (JERRY_ES2015) 177425bb815Sopenharmony_ci LEXER_ASSIGN_GROUP_EXPR, /**< indetifier for the assignment is located in a group expression */ 178425bb815Sopenharmony_ci LEXER_ASSIGN_CONST, /**< a const binding is reassigned */ 179425bb815Sopenharmony_ci LEXER_CLASS_CONSTRUCTOR, /**< special value for class constructor method */ 180425bb815Sopenharmony_ci LEXER_INVALID_PATTERN, /**< special value for invalid destructuring pattern */ 181425bb815Sopenharmony_ci#endif /* ENABLED (JERRY_ES2015) */ 182425bb815Sopenharmony_ci 183425bb815Sopenharmony_ci#if ENABLED (JERRY_ES2015) 184425bb815Sopenharmony_ci /* Keywords which are not keyword tokens. */ 185425bb815Sopenharmony_ci#define LEXER_FIRST_NON_RESERVED_KEYWORD LEXER_KEYW_ASYNC 186425bb815Sopenharmony_ci LEXER_KEYW_ASYNC, /**< async */ 187425bb815Sopenharmony_ci#else /* !ENABLED (JERRY_ES2015) */ 188425bb815Sopenharmony_ci /* Keywords which are not keyword tokens. */ 189425bb815Sopenharmony_ci#define LEXER_FIRST_NON_RESERVED_KEYWORD LEXER_KEYW_EVAL 190425bb815Sopenharmony_ci#endif /* ENABLED (JERRY_ES2015) */ 191425bb815Sopenharmony_ci 192425bb815Sopenharmony_ci /* Keywords which cannot be assigned in strict mode. */ 193425bb815Sopenharmony_ci#define LEXER_FIRST_NON_STRICT_ARGUMENTS LEXER_KEYW_EVAL 194425bb815Sopenharmony_ci LEXER_KEYW_EVAL, /**< eval */ 195425bb815Sopenharmony_ci LEXER_KEYW_ARGUMENTS, /**< arguments */ 196425bb815Sopenharmony_ci 197425bb815Sopenharmony_ci /* Future strict reserved words: these keywords 198425bb815Sopenharmony_ci * must form a group after non-reserved keywords. */ 199425bb815Sopenharmony_ci#define LEXER_FIRST_FUTURE_STRICT_RESERVED_WORD LEXER_KEYW_IMPLEMENTS 200425bb815Sopenharmony_ci LEXER_KEYW_IMPLEMENTS, /**< implements */ 201425bb815Sopenharmony_ci LEXER_KEYW_PRIVATE, /**< private */ 202425bb815Sopenharmony_ci LEXER_KEYW_PUBLIC, /**< public */ 203425bb815Sopenharmony_ci LEXER_KEYW_INTERFACE, /**< interface */ 204425bb815Sopenharmony_ci LEXER_KEYW_PACKAGE, /**< package */ 205425bb815Sopenharmony_ci LEXER_KEYW_PROTECTED, /**< protected */ 206425bb815Sopenharmony_ci 207425bb815Sopenharmony_ci /* Context dependent future strict reserved words: 208425bb815Sopenharmony_ci * See also: ECMA-262 v6, 11.6.2.1 */ 209425bb815Sopenharmony_ci LEXER_KEYW_LET, /**< let */ 210425bb815Sopenharmony_ci LEXER_KEYW_YIELD, /**< yield */ 211425bb815Sopenharmony_ci LEXER_KEYW_STATIC, /**< static */ 212425bb815Sopenharmony_ci} lexer_token_type_t; 213425bb815Sopenharmony_ci 214425bb815Sopenharmony_ci#define LEXER_NEWLINE_LS_PS_BYTE_1 0xe2 215425bb815Sopenharmony_ci#define LEXER_NEWLINE_LS_PS_BYTE_23(source) \ 216425bb815Sopenharmony_ci ((source)[1] == LIT_UTF8_2_BYTE_CODE_POINT_MIN && ((source)[2] | 0x1) == 0xa9) 217425bb815Sopenharmony_ci 218425bb815Sopenharmony_ci#define LEXER_IS_LEFT_BRACKET(type) \ 219425bb815Sopenharmony_ci ((type) == LEXER_LEFT_BRACE || (type) == LEXER_LEFT_PAREN || (type) == LEXER_LEFT_SQUARE) 220425bb815Sopenharmony_ci 221425bb815Sopenharmony_ci#define LEXER_IS_RIGHT_BRACKET(type) \ 222425bb815Sopenharmony_ci ((type) == LEXER_RIGHT_BRACE || (type) == LEXER_RIGHT_PAREN || (type) == LEXER_RIGHT_SQUARE) 223425bb815Sopenharmony_ci 224425bb815Sopenharmony_ci#define LEXER_UNARY_OP_TOKEN_TO_OPCODE(token_type) \ 225425bb815Sopenharmony_ci ((((token_type) - LEXER_PLUS) * 2) + CBC_PLUS) 226425bb815Sopenharmony_ci 227425bb815Sopenharmony_ci#define LEXER_UNARY_LVALUE_OP_TOKEN_TO_OPCODE(token_type) \ 228425bb815Sopenharmony_ci ((((token_type) - LEXER_INCREASE) * 6) + CBC_PRE_INCR) 229425bb815Sopenharmony_ci 230425bb815Sopenharmony_ci#define LEXER_BINARY_OP_TOKEN_TO_OPCODE(token_type) \ 231425bb815Sopenharmony_ci ((cbc_opcode_t) ((((token_type) - LEXER_BIT_OR) * 3) + CBC_BIT_OR)) 232425bb815Sopenharmony_ci 233425bb815Sopenharmony_ci#define LEXER_BINARY_LVALUE_OP_TOKEN_TO_OPCODE(token_type) \ 234425bb815Sopenharmony_ci ((cbc_opcode_t) ((((token_type) - LEXER_ASSIGN_ADD) * 2) + CBC_ASSIGN_ADD)) 235425bb815Sopenharmony_ci 236425bb815Sopenharmony_ci/** 237425bb815Sopenharmony_ci * Maximum local buffer size for identifiers which contains escape sequences. 238425bb815Sopenharmony_ci */ 239425bb815Sopenharmony_ci#define LEXER_MAX_LITERAL_LOCAL_BUFFER_SIZE 48 240425bb815Sopenharmony_ci 241425bb815Sopenharmony_ci/** 242425bb815Sopenharmony_ci * Lexer newline flags. 243425bb815Sopenharmony_ci */ 244425bb815Sopenharmony_citypedef enum 245425bb815Sopenharmony_ci{ 246425bb815Sopenharmony_ci LEXER_WAS_NEWLINE = (1u << 0), /**< newline was seen */ 247425bb815Sopenharmony_ci LEXER_NO_SKIP_SPACES = (1u << 1) /**< ignore skip spaces */ 248425bb815Sopenharmony_ci} lexer_newline_flags_t; 249425bb815Sopenharmony_ci 250425bb815Sopenharmony_ci/** 251425bb815Sopenharmony_ci * Lexer object identifier parse options. 252425bb815Sopenharmony_ci */ 253425bb815Sopenharmony_citypedef enum 254425bb815Sopenharmony_ci{ 255425bb815Sopenharmony_ci LEXER_OBJ_IDENT_NO_OPTS = (1u << 0), /**< no options */ 256425bb815Sopenharmony_ci LEXER_OBJ_IDENT_ONLY_IDENTIFIERS = (1u << 1), /**< only identifiers are accepted */ 257425bb815Sopenharmony_ci LEXER_OBJ_IDENT_CLASS_METHOD = (1u << 2), /**< expect identifier inside a class body */ 258425bb815Sopenharmony_ci LEXER_OBJ_IDENT_OBJECT_PATTERN = (1u << 3), /**< parse "get"/"set" as string literal in object pattern */ 259425bb815Sopenharmony_ci} lexer_obj_ident_opts_t; 260425bb815Sopenharmony_ci 261425bb815Sopenharmony_ci/** 262425bb815Sopenharmony_ci * Lexer string options. 263425bb815Sopenharmony_ci */ 264425bb815Sopenharmony_citypedef enum 265425bb815Sopenharmony_ci{ 266425bb815Sopenharmony_ci LEXER_STRING_NO_OPTS = (1u << 0), /**< no options */ 267425bb815Sopenharmony_ci LEXER_STRING_RAW = (1u << 1), /**< raw string ECMAScript v6, 11.8.6.1: TVR */ 268425bb815Sopenharmony_ci} lexer_string_options_t; 269425bb815Sopenharmony_ci 270425bb815Sopenharmony_ci/** 271425bb815Sopenharmony_ci * Lexer number types. 272425bb815Sopenharmony_ci */ 273425bb815Sopenharmony_citypedef enum 274425bb815Sopenharmony_ci{ 275425bb815Sopenharmony_ci LEXER_NUMBER_DECIMAL, /**< decimal number */ 276425bb815Sopenharmony_ci LEXER_NUMBER_HEXADECIMAL, /**< hexadecimal number */ 277425bb815Sopenharmony_ci LEXER_NUMBER_OCTAL, /**< octal number */ 278425bb815Sopenharmony_ci LEXER_NUMBER_BINARY, /**< binary number */ 279425bb815Sopenharmony_ci} lexer_number_type_t; 280425bb815Sopenharmony_ci 281425bb815Sopenharmony_ci/** 282425bb815Sopenharmony_ci * Lexer character (string / identifier) literal data. 283425bb815Sopenharmony_ci */ 284425bb815Sopenharmony_citypedef struct 285425bb815Sopenharmony_ci{ 286425bb815Sopenharmony_ci const uint8_t *char_p; /**< start of identifier or string token */ 287425bb815Sopenharmony_ci prop_length_t length; /**< length or index of a literal */ 288425bb815Sopenharmony_ci uint8_t type; /**< type of the current literal */ 289425bb815Sopenharmony_ci uint8_t has_escape; /**< has escape sequences */ 290425bb815Sopenharmony_ci} lexer_lit_location_t; 291425bb815Sopenharmony_ci 292425bb815Sopenharmony_ci/** 293425bb815Sopenharmony_ci * Lexer token. 294425bb815Sopenharmony_ci */ 295425bb815Sopenharmony_citypedef struct 296425bb815Sopenharmony_ci{ 297425bb815Sopenharmony_ci uint8_t type; /**< token type */ 298425bb815Sopenharmony_ci uint8_t keyword_type; /**< keyword type for identifiers */ 299425bb815Sopenharmony_ci uint8_t extra_value; /**< helper value for different purposes */ 300425bb815Sopenharmony_ci uint8_t flags; /**< flag bits for the current token */ 301425bb815Sopenharmony_ci parser_line_counter_t line; /**< token start line */ 302425bb815Sopenharmony_ci parser_line_counter_t column; /**< token start column */ 303425bb815Sopenharmony_ci lexer_lit_location_t lit_location; /**< extra data for character literals */ 304425bb815Sopenharmony_ci} lexer_token_t; 305425bb815Sopenharmony_ci 306425bb815Sopenharmony_ci/** 307425bb815Sopenharmony_ci * Literal data set by lexer_construct_literal_object. 308425bb815Sopenharmony_ci */ 309425bb815Sopenharmony_citypedef struct 310425bb815Sopenharmony_ci{ 311425bb815Sopenharmony_ci lexer_literal_t *literal_p; /**< pointer to the literal object */ 312425bb815Sopenharmony_ci uint16_t index; /**< literal index */ 313425bb815Sopenharmony_ci} lexer_lit_object_t; 314425bb815Sopenharmony_ci 315425bb815Sopenharmony_ci/** 316425bb815Sopenharmony_ci * @} 317425bb815Sopenharmony_ci * @} 318425bb815Sopenharmony_ci * @} 319425bb815Sopenharmony_ci */ 320425bb815Sopenharmony_ci 321425bb815Sopenharmony_ci#endif /* !JS_LEXER_H */ 322