Lines Matching full:lexer
94 #include <lexer/lexer.h>
100 std::unique_ptr<lexer::Lexer> ParserImpl::InitLexer(const std::string &fileName, const std::string … in InitLexer()
107 auto lexer = std::make_unique<lexer::Lexer>(&context_); in InitLexer() local
108 lexer_ = lexer.get(); in InitLexer()
110 return lexer; in InitLexer()
129 * In order to make the lexer's memory alive, the return value 'lexer' can not be omitted. in Parse()
131 auto lexer = InitLexer(sourceFile.fileName, std::string {sourceFile.source}); in Parse() local
170 lexer::SourcePosition startLoc = lexer_->GetToken().Start(); in ParseProgram()
270 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT || in CurrentLiteralIsBasicType()
271 lexer_->GetToken().Type() == lexer::TokenType::KEYW_EXTENDS); in CurrentLiteralIsBasicType()
274 case lexer::TokenType::KEYW_ANY: in CurrentLiteralIsBasicType()
275 case lexer::TokenType::KEYW_BOOLEAN: in CurrentLiteralIsBasicType()
276 case lexer::TokenType::KEYW_NUMBER: in CurrentLiteralIsBasicType()
277 case lexer::TokenType::KEYW_STRING: in CurrentLiteralIsBasicType()
278 case lexer::TokenType::KEYW_SYMBOL: in CurrentLiteralIsBasicType()
279 case lexer::TokenType::KEYW_UNKNOWN: in CurrentLiteralIsBasicType()
280 case lexer::TokenType::KEYW_UNDEFINED: in CurrentLiteralIsBasicType()
281 case lexer::TokenType::KEYW_NEVER: in CurrentLiteralIsBasicType()
282 case lexer::TokenType::KEYW_OBJECT: in CurrentLiteralIsBasicType()
283 case lexer::TokenType::KEYW_BIGINT: { in CurrentLiteralIsBasicType()
296 case lexer::TokenType::PUNCTUATOR_MINUS: in CurrentIsBasicType()
297 case lexer::TokenType::LITERAL_NUMBER: in CurrentIsBasicType()
298 case lexer::TokenType::LITERAL_STRING: in CurrentIsBasicType()
299 case lexer::TokenType::LITERAL_FALSE: in CurrentIsBasicType()
300 case lexer::TokenType::LITERAL_TRUE: in CurrentIsBasicType()
301 case lexer::TokenType::LITERAL_NULL: in CurrentIsBasicType()
302 case lexer::TokenType::KEYW_VOID: { in CurrentIsBasicType()
305 case lexer::TokenType::LITERAL_IDENT: { in CurrentIsBasicType()
345 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_MINUS || in IsStartOfMappedType()
346 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PLUS) { in IsStartOfMappedType()
348 result = lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_READONLY; in IsStartOfMappedType()
353 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_READONLY) { in IsStartOfMappedType()
357 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_SQUARE_BRACKET) { in IsStartOfMappedType()
364 if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { in IsStartOfMappedType()
371 result = lexer_->GetToken().Type() == lexer::TokenType::KEYW_IN; in IsStartOfMappedType()
379 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT || in IsStartOfTsTypePredicate()
380 lexer_->GetToken().Type() == lexer::TokenType::KEYW_THIS); in IsStartOfTsTypePredicate()
383 bool isAsserts = lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_ASSERTS; in IsStartOfTsTypePredicate()
388 if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT && in IsStartOfTsTypePredicate()
389 lexer_->GetToken().Type() != lexer::TokenType::KEYW_THIS) { in IsStartOfTsTypePredicate()
401 …bool result = !lexer_->GetToken().NewLine() && (lexer_->GetToken().KeywordType() == lexer::TokenTy… in IsStartOfTsTypePredicate()
408 if (lexer_->GetToken().KeywordType() != lexer::TokenType::KEYW_ABSTRACT) { in IsStartOfAbstractConstructorType()
412 lexer::LexerPosition pos = lexer_->Save(); in IsStartOfAbstractConstructorType()
414 bool result = lexer_->GetToken().Type() == lexer::TokenType::KEYW_NEW; in IsStartOfAbstractConstructorType()
431 lexer::SourcePosition bodyStart = lexer_->GetToken().Start(); in ParseTsTypeLiteralOrTsMappedType()
433 lexer::SourcePosition bodyEnd = lexer_->GetToken().End(); in ParseTsTypeLiteralOrTsMappedType()
473 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_BACK_TICK); in ParseTsTemplateLiteralType()
474 lexer::SourcePosition startLoc = lexer_->GetToken().Start(); in ParseTsTemplateLiteralType()
490 element->SetRange({lexer::SourcePosition{startPos.iterator.Index(), startPos.line}, in ParseTsTemplateLiteralType()
491 lexer::SourcePosition{end, lexer_->Line()}}); in ParseTsTemplateLiteralType()
502 lexer::TemplateLiteralParserContext ctx(lexer_); in ParseTsTemplateLiteralType()
509 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_BRACE) { in ParseTsTemplateLiteralType()
531 case lexer::TokenType::PUNCTUATOR_BITWISE_OR: { in ParseTsTypeAnnotationElement()
540 case lexer::TokenType::PUNCTUATOR_BITWISE_AND: { in ParseTsTypeAnnotationElement()
550 case lexer::TokenType::PUNCTUATOR_MINUS: in ParseTsTypeAnnotationElement()
551 case lexer::TokenType::LITERAL_NUMBER: in ParseTsTypeAnnotationElement()
552 case lexer::TokenType::LITERAL_STRING: in ParseTsTypeAnnotationElement()
553 case lexer::TokenType::LITERAL_FALSE: in ParseTsTypeAnnotationElement()
554 case lexer::TokenType::LITERAL_TRUE: in ParseTsTypeAnnotationElement()
555 case lexer::TokenType::LITERAL_NULL: in ParseTsTypeAnnotationElement()
556 case lexer::TokenType::KEYW_VOID: { in ParseTsTypeAnnotationElement()
563 case lexer::TokenType::KEYW_TYPEOF: { in ParseTsTypeAnnotationElement()
570 case lexer::TokenType::KEYW_IMPORT: { in ParseTsTypeAnnotationElement()
575 lexer::SourcePosition startLoc = lexer_->GetToken().Start(); in ParseTsTypeAnnotationElement()
578 case lexer::TokenType::KEYW_CONST: { in ParseTsTypeAnnotationElement()
586 case lexer::TokenType::LITERAL_IDENT: { in ParseTsTypeAnnotationElement()
596 case lexer::TokenType::KEYW_EXTENDS: { in ParseTsTypeAnnotationElement()
610 case lexer::TokenType::KEYW_THIS: { in ParseTsTypeAnnotationElement()
615 case lexer::TokenType::PUNCTUATOR_BACK_TICK: { in ParseTsTypeAnnotationElement()
638 case lexer::TokenType::PUNCTUATOR_LESS_THAN: in ParsePostfixTypeOrHigher()
639 case lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS: in ParsePostfixTypeOrHigher()
640 case lexer::TokenType::KEYW_NEW: { in ParsePostfixTypeOrHigher()
645 case lexer::TokenType::PUNCTUATOR_LEFT_SQUARE_BRACKET: { in ParsePostfixTypeOrHigher()
659 case lexer::TokenType::PUNCTUATOR_LEFT_BRACE: { in ParsePostfixTypeOrHigher()
669 ir::TSImportType *ParserImpl::ParseTsImportType(const lexer::SourcePosition &startLoc, bool isTypeo… in ParseTsImportType()
671 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::KEYW_IMPORT); in ParseTsImportType()
675 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS) { in ParseTsImportType()
688 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS) { in ParseTsImportType()
695 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PERIOD) { in ParseTsImportType()
698 if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { in ParseTsImportType()
707 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PERIOD) { in ParseTsImportType()
713 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SHIFT || in ParseTsImportType()
714 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LESS_THAN) { in ParseTsImportType()
715 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SHIFT) { in ParseTsImportType()
716 lexer_->BackwardToken(lexer::TokenType::PUNCTUATOR_LESS_THAN, 1); in ParseTsImportType()
731 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::KEYW_THIS); in ParseTsThisType()
749 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::KEYW_EXTENDS); in ParseTsConditionalType()
754 lexer::SourcePosition startLoc = checkType->Start(); in ParseTsConditionalType()
768 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_QUESTION_MARK) { in ParseTsConditionalType()
777 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COLON) { in ParseTsConditionalType()
785 lexer::SourcePosition endLoc = falseType->End(); in ParseTsConditionalType()
812 !(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_BITWISE_AND || in ParseTsTypeAnnotation()
813 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_BITWISE_OR)) { in ParseTsTypeAnnotation()
827 case lexer::TokenType::KEYW_READONLY: in ParseTsTypeOperatorOrTypeReference()
828 case lexer::TokenType::KEYW_KEYOF: in ParseTsTypeOperatorOrTypeReference()
829 case lexer::TokenType::KEYW_UNIQUE: { in ParseTsTypeOperatorOrTypeReference()
832 case lexer::TokenType::KEYW_INFER: { in ParseTsTypeOperatorOrTypeReference()
849 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_READONLY) { in ParseTsTypeOperator()
850 lexer::SourcePosition typeOperatorStart = lexer_->GetToken().Start(); in ParseTsTypeOperator()
869 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_KEYOF) { in ParseTsTypeOperator()
870 lexer::SourcePosition typeOperatorStart = lexer_->GetToken().Start(); in ParseTsTypeOperator()
883 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_UNIQUE) { in ParseTsTypeOperator()
884 lexer::SourcePosition typeOperatorStart = lexer_->GetToken().Start(); in ParseTsTypeOperator()
907 lexer::SourcePosition inferStart = lexer_->GetToken().Start(); in ParseTsInferType()
921 if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { in IsTSNamedTupleMember()
927 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COLON || in IsTSNamedTupleMember()
928 (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_QUESTION_MARK && in IsTSNamedTupleMember()
948 lexer::SourcePosition startPos = lexer_->GetToken().Start(); in ParseTsTupleElement()
953 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PERIOD_PERIOD_PERIOD) { in ParseTsTupleElement()
969 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_QUESTION_MARK) { in ParseTsTupleElement()
977 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COLON) { in ParseTsTupleElement()
1001 lexer::SourcePosition endPos = element->End(); in ParseTsTupleElement()
1006 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_QUESTION_MARK) { in ParseTsTupleElement()
1007 lexer::SourcePosition elementStartPos = element->Start(); in ParseTsTupleElement()
1021 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SQUARE_BRACKET); in ParseTsTupleType()
1022 lexer::SourcePosition tupleStart = lexer_->GetToken().Start(); in ParseTsTupleType()
1030 while (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { in ParseTsTupleType()
1035 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { in ParseTsTupleType()
1039 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COMMA) { in ParseTsTupleType()
1046 lexer::SourcePosition tupleEnd = lexer_->GetToken().End(); in ParseTsTupleType()
1056 lexer::SourcePosition startLoc = typeName->Start(); in ParseTsQualifiedReference()
1059 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); // eat '.' in ParseTsQualifiedReference()
1061 if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { in ParseTsQualifiedReference()
1072 } while (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PERIOD); in ParseTsQualifiedReference()
1089 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { in ParseTsIndexAccessType()
1100 } while (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SQUARE_BRACKET && in ParseTsIndexAccessType()
1108 lexer::SourcePosition referenceStartLoc = lexer_->GetToken().Start(); in ParseTsTypeReferenceOrQuery()
1111 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::KEYW_TYPEOF); in ParseTsTypeReferenceOrQuery()
1114 if (lexer_->GetToken().Type() == lexer::TokenType::KEYW_IMPORT) { in ParseTsTypeReferenceOrQuery()
1115 lexer::SourcePosition &startLoc = referenceStartLoc; in ParseTsTypeReferenceOrQuery()
1119 if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT && in ParseTsTypeReferenceOrQuery()
1120 lexer_->GetToken().Type() != lexer::TokenType::KEYW_THIS) { in ParseTsTypeReferenceOrQuery()
1125 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT || in ParseTsTypeReferenceOrQuery()
1126 lexer_->GetToken().Type() == lexer::TokenType::KEYW_THIS || in ParseTsTypeReferenceOrQuery()
1127 lexer_->GetToken().Type() == lexer::TokenType::KEYW_EXTENDS); in ParseTsTypeReferenceOrQuery()
1134 lexer_->ForwardToken(lexer::TokenType::PUNCTUATOR_LESS_THAN, 1); in ParseTsTypeReferenceOrQuery()
1139 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PERIOD) { in ParseTsTypeReferenceOrQuery()
1144 if (!(lexer_->GetToken().Flags() & lexer::TokenFlags::NEW_LINE) && in ParseTsTypeReferenceOrQuery()
1145 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LESS_THAN) { in ParseTsTypeReferenceOrQuery()
1149 lexer::SourcePosition endLoc = typeParamInst->End(); in ParseTsTypeReferenceOrQuery()
1154 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SQUARE_BRACKET && in ParseTsTypeReferenceOrQuery()
1169 lexer::SourcePosition referenceEndLoc = typeName->End(); in ParseTsTypeReferenceOrQuery()
1184 lexer::SourcePosition startLoc = lexer_->GetToken().Start(); in ParseTsMappedTypeParameter()
1196 lexer::SourcePosition endLoc = constraint->End(); in ParseTsMappedTypeParameter()
1205 ir::MappedOption ParserImpl::ParseMappedOption(lexer::TokenType tokenType) in ParseMappedOption()
1207 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_MINUS && in ParseMappedOption()
1208 lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_PLUS && in ParseMappedOption()
1213 …auto result = lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_MINUS ? ir::MappedOption::… in ParseMappedOption()
1216 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_MINUS || in ParseMappedOption()
1217 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PLUS) { in ParseMappedOption()
1232 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_BRACE); in ParseTsMappedType()
1234 lexer::SourcePosition startLoc = lexer_->GetToken().Start(); in ParseTsMappedType()
1235 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); // eat '{' in ParseTsMappedType()
1237 ir::MappedOption readonly = ParseMappedOption(lexer::TokenType::KEYW_READONLY); in ParseTsMappedType()
1244 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_AS) { in ParseTsMappedType()
1251 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { in ParseTsMappedType()
1257 ir::MappedOption optional = ParseMappedOption(lexer::TokenType::PUNCTUATOR_QUESTION_MARK); in ParseTsMappedType()
1260 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COLON) { in ParseTsMappedType()
1266 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_SEMI_COLON && in ParseTsMappedType()
1267 lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_BRACE) { in ParseTsMappedType()
1271 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SEMI_COLON) { in ParseTsMappedType()
1275 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_BRACE) { in ParseTsMappedType()
1291 lexer::SourcePosition startPos = lexer_->GetToken().Start(); in ParseTsTypePredicate()
1292 bool isAsserts = lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_ASSERTS; in ParseTsTypePredicate()
1295 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_IS) { in ParseTsTypePredicate()
1302 if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT) { in ParseTsTypePredicate()
1313 lexer::SourcePosition endPos; in ParseTsTypePredicate()
1316 if (isAsserts && lexer_->GetToken().KeywordType() != lexer::TokenType::KEYW_IS) { in ParseTsTypePredicate()
1340 if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT && in ParseTsTypeLiteralOrInterfaceKey()
1341 (lexer_->GetToken().KeywordType() != lexer::TokenType::KEYW_NEW || in ParseTsTypeLiteralOrInterfaceKey()
1346 } else if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_NUMBER) { in ParseTsTypeLiteralOrInterfaceKey()
1347 if (lexer_->GetToken().Flags() & lexer::TokenFlags::NUMBER_BIGINT) { in ParseTsTypeLiteralOrInterfaceKey()
1355 } else if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_STRING) { in ParseTsTypeLiteralOrInterfaceKey()
1359 } else if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SQUARE_BRACKET) { in ParseTsTypeLiteralOrInterfaceKey()
1363 …if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT && lexer_->Lookahead() == LEX_CHA… in ParseTsTypeLiteralOrInterfaceKey()
1370 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COLON) { in ParseTsTypeLiteralOrInterfaceKey()
1386 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { in ParseTsTypeLiteralOrInterfaceKey()
1391 } else if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS && in ParseTsTypeLiteralOrInterfaceKey()
1392 lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LESS_THAN && in ParseTsTypeLiteralOrInterfaceKey()
1393 lexer_->GetToken().KeywordType() != lexer::TokenType::KEYW_NEW) { in ParseTsTypeLiteralOrInterfaceKey()
1450 if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { in ParseTsTypeLiteralOrInterfaceKeyModifiers()
1459 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_GET) { in ParseTsTypeLiteralOrInterfaceKeyModifiers()
1460 if (lexer_->GetToken().Flags() & lexer::TokenFlags::HAS_ESCAPE) { in ParseTsTypeLiteralOrInterfaceKeyModifiers()
1466 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_SET) { in ParseTsTypeLiteralOrInterfaceKeyModifiers()
1467 if (lexer_->GetToken().Flags() & lexer::TokenFlags::HAS_ESCAPE) { in ParseTsTypeLiteralOrInterfaceKeyModifiers()
1487 lexer::SourcePosition memberStartLoc = lexer_->GetToken().Start(); in ParseTsTypeLiteralOrInterfaceMember()
1489 …if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_READONLY && nextToken != LEX_CHAR_L… in ParseTsTypeLiteralOrInterfaceMember()
1493 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); in ParseTsTypeLiteralOrInterfaceMember()
1499 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_QUESTION_MARK) { in ParseTsTypeLiteralOrInterfaceMember()
1508 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_NEW && signature) { in ParseTsTypeLiteralOrInterfaceMember()
1511 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS && in ParseTsTypeLiteralOrInterfaceMember()
1512 lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LESS_THAN) { in ParseTsTypeLiteralOrInterfaceMember()
1520 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LESS_THAN) { in ParseTsTypeLiteralOrInterfaceMember()
1527 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS) { in ParseTsTypeLiteralOrInterfaceMember()
1544 …if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS && !isIndexSignatur… in ParseTsTypeLiteralOrInterfaceMember()
1549 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COLON) { in ParseTsTypeLiteralOrInterfaceMember()
1569 } else if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COLON) { in ParseTsTypeLiteralOrInterfaceMember()
1663 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_BRACE); in ParseTsTypeLiteralOrInterface()
1665 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); // eat '{' in ParseTsTypeLiteralOrInterface()
1669 while (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_BRACE) { in ParseTsTypeLiteralOrInterface()
1676 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_RIGHT_BRACE) { in ParseTsTypeLiteralOrInterface()
1680 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COMMA && in ParseTsTypeLiteralOrInterface()
1681 lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_SEMI_COLON) { in ParseTsTypeLiteralOrInterface()
1687 lexer_->GetToken().SetTokenType(lexer::TokenType::LITERAL_IDENT); in ParseTsTypeLiteralOrInterface()
1693 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); in ParseTsTypeLiteralOrInterface()
1701 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SQUARE_BRACKET); in ParseTsArrayType()
1704 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { in ParseTsArrayType()
1708 lexer::SourcePosition endLoc = lexer_->GetToken().End(); in ParseTsArrayType()
1711 lexer::SourcePosition startLoc = elementType->Start(); in ParseTsArrayType()
1721 lexer::SourcePosition startLoc; in ParseTsUnionType()
1740 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_BITWISE_OR) { in ParseTsUnionType()
1754 lexer::SourcePosition endLoc = types.back()->End(); in ParseTsUnionType()
1768 lexer::SourcePosition startLoc; in ParseTsIntersectionType()
1791 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_BITWISE_AND) { in ParseTsIntersectionType()
1804 lexer::SourcePosition endLoc = types.back()->End(); in ParseTsIntersectionType()
1816 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS); in IsTsFunctionType()
1819 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS || in IsTsFunctionType()
1820 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PERIOD_PERIOD_PERIOD) { in IsTsFunctionType()
1827 if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT || in IsTsFunctionType()
1828 …(Extension() == ScriptExtension::TS && lexer_->GetToken().Type() == lexer::TokenType::KEYW_THIS)) { in IsTsFunctionType()
1830 } else if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SQUARE_BRACKET) { in IsTsFunctionType()
1832 } else if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_BRACE) { in IsTsFunctionType()
1843 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COMMA || in IsTsFunctionType()
1844 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_QUESTION_MARK || in IsTsFunctionType()
1845 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COLON || in IsTsFunctionType()
1846 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_EQUAL) { in IsTsFunctionType()
1851 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS) { in IsTsFunctionType()
1853 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_ARROW) { in IsTsFunctionType()
1868 lexer::SourcePosition typeStart = lexer_->GetToken().Start(); in ParseTsParenthesizedOrFunctionType()
1870 bool abstractConstructor = lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_ABSTRACT; in ParseTsParenthesizedOrFunctionType()
1877 if (lexer_->GetToken().Type() == lexer::TokenType::KEYW_NEW) { in ParseTsParenthesizedOrFunctionType()
1881 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS && in ParseTsParenthesizedOrFunctionType()
1882 lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LESS_THAN) { in ParseTsParenthesizedOrFunctionType()
1890 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LESS_THAN || isConstructionType) { in ParseTsParenthesizedOrFunctionType()
1898 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS); in ParseTsParenthesizedOrFunctionType()
1907 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS) { in ParseTsParenthesizedOrFunctionType()
1914 lexer::SourcePosition endLoc = lexer_->GetToken().End(); in ParseTsParenthesizedOrFunctionType()
1923 ir::Expression *ParserImpl::ParseTsFunctionType(lexer::SourcePosition startLoc, bool isConstruction… in ParseTsFunctionType()
1927 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LESS_THAN) { in ParseTsFunctionType()
1930 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS) { in ParseTsFunctionType()
1952 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_ARROW) { in ParseTsFunctionType()
1989 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_MINUS) { in ParseTsBasicType()
1992 if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_NUMBER) { in ParseTsBasicType()
2000 if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_NUMBER) { in ParseTsBasicType()
2001 if (lexer_->GetToken().Flags() & lexer::TokenFlags::NUMBER_BIGINT) { in ParseTsBasicType()
2012 } else if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_STRING) { in ParseTsBasicType()
2017 } else if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_TRUE) { in ParseTsBasicType()
2022 } else if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_FALSE) { in ParseTsBasicType()
2027 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_ANY) { in ParseTsBasicType()
2029 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_BOOLEAN) { in ParseTsBasicType()
2031 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_NUMBER) { in ParseTsBasicType()
2033 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_STRING) { in ParseTsBasicType()
2035 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_UNKNOWN) { in ParseTsBasicType()
2037 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_VOID) { in ParseTsBasicType()
2039 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::LITERAL_NULL) { in ParseTsBasicType()
2041 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_UNDEFINED) { in ParseTsBasicType()
2043 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_NEVER) { in ParseTsBasicType()
2045 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_OBJECT) { in ParseTsBasicType()
2047 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_BIGINT) { in ParseTsBasicType()
2049 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_SYMBOL) { in ParseTsBasicType()
2078 static bool IsModifierKind(const lexer::Token &token) in IsModifierKind()
2080 if (token.Type() == lexer::TokenType::LITERAL_IDENT) { in IsModifierKind()
2082 case lexer::TokenType::KEYW_PUBLIC: in IsModifierKind()
2083 case lexer::TokenType::KEYW_PRIVATE: in IsModifierKind()
2084 case lexer::TokenType::KEYW_PROTECTED: in IsModifierKind()
2085 case lexer::TokenType::KEYW_STATIC: in IsModifierKind()
2086 case lexer::TokenType::KEYW_ASYNC: in IsModifierKind()
2087 case lexer::TokenType::KEYW_ABSTRACT: in IsModifierKind()
2088 case lexer::TokenType::KEYW_DECLARE: in IsModifierKind()
2089 case lexer::TokenType::KEYW_READONLY: in IsModifierKind()
2090 case lexer::TokenType::KEYW_ACCESSOR: in IsModifierKind()
2091 case lexer::TokenType::KEYW_OVERRIDE: in IsModifierKind()
2112 lexer::TokenFlags tokenFlags = lexer_->GetToken().Flags(); in ParseModifiers()
2113 if (tokenFlags & lexer::TokenFlags::HAS_ESCAPE) { in ParseModifiers()
2121 case lexer::TokenType::KEYW_PUBLIC: { in ParseModifiers()
2128 case lexer::TokenType::KEYW_PRIVATE: { in ParseModifiers()
2135 case lexer::TokenType::KEYW_PROTECTED: { in ParseModifiers()
2142 case lexer::TokenType::KEYW_STATIC: { in ParseModifiers()
2148 case lexer::TokenType::KEYW_ASYNC: { in ParseModifiers()
2153 case lexer::TokenType::KEYW_ABSTRACT: { in ParseModifiers()
2160 case lexer::TokenType::KEYW_DECLARE: { in ParseModifiers()
2166 case lexer::TokenType::KEYW_READONLY: { in ParseModifiers()
2171 case lexer::TokenType::KEYW_ACCESSOR: { in ParseModifiers()
2176 case lexer::TokenType::KEYW_OVERRIDE: { in ParseModifiers()
2193 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); in ParseModifiers()
2220 lexer::SourcePosition errorInfo) in CheckAccessorPair()
2281 if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { in ParseClassKeyModifiers()
2292 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_GET) { in ParseClassKeyModifiers()
2293 if (lexer_->GetToken().Flags() & lexer::TokenFlags::HAS_ESCAPE) { in ParseClassKeyModifiers()
2300 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); in ParseClassKeyModifiers()
2302 } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_SET) { in ParseClassKeyModifiers()
2303 if (lexer_->GetToken().Flags() & lexer::TokenFlags::HAS_ESCAPE) { in ParseClassKeyModifiers()
2310 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); in ParseClassKeyModifiers()
2344 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_HASH_MARK) { in ValidateClassKey()
2383 lexer_->GetToken().SetTokenType(lexer::TokenType::LITERAL_IDENT); in ParseClassKey()
2387 case lexer::TokenType::LITERAL_IDENT: { in ParseClassKey()
2394 case lexer::TokenType::LITERAL_STRING: { in ParseClassKey()
2401 case lexer::TokenType::LITERAL_NUMBER: { in ParseClassKey()
2403 if (lexer_->GetToken().Flags() & lexer::TokenFlags::NUMBER_BIGINT) { in ParseClassKey()
2412 case lexer::TokenType::PUNCTUATOR_LEFT_SQUARE_BRACKET: { in ParseClassKey()
2416 …if (Extension() == ScriptExtension::TS && lexer_->GetToken().Type() == lexer::TokenType::LITERAL_I… in ParseClassKey()
2425 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COLON) { in ParseClassKey()
2437 … if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { in ParseClassKey()
2441 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); in ParseClassKey()
2457 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { in ParseClassKey()
2467 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); in ParseClassKey()
2475 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS) { in ValidateClassMethodStart()
2482 …if (!typeAnnotation && (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS… in ValidateClassMethodStart()
2483 … lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LESS_THAN)) { in ValidateClassMethodStart()
2514 lexer::SourcePosition errorInfo) in ValidateClassSetter()
2528 lexer::SourcePosition errorInfo) in ValidateClassGetter()
2599 … ir::Expression *propName, lexer::SourcePosition *propEnd, in ParseClassMethod()
2633 lexer::SourcePosition errorInfo = decorators.empty() ? func->Start() : decorators[0]->Start(); in ParseClassMethod()
2648 … auto privateIdStart = lexer::SourcePosition(propName->Start().index - 1, propName->Start().line); in ParseClassMethod()
2682 lexer::SourcePosition propEnd = propName->End(); in ParseClassProperty()
2702 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SUBSTITUTION) { in ParseClassProperty()
2723 … auto privateIdStart = lexer::SourcePosition(propName->Start().index - 1, propName->Start().line); in ParseClassProperty()
2738 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_MULTIPLY) { in CheckClassGeneratorMethod()
2743 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); in CheckClassGeneratorMethod()
2748 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_HASH_MARK) { in CheckClassPrivateIdentifier()
2759 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); in CheckClassPrivateIdentifier()
2779 …if (Extension() == ScriptExtension::TS && lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATO… in ParseClassKeyAnnotation()
2791 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_AT); in ParseDecoratorAndAnnotation()
2794 lexer::SourcePosition start = lexer_->GetToken().Start(); in ParseDecoratorAndAnnotation()
2797 if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT && in ParseDecoratorAndAnnotation()
2832 while (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_AT) { in ParseDecoratorsAndAnnotations()
2846 if (!decorators.empty() && lexer_->GetToken().Type() != lexer::TokenType::KEYW_CLASS && in ParseDecoratorsAndAnnotations()
2848 lexer_->GetToken().Type() != lexer::TokenType::KEYW_EXPORT && in ParseDecoratorsAndAnnotations()
2849 !(lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT && in ParseDecoratorsAndAnnotations()
2850 (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_DECLARE || in ParseDecoratorsAndAnnotations()
2851 lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_ABSTRACT))) { in ParseDecoratorsAndAnnotations()
2888 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_BRACE) { in ParseClassElement()
2918 …if (Extension() == ScriptExtension::TS && lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATO… in ParseClassElement()
2934 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_EXCLAMATION_MARK) { in ParseClassElement()
2971 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_SEMI_COLON && in ParseClassElement()
2972 lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_BRACE && in ParseClassElement()
2973 !(lexer_->GetToken().Flags() & lexer::TokenFlags::NEW_LINE) && in ParseClassElement()
2978 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SEMI_COLON) { in ParseClassElement()
2979 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); in ParseClassElement()
3159 lexer::SourcePosition startLoc = lexer_->GetToken().Start(); in ParseClassDefinition()
3167 if ((lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT || in ParseClassDefinition()
3168 …lexer_->GetToken().Type() == lexer::TokenType::KEYW_AWAIT) && (Extension() != ScriptExtension::TS … in ParseClassDefinition()
3169 lexer_->GetToken().KeywordType() != lexer::TokenType::KEYW_IMPLEMENTS)) { in ParseClassDefinition()
3176 …if (Extension() == ScriptExtension::TS && lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATO… in ParseClassDefinition()
3186 …if (Extension() == ScriptExtension::TS && (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUAT… in ParseClassDefinition()
3187 … lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SHIFT)) { in ParseClassDefinition()
3188 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SHIFT) { in ParseClassDefinition()
3189 lexer_->BackwardToken(lexer::TokenType::PUNCTUATOR_LESS_THAN, 1); in ParseClassDefinition()
3197 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_BRACE) { in ParseClassDefinition()
3205 lexer::SourcePosition classBodyStartLoc = lexer_->GetToken().Start(); in ParseClassDefinition()
3206 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); in ParseClassDefinition()
3224 while (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_BRACE) { in ParseClassDefinition()
3225 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SEMI_COLON) { in ParseClassDefinition()
3256 lexer::SourcePosition classBodyEndLoc = lexer_->GetToken().End(); in ParseClassDefinition()
3285 if (lexer_->GetToken().Type() != lexer::TokenType::KEYW_EXTENDS) { in ParseSuperClass()
3290 if (lexer_->GetToken().Type() == lexer::TokenType::KEYW_AWAIT && isDeclare) { in ParseSuperClass()
3291 lexer_->GetToken().SetTokenType(lexer::TokenType::LITERAL_IDENT); in ParseSuperClass()
3306 …if (Extension() != ScriptExtension::TS || lexer_->GetToken().KeywordType() != lexer::TokenType::KE… in ParseTSClassImplements()
3311 while (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_BRACE) { in ParseTSClassImplements()
3312 lexer::SourcePosition implStart = lexer_->GetToken().Start(); in ParseTSClassImplements()
3313 if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT && in ParseTSClassImplements()
3314 !(lexer_->GetToken().Type() == lexer::TokenType::KEYW_AWAIT && isDeclare)) { in ParseTSClassImplements()
3321 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PERIOD) { in ParseTSClassImplements()
3325 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SHIFT) { in ParseTSClassImplements()
3326 lexer_->BackwardToken(lexer::TokenType::PUNCTUATOR_LESS_THAN, 1); in ParseTSClassImplements()
3328 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LESS_THAN || in ParseTSClassImplements()
3329 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SHIFT) { in ParseTSClassImplements()
3335 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COMMA) { in ParseTSClassImplements()
3339 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_BRACE) { in ParseTSClassImplements()
3514 … const lexer::SourcePosition &keyStartLoc, bool isDeclare) in ParseEnumComputedPropertyKey()
3519 if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_STRING) { in ParseEnumComputedPropertyKey()
3524 } else if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_BACK_TICK) { in ParseEnumComputedPropertyKey()
3543 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { in ParseEnumComputedPropertyKey()
3552 ir::TSEnumDeclaration *ParserImpl::ParseEnumMembers(ir::Identifier *key, const lexer::SourcePositio… in ParseEnumMembers()
3555 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_BRACE) { in ParseEnumMembers()
3560 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); // eat '{' in ParseEnumMembers()
3562 while (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_BRACE) { in ParseEnumMembers()
3567 if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT) { in ParseEnumMembers()
3572 } else if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_STRING) { in ParseEnumMembers()
3577 } else if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SQUARE_BRACKET) { in ParseEnumMembers()
3584 lexer::SourcePosition initStart = lexer_->GetToken().Start(); in ParseEnumMembers()
3586 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SUBSTITUTION) { in ParseEnumMembers()
3597 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COMMA) { in ParseEnumMembers()
3598 lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); // eat ',' in ParseEnumMembers()
3613 ASSERT(lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_ENUM); in ParseEnumDeclaration()
3614 lexer::SourcePosition enumStart = lexer_->GetToken().Start(); in ParseEnumDeclaration()
3617 if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT && in ParseEnumDeclaration()
3618 lexer_->GetToken().Type() != lexer::TokenType::KEYW_AWAIT) { in ParseEnumDeclaration()
3669 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS) { in ValidateFunctionParam()
3715 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS); in ParseFunctionParams()
3722 while (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS) { in ParseFunctionParams()
3742 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COMMA && in ParseFunctionParams()
3743 lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS) { in ParseFunctionParams()
3747 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COMMA) { in ParseFunctionParams()
3754 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS); in ParseFunctionParams()
3772 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_GREATER_THAN || in CheckOutIsIdentInTypeParameter()
3773 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COMMA) { in CheckOutIsIdentInTypeParameter()
3784 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_IN) { in ParseTypeModifier()
3790 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_IN) { in ParseTypeModifier()
3794 …if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_OUT && !CheckOutIsIdentInTypeParame… in ParseTypeModifier()
3797 …if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_OUT && !CheckOutIsIdentInTypeParame… in ParseTypeModifier()
3801 …} else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_OUT && !CheckOutIsIdentInTyp… in ParseTypeModifier()
3809 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_IN) { in ParseTypeModifier()
3813 …if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_OUT && !CheckOutIsIdentInTypeParame… in ParseTypeModifier()
3821 lexer::SourcePosition startLoc = lexer_->GetToken().Start(); in ParseTsTypeParameter()
3827 if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { in ParseTsTypeParameter()
3864 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SUBSTITUTION) { in ParseTsTypeParameter()
3879 if (lexer_->GetToken().Type() == lexer::TokenType::KEYW_EXTENDS) { in TryParseConstraintOfInferType()
3884 lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_QUESTION_MARK) { in TryParseConstraintOfInferType()
3894 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LESS_THAN); in ParseTsTypeParameterDeclaration()
3898 lexer::SourcePosition startLoc = lexer_->GetToken().Start(); in ParseTsTypeParameterDeclaration()
3904 while (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_GREATER_THAN) { in ParseTsTypeParameterDeclaration()
3922 if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COMMA) { in ParseTsTypeParameterDeclaration()
3927 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_GREATER_THAN) { in ParseTsTypeParameterDeclaration()
3940 lexer::SourcePosition endLoc = lexer_->GetToken().End(); in ParseTsTypeParameterDeclaration()
3953 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LESS_THAN); in ParseTsTypeParameterInstantiation()
3954 lexer::SourcePosition startLoc = lexer_->GetToken().Start(); in ParseTsTypeParameterInstantiation()
3958 while (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_GREATER_THAN) { in ParseTsTypeParameterInstantiation()
3974 case lexer::TokenType::PUNCTUATOR_COMMA: { in ParseTsTypeParameterInstantiation()
3978 case lexer::TokenType::PUNCTUATOR_RIGHT_SHIFT: { in ParseTsTypeParameterInstantiation()
3979 lexer_->BackwardToken(lexer::TokenType::PUNCTUATOR_GREATER_THAN, 1); in ParseTsTypeParameterInstantiation()
3982 case lexer::TokenType::PUNCTUATOR_UNSIGNED_RIGHT_SHIFT: { in ParseTsTypeParameterInstantiation()
3983 lexer_->BackwardToken(lexer::TokenType::PUNCTUATOR_GREATER_THAN, 2); in ParseTsTypeParameterInstantiation()
3986 case lexer::TokenType::PUNCTUATOR_GREATER_THAN: { in ParseTsTypeParameterInstantiation()
3999 lexer::SourcePosition endLoc = lexer_->GetToken().End(); in ParseTsTypeParameterInstantiation()
4018 lexer::SourcePosition startLoc = lexer_->GetToken().Start(); in ParseFunction()
4021 …if (Extension() == ScriptExtension::TS && lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATO… in ParseFunction()
4025 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS) { in ParseFunction()
4037 …if (Extension() == ScriptExtension::TS && lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATO… in ParseFunction()
4050 lexer::SourcePosition endLoc = lexer_->GetToken().End(); in ParseFunction()
4063 if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_BRACE) { in ParseFunction()
4105 ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PERIOD_PERIOD_PERIOD); in ParseSpreadElement()
4106 lexer::SourcePosition startLocation = lexer_->GetToken().Start(); in ParseSpreadElement()
4122 …if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COLON && Extension() == ScriptExtens… in ParseSpreadElement()
4132 lexer::SourcePosition endLoc = typeAnnotation ? typeAnnotation->End() : argument->End(); in ParseSpreadElement()
4178 …if (Extension() == ScriptExtension::TS && lexer_->GetToken().KeywordType() == lexer::TokenType::KE… in ParseFunctionParameter()
4179 lexer_->GetToken().SetTokenType(lexer::TokenType::LITERAL_IDENT); in ParseFunctionParameter()
4182 lexer::SourcePosition parameterStart = lexer_->GetToken().Start(); in ParseFunctionParameter()
4188 lexer::TokenType tokenType = lexer_->GetToken().Type(); in ParseFunctionParameter()
4189 if (tokenType == lexer::TokenType::LITERAL_IDENT && in ParseFunctionParameter()
4190 (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_ARGUMENTS || in ParseFunctionParameter()
4191 lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_EVAL)) { in ParseFunctionParameter()
4352 void ParserImpl::ThrowSyntaxError(std::initializer_list<std::string_view> list, const lexer::Source… in ThrowSyntaxError()
4365 void ParserImpl::ThrowSyntaxError(std::string_view errorMessage, const lexer::SourcePosition &pos) … in ThrowSyntaxError()
4367 lexer::LineIndex index(program_.SourceCode()); in ThrowSyntaxError()
4368 lexer::SourceLocation loc = index.GetLocation(pos); in ThrowSyntaxError()
4405 if (lexer_->GetToken().KeywordType() >= lexer::TokenType::KEYW_ARGUMENTS) { in CheckStrictReservedWord()
4410 if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_AWAIT && in CheckStrictReservedWord()
4471 lexer::LineIndex index(program_.SourceCode()); in RecursiveDepthException()
4472 lexer::SourceLocation loc = index.GetLocation(pos); in RecursiveDepthException()