mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Revert "Refactor: Rename Parser::consumeToken, consumeLoc. Add consumeToken API."
This reverts commit 39bfc123a3.
This commit is contained in:
@@ -321,10 +321,10 @@ public:
|
|||||||
void restoreParserPosition(ParserPosition PP) {
|
void restoreParserPosition(ParserPosition PP) {
|
||||||
L->restoreState(PP.LS);
|
L->restoreState(PP.LS);
|
||||||
|
|
||||||
// We might be at tok::eof now, so ensure that consumeLoc()
|
// We might be at tok::eof now, so ensure that consumeToken()
|
||||||
// does not assert about lexing past eof.
|
// does not assert about lexing past eof.
|
||||||
Tok = syntax::Token::unknown();
|
Tok = syntax::Token::unknown();
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
PreviousLoc = PP.PreviousLoc;
|
PreviousLoc = PP.PreviousLoc;
|
||||||
}
|
}
|
||||||
@@ -334,10 +334,10 @@ public:
|
|||||||
|
|
||||||
L->backtrackToState(PP.LS);
|
L->backtrackToState(PP.LS);
|
||||||
|
|
||||||
// We might be at tok::eof now, so ensure that consumeLoc()
|
// We might be at tok::eof now, so ensure that consumeToken()
|
||||||
// does not assert about lexing past eof.
|
// does not assert about lexing past eof.
|
||||||
Tok = syntax::Token::unknown();
|
Tok = syntax::Token::unknown();
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
PreviousLoc = PP.PreviousLoc;
|
PreviousLoc = PP.PreviousLoc;
|
||||||
}
|
}
|
||||||
@@ -386,14 +386,13 @@ public:
|
|||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Utilities
|
// Utilities
|
||||||
|
|
||||||
/// \brief Return the next token that will be installed by \c consumeLoc.
|
/// \brief Return the next token that will be installed by \c consumeToken.
|
||||||
const syntax::Token &peekToken();
|
const syntax::Token &peekToken();
|
||||||
|
|
||||||
syntax::Token consumeToken();
|
SourceLoc consumeToken();
|
||||||
SourceLoc consumeLoc();
|
SourceLoc consumeToken(tok K) {
|
||||||
SourceLoc consumeLoc(tok K) {
|
|
||||||
assert(Tok.is(K) && "Consuming wrong token kind");
|
assert(Tok.is(K) && "Consuming wrong token kind");
|
||||||
return consumeLoc();
|
return consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceLoc consumeIdentifier(Identifier *Result = nullptr) {
|
SourceLoc consumeIdentifier(Identifier *Result = nullptr) {
|
||||||
@@ -401,7 +400,7 @@ public:
|
|||||||
tok::kw_Self, tok::kw_throws));
|
tok::kw_Self, tok::kw_throws));
|
||||||
if (Result)
|
if (Result)
|
||||||
*Result = Context.getIdentifier(Tok.getText().str());
|
*Result = Context.getIdentifier(Tok.getText().str());
|
||||||
return consumeLoc();
|
return consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Retrieve the location just past the end of the previous
|
/// \brief Retrieve the location just past the end of the previous
|
||||||
@@ -412,7 +411,7 @@ public:
|
|||||||
/// return true. Otherwise, return false without consuming it.
|
/// return true. Otherwise, return false without consuming it.
|
||||||
bool consumeIf(tok K) {
|
bool consumeIf(tok K) {
|
||||||
if (Tok.isNot(K)) return false;
|
if (Tok.isNot(K)) return false;
|
||||||
consumeLoc(K);
|
consumeToken(K);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,7 +419,7 @@ public:
|
|||||||
/// return true. Otherwise, return false without consuming it.
|
/// return true. Otherwise, return false without consuming it.
|
||||||
bool consumeIf(tok K, SourceLoc &consumedLoc) {
|
bool consumeIf(tok K, SourceLoc &consumedLoc) {
|
||||||
if (Tok.isNot(K)) return false;
|
if (Tok.isNot(K)) return false;
|
||||||
consumedLoc = consumeLoc(K);
|
consumedLoc = consumeToken(K);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
//===--- RawSyntax.h - Swift Raw Syntax Nodes -------------------*- C++ -*-===//
|
|
||||||
//
|
|
||||||
// This source file is part of the Swift.org open source project
|
|
||||||
//
|
|
||||||
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
|
|
||||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
||||||
//
|
|
||||||
// See http://swift.org/LICENSE.txt for license information
|
|
||||||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// This file defines the RawSyntax class - the immutable, persistent backing
|
|
||||||
// for syntactic information in the AST. These are raw containers of child
|
|
||||||
// relationships and the layout of a particular node. For example:
|
|
||||||
//
|
|
||||||
// func foo() {
|
|
||||||
// // body ...
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// This function declaration is laid out as following:
|
|
||||||
// - func token
|
|
||||||
// - foo identifier token
|
|
||||||
// - child: argument list
|
|
||||||
// - child: brace statement
|
|
||||||
//
|
|
||||||
// And would have two children.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#ifndef SWIFT_SYNTAX_RAWSYNTAX_H
|
|
||||||
#define SWIFT_SYNTAX_RAWSYNTAX_H
|
|
||||||
|
|
||||||
namespace swift {
|
|
||||||
namespace syntax {
|
|
||||||
|
|
||||||
struct RawSyntax;
|
|
||||||
using RawSyntaxRef = llvm::IntrusiveRefCntPtr<RawSyntax>;
|
|
||||||
|
|
||||||
enum class RawSyntaxLayoutKind {
|
|
||||||
/// The layout element is a terminal token.
|
|
||||||
Token,
|
|
||||||
|
|
||||||
/// The layout element is a child syntax node.
|
|
||||||
ChildIndex,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RawSyntaxLayout {
|
|
||||||
const RawSyntaxLayoutKind Kind;
|
|
||||||
private:
|
|
||||||
union {
|
|
||||||
syntax::Token Tok;
|
|
||||||
size_t ChildIndex;
|
|
||||||
} Data;
|
|
||||||
|
|
||||||
public:
|
|
||||||
const syntax::Token &getToken() const {
|
|
||||||
assert(Kind == RawSyntaxLayoutKind::Token);
|
|
||||||
return Data.Tok;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t getChildIndex() const {
|
|
||||||
assert(Kind == RawSyntaxLayoutKind::ChildIndex);
|
|
||||||
return Data.ChildIndex;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RawSyntax : public llvm::ThreadSafeRefCountedBase<RawSyntax> {
|
|
||||||
const std::vector<RawSyntaxRef> Children;
|
|
||||||
const std::vector<RawSyntaxLayout> Layout;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace syntax
|
|
||||||
} // end namespace swift
|
|
||||||
|
|
||||||
#endif // SWIFT_SYNTAX_RAWSYNTAX_H
|
|
||||||
@@ -185,7 +185,7 @@ bool Parser::parseTopLevel() {
|
|||||||
|
|
||||||
// Prime the lexer.
|
// Prime the lexer.
|
||||||
if (Tok.is(tok::NUM_TOKENS))
|
if (Tok.is(tok::NUM_TOKENS))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
// Parse the body of the file.
|
// Parse the body of the file.
|
||||||
SmallVector<ASTNode, 128> Items;
|
SmallVector<ASTNode, 128> Items;
|
||||||
@@ -234,7 +234,7 @@ bool Parser::parseTopLevel() {
|
|||||||
Tok.is(tok::pound_endif)) {
|
Tok.is(tok::pound_endif)) {
|
||||||
diagnose(Tok.getLoc(),
|
diagnose(Tok.getLoc(),
|
||||||
diag::unexpected_conditional_compilation_block_terminator);
|
diag::unexpected_conditional_compilation_block_terminator);
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is a Main source file, determine if we found code that needs to be
|
// If this is a Main source file, determine if we found code that needs to be
|
||||||
@@ -270,7 +270,7 @@ bool Parser::skipExtraTopLevelRBraces() {
|
|||||||
while (Tok.is(tok::r_brace)) {
|
while (Tok.is(tok::r_brace)) {
|
||||||
diagnose(Tok, diag::extra_rbrace)
|
diagnose(Tok, diag::extra_rbrace)
|
||||||
.fixItRemove(Tok.getLoc());
|
.fixItRemove(Tok.getLoc());
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -297,7 +297,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
DeclAttrKind DK) {
|
DeclAttrKind DK) {
|
||||||
// Ok, it is a valid attribute, eat it, and then process it.
|
// Ok, it is a valid attribute, eat it, and then process it.
|
||||||
auto AttrName = Tok.getText().str();
|
auto AttrName = Tok.getText().str();
|
||||||
SourceLoc Loc = consumeLoc();
|
SourceLoc Loc = consumeToken();
|
||||||
bool DiscardAttribute = false;
|
bool DiscardAttribute = false;
|
||||||
|
|
||||||
// Diagnose duplicated attributes.
|
// Diagnose duplicated attributes.
|
||||||
@@ -347,10 +347,10 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Consume the '('.
|
// Consume the '('.
|
||||||
SourceLoc lParenLoc = consumeLoc(tok::l_paren);
|
SourceLoc lParenLoc = consumeToken(tok::l_paren);
|
||||||
|
|
||||||
// Consume the 'escaping'.
|
// Consume the 'escaping'.
|
||||||
(void)consumeLoc();
|
(void)consumeToken();
|
||||||
|
|
||||||
// Parse the closing ')'.
|
// Parse the closing ')'.
|
||||||
SourceLoc rParenLoc;
|
SourceLoc rParenLoc;
|
||||||
@@ -406,7 +406,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AttrRange = SourceRange(Loc, Tok.getRange().getStart());
|
AttrRange = SourceRange(Loc, Tok.getRange().getStart());
|
||||||
consumeLoc(tok::identifier);
|
consumeToken(tok::identifier);
|
||||||
|
|
||||||
if (!consumeIf(tok::r_paren)) {
|
if (!consumeIf(tok::r_paren)) {
|
||||||
diagnose(Loc, diag::attr_expected_rparen, AttrName,
|
diagnose(Loc, diag::attr_expected_rparen, AttrName,
|
||||||
@@ -441,7 +441,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
Tok.getText(), AttrName);
|
Tok.getText(), AttrName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
consumeLoc(tok::identifier);
|
consumeToken(tok::identifier);
|
||||||
AttrRange = SourceRange(Loc, Tok.getRange().getStart());
|
AttrRange = SourceRange(Loc, Tok.getRange().getStart());
|
||||||
|
|
||||||
if (!consumeIf(tok::r_paren)) {
|
if (!consumeIf(tok::r_paren)) {
|
||||||
@@ -463,11 +463,11 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
|
|
||||||
if (Kind == Ownership::Unowned && Tok.is(tok::l_paren)) {
|
if (Kind == Ownership::Unowned && Tok.is(tok::l_paren)) {
|
||||||
// Parse an optional specifier after unowned.
|
// Parse an optional specifier after unowned.
|
||||||
SourceLoc lp = consumeLoc(tok::l_paren);
|
SourceLoc lp = consumeToken(tok::l_paren);
|
||||||
if (Tok.is(tok::identifier) && Tok.getText() == "safe") {
|
if (Tok.is(tok::identifier) && Tok.getText() == "safe") {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
} else if (Tok.is(tok::identifier) && Tok.getText() == "unsafe") {
|
} else if (Tok.is(tok::identifier) && Tok.getText() == "unsafe") {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
Kind = Ownership::Unmanaged;
|
Kind = Ownership::Unmanaged;
|
||||||
} else {
|
} else {
|
||||||
diagnose(Tok, diag::attr_unowned_invalid_specifier);
|
diagnose(Tok, diag::attr_unowned_invalid_specifier);
|
||||||
@@ -511,15 +511,15 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
|
|
||||||
// Parse the subject.
|
// Parse the subject.
|
||||||
if (Tok.isContextualKeyword("set")) {
|
if (Tok.isContextualKeyword("set")) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
} else {
|
} else {
|
||||||
diagnose(Loc, diag::attr_accessibility_expected_set, AttrName);
|
diagnose(Loc, diag::attr_accessibility_expected_set, AttrName);
|
||||||
// Minimal recovery: if there's a single token and then an r_paren,
|
// Minimal recovery: if there's a single token and then an r_paren,
|
||||||
// consume them both. If there's just an r_paren, consume that.
|
// consume them both. If there's just an r_paren, consume that.
|
||||||
if (!consumeIf(tok::r_paren)) {
|
if (!consumeIf(tok::r_paren)) {
|
||||||
if (Tok.isNot(tok::l_paren) && peekToken().is(tok::r_paren)) {
|
if (Tok.isNot(tok::l_paren) && peekToken().is(tok::r_paren)) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
consumeLoc(tok::r_paren);
|
consumeToken(tok::r_paren);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -558,7 +558,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
Optional<StringRef> AsmName =
|
Optional<StringRef> AsmName =
|
||||||
getStringLiteralIfNotInterpolated(*this, Loc, Tok, AttrName);
|
getStringLiteralIfNotInterpolated(*this, Loc, Tok, AttrName);
|
||||||
|
|
||||||
consumeLoc(tok::string_literal);
|
consumeToken(tok::string_literal);
|
||||||
|
|
||||||
if (AsmName.hasValue())
|
if (AsmName.hasValue())
|
||||||
AttrRange = SourceRange(Loc, Tok.getRange().getStart());
|
AttrRange = SourceRange(Loc, Tok.getRange().getStart());
|
||||||
@@ -610,7 +610,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
if (alignmentText.getAsInteger(0, alignmentValue))
|
if (alignmentText.getAsInteger(0, alignmentValue))
|
||||||
llvm_unreachable("not valid integer literal token?!");
|
llvm_unreachable("not valid integer literal token?!");
|
||||||
|
|
||||||
consumeLoc(tok::integer_literal);
|
consumeToken(tok::integer_literal);
|
||||||
|
|
||||||
auto range = SourceRange(Loc, Tok.getRange().getStart());
|
auto range = SourceRange(Loc, Tok.getRange().getStart());
|
||||||
|
|
||||||
@@ -640,7 +640,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
|
|
||||||
Identifier name = Context.getIdentifier(Tok.getText());
|
Identifier name = Context.getIdentifier(Tok.getText());
|
||||||
|
|
||||||
consumeLoc(tok::identifier);
|
consumeToken(tok::identifier);
|
||||||
|
|
||||||
auto range = SourceRange(Loc, Tok.getRange().getStart());
|
auto range = SourceRange(Loc, Tok.getRange().getStart());
|
||||||
|
|
||||||
@@ -669,7 +669,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
|
|
||||||
auto Value = getStringLiteralIfNotInterpolated(*this, Loc, Tok, AttrName);
|
auto Value = getStringLiteralIfNotInterpolated(*this, Loc, Tok, AttrName);
|
||||||
|
|
||||||
consumeLoc(tok::string_literal);
|
consumeToken(tok::string_literal);
|
||||||
|
|
||||||
if (Value.hasValue())
|
if (Value.hasValue())
|
||||||
AttrRange = SourceRange(Loc, Tok.getRange().getStart());
|
AttrRange = SourceRange(Loc, Tok.getRange().getStart());
|
||||||
@@ -711,7 +711,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
!(Tok.isAnyOperator() && Tok.getText() == "*")) {
|
!(Tok.isAnyOperator() && Tok.getText() == "*")) {
|
||||||
if (Tok.is(tok::code_complete) && CodeCompletion) {
|
if (Tok.is(tok::code_complete) && CodeCompletion) {
|
||||||
CodeCompletion->completeDeclAttrParam(DAK_Available, 0);
|
CodeCompletion->completeDeclAttrParam(DAK_Available, 0);
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
}
|
}
|
||||||
diagnose(Tok.getLoc(), diag::attr_availability_platform, AttrName)
|
diagnose(Tok.getLoc(), diag::attr_availability_platform, AttrName)
|
||||||
.highlight(SourceRange(Tok.getLoc()));
|
.highlight(SourceRange(Tok.getLoc()));
|
||||||
@@ -791,7 +791,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
StringRef Message, Renamed;
|
StringRef Message, Renamed;
|
||||||
clang::VersionTuple Introduced, Deprecated, Obsoleted;
|
clang::VersionTuple Introduced, Deprecated, Obsoleted;
|
||||||
@@ -830,27 +830,27 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
.highlight(SourceRange(Tok.getLoc()));
|
.highlight(SourceRange(Tok.getLoc()));
|
||||||
if (Tok.is(tok::code_complete) && CodeCompletion) {
|
if (Tok.is(tok::code_complete) && CodeCompletion) {
|
||||||
CodeCompletion->completeDeclAttrParam(DAK_Available, ParamIndex);
|
CodeCompletion->completeDeclAttrParam(DAK_Available, ParamIndex);
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
} else {
|
} else {
|
||||||
consumeIf(tok::identifier);
|
consumeIf(tok::identifier);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
switch (ArgumentKind) {
|
switch (ArgumentKind) {
|
||||||
case IsMessage:
|
case IsMessage:
|
||||||
case IsRenamed: {
|
case IsRenamed: {
|
||||||
// Items with string arguments.
|
// Items with string arguments.
|
||||||
if (findAttrValueDelimiter()) {
|
if (findAttrValueDelimiter()) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
} else {
|
} else {
|
||||||
diagnose(Tok, diag::attr_availability_expected_equal,
|
diagnose(Tok, diag::attr_availability_expected_equal,
|
||||||
AttrName, ArgumentKindStr);
|
AttrName, ArgumentKindStr);
|
||||||
DiscardAttribute = true;
|
DiscardAttribute = true;
|
||||||
if (peekToken().isAny(tok::r_paren, tok::comma))
|
if (peekToken().isAny(tok::r_paren, tok::comma))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -858,13 +858,13 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
diagnose(Loc, diag::attr_expected_string_literal, AttrName);
|
diagnose(Loc, diag::attr_expected_string_literal, AttrName);
|
||||||
DiscardAttribute = true;
|
DiscardAttribute = true;
|
||||||
if (peekToken().isAny(tok::r_paren, tok::comma))
|
if (peekToken().isAny(tok::r_paren, tok::comma))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Value =
|
auto Value =
|
||||||
getStringLiteralIfNotInterpolated(*this, Loc, Tok, ArgumentKindStr);
|
getStringLiteralIfNotInterpolated(*this, Loc, Tok, ArgumentKindStr);
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (!Value) {
|
if (!Value) {
|
||||||
DiscardAttribute = true;
|
DiscardAttribute = true;
|
||||||
continue;
|
continue;
|
||||||
@@ -901,13 +901,13 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
case IsObsoleted: {
|
case IsObsoleted: {
|
||||||
// Items with version arguments.
|
// Items with version arguments.
|
||||||
if (findAttrValueDelimiter()) {
|
if (findAttrValueDelimiter()) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
} else {
|
} else {
|
||||||
diagnose(Tok, diag::attr_availability_expected_equal,
|
diagnose(Tok, diag::attr_availability_expected_equal,
|
||||||
AttrName, ArgumentKindStr);
|
AttrName, ArgumentKindStr);
|
||||||
DiscardAttribute = true;
|
DiscardAttribute = true;
|
||||||
if (peekToken().isAny(tok::r_paren, tok::comma))
|
if (peekToken().isAny(tok::r_paren, tok::comma))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -923,7 +923,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
AttrName))) {
|
AttrName))) {
|
||||||
DiscardAttribute = true;
|
DiscardAttribute = true;
|
||||||
if (peekToken().isAny(tok::r_paren, tok::comma))
|
if (peekToken().isAny(tok::r_paren, tok::comma))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -1007,7 +1007,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse the leading '('.
|
// Parse the leading '('.
|
||||||
SourceLoc LParenLoc = consumeLoc(tok::l_paren);
|
SourceLoc LParenLoc = consumeToken(tok::l_paren);
|
||||||
|
|
||||||
// Parse the names, with trailing colons (if there are present).
|
// Parse the names, with trailing colons (if there are present).
|
||||||
SmallVector<Identifier, 4> Names;
|
SmallVector<Identifier, 4> Names;
|
||||||
@@ -1019,7 +1019,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
Names.push_back(Identifier());
|
Names.push_back(Identifier());
|
||||||
NameLocs.push_back(Tok.getLoc());
|
NameLocs.push_back(Tok.getLoc());
|
||||||
sawColon = true;
|
sawColon = true;
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1027,11 +1027,11 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
if (Tok.is(tok::identifier) || Tok.isKeyword()) {
|
if (Tok.is(tok::identifier) || Tok.isKeyword()) {
|
||||||
Names.push_back(Context.getIdentifier(Tok.getText()));
|
Names.push_back(Context.getIdentifier(Tok.getText()));
|
||||||
NameLocs.push_back(Tok.getLoc());
|
NameLocs.push_back(Tok.getLoc());
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
// If we have a colon, consume it.
|
// If we have a colon, consume it.
|
||||||
if (Tok.is(tok::colon)) {
|
if (Tok.is(tok::colon)) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
sawColon = true;
|
sawColon = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1099,7 +1099,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceLoc lParenLoc = consumeLoc();
|
SourceLoc lParenLoc = consumeToken();
|
||||||
|
|
||||||
SmallVector<TypeLoc, 8> TypeList;
|
SmallVector<TypeLoc, 8> TypeList;
|
||||||
do {
|
do {
|
||||||
@@ -1162,12 +1162,12 @@ bool Parser::parseVersionTuple(clang::VersionTuple &Version,
|
|||||||
if (Tok.getText().getAsInteger(10, major)) {
|
if (Tok.getText().getAsInteger(10, major)) {
|
||||||
// Maybe the literal was in hex. Reject that.
|
// Maybe the literal was in hex. Reject that.
|
||||||
diagnose(Tok, D);
|
diagnose(Tok, D);
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Version = clang::VersionTuple(major);
|
Version = clang::VersionTuple(major);
|
||||||
Range = SourceRange(StartLoc, Tok.getLoc());
|
Range = SourceRange(StartLoc, Tok.getLoc());
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1177,12 +1177,12 @@ bool Parser::parseVersionTuple(clang::VersionTuple &Version,
|
|||||||
if (majorPart.getAsInteger(10, major) || minorPart.getAsInteger(10, minor)) {
|
if (majorPart.getAsInteger(10, major) || minorPart.getAsInteger(10, minor)) {
|
||||||
// Reject things like 0.1e5 and hex literals.
|
// Reject things like 0.1e5 and hex literals.
|
||||||
diagnose(Tok, D);
|
diagnose(Tok, D);
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Range = SourceRange(StartLoc, Tok.getLoc());
|
Range = SourceRange(StartLoc, Tok.getLoc());
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
if (consumeIf(tok::period)) {
|
if (consumeIf(tok::period)) {
|
||||||
unsigned micro = 0;
|
unsigned micro = 0;
|
||||||
@@ -1192,12 +1192,12 @@ bool Parser::parseVersionTuple(clang::VersionTuple &Version,
|
|||||||
diagnose(Tok, D);
|
diagnose(Tok, D);
|
||||||
if (Tok.is(tok::integer_literal) ||
|
if (Tok.is(tok::integer_literal) ||
|
||||||
peekToken().isAny(tok::r_paren, tok::comma))
|
peekToken().isAny(tok::r_paren, tok::comma))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Range = SourceRange(StartLoc, Tok.getLoc());
|
Range = SourceRange(StartLoc, Tok.getLoc());
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
Version = clang::VersionTuple(major, minor, micro);
|
Version = clang::VersionTuple(major, minor, micro);
|
||||||
} else {
|
} else {
|
||||||
@@ -1255,7 +1255,7 @@ bool Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc) {
|
|||||||
if (DK == DAK_Count && Tok.getText() == "warn_unused_result") {
|
if (DK == DAK_Count && Tok.getText() == "warn_unused_result") {
|
||||||
// The behavior created by @warn_unused_result is now the default. Emit a
|
// The behavior created by @warn_unused_result is now the default. Emit a
|
||||||
// Fix-It to remove.
|
// Fix-It to remove.
|
||||||
SourceLoc attrLoc = consumeLoc();
|
SourceLoc attrLoc = consumeToken();
|
||||||
|
|
||||||
// @warn_unused_result with no arguments.
|
// @warn_unused_result with no arguments.
|
||||||
if (Tok.isNot(tok::l_paren)) {
|
if (Tok.isNot(tok::l_paren)) {
|
||||||
@@ -1266,7 +1266,7 @@ bool Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @warn_unused_result with arguments.
|
// @warn_unused_result with arguments.
|
||||||
SourceLoc lParenLoc = consumeLoc();
|
SourceLoc lParenLoc = consumeToken();
|
||||||
skipUntil(tok::r_paren);
|
skipUntil(tok::r_paren);
|
||||||
|
|
||||||
// Parse the closing ')'.
|
// Parse the closing ')'.
|
||||||
@@ -1277,7 +1277,7 @@ bool Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc) {
|
|||||||
lParenLoc);
|
lParenLoc);
|
||||||
}
|
}
|
||||||
if (Tok.is(tok::r_paren)) {
|
if (Tok.is(tok::r_paren)) {
|
||||||
rParenLoc = consumeLoc();
|
rParenLoc = consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
diagnose(AtLoc, diag::attr_warn_unused_result_removed)
|
diagnose(AtLoc, diag::attr_warn_unused_result_removed)
|
||||||
@@ -1295,7 +1295,7 @@ bool Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc) {
|
|||||||
diagnose(Tok, diag::unknown_attribute, Tok.getText());
|
diagnose(Tok, diag::unknown_attribute, Tok.getText());
|
||||||
|
|
||||||
// Recover by eating @foo(...) when foo is not known.
|
// Recover by eating @foo(...) when foo is not known.
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (Tok.is(tok::l_paren))
|
if (Tok.is(tok::l_paren))
|
||||||
skipSingle();
|
skipSingle();
|
||||||
|
|
||||||
@@ -1360,7 +1360,7 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recover by eating @foo(...) when foo is not known.
|
// Recover by eating @foo(...) when foo is not known.
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (Tok.is(tok::l_paren) && getEndOfPreviousLoc() == Tok.getLoc()) {
|
if (Tok.is(tok::l_paren) && getEndOfPreviousLoc() == Tok.getLoc()) {
|
||||||
ParserPosition LParenPosition = getParserPosition();
|
ParserPosition LParenPosition = getParserPosition();
|
||||||
skipSingle();
|
skipSingle();
|
||||||
@@ -1375,7 +1375,7 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
|
|||||||
|
|
||||||
// Ok, it is a valid attribute, eat it, and then process it.
|
// Ok, it is a valid attribute, eat it, and then process it.
|
||||||
StringRef Text = Tok.getText();
|
StringRef Text = Tok.getText();
|
||||||
SourceLoc Loc = consumeLoc();
|
SourceLoc Loc = consumeToken();
|
||||||
|
|
||||||
bool isAutoclosureEscaping = false;
|
bool isAutoclosureEscaping = false;
|
||||||
SourceRange autoclosureEscapingParenRange;
|
SourceRange autoclosureEscapingParenRange;
|
||||||
@@ -1389,16 +1389,16 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
|
|||||||
// function type coming up is a typealias, e.g. "@autoclosure (escaping) T".
|
// function type coming up is a typealias, e.g. "@autoclosure (escaping) T".
|
||||||
if (Tok.is(tok::l_paren) && peekToken().getText() == "escaping") {
|
if (Tok.is(tok::l_paren) && peekToken().getText() == "escaping") {
|
||||||
Parser::BacktrackingScope Backtrack(*this);
|
Parser::BacktrackingScope Backtrack(*this);
|
||||||
consumeLoc(tok::l_paren);
|
consumeToken(tok::l_paren);
|
||||||
consumeLoc(tok::identifier);
|
consumeToken(tok::identifier);
|
||||||
isAutoclosureEscaping =
|
isAutoclosureEscaping =
|
||||||
Tok.is(tok::r_paren) && peekToken().isNot(tok::arrow);
|
Tok.is(tok::r_paren) && peekToken().isNot(tok::arrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAutoclosureEscaping) {
|
if (isAutoclosureEscaping) {
|
||||||
autoclosureEscapingParenRange.Start = consumeLoc(tok::l_paren);
|
autoclosureEscapingParenRange.Start = consumeToken(tok::l_paren);
|
||||||
consumeLoc(tok::identifier);
|
consumeToken(tok::identifier);
|
||||||
autoclosureEscapingParenRange.End = consumeLoc(tok::r_paren);
|
autoclosureEscapingParenRange.End = consumeToken(tok::r_paren);
|
||||||
}
|
}
|
||||||
} else if (attr == TAK_convention) {
|
} else if (attr == TAK_convention) {
|
||||||
SourceLoc LPLoc;
|
SourceLoc LPLoc;
|
||||||
@@ -1415,7 +1415,7 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
conventionName = Tok.getText();
|
conventionName = Tok.getText();
|
||||||
consumeLoc(tok::identifier);
|
consumeToken(tok::identifier);
|
||||||
|
|
||||||
// Parse the ')'. We can't use parseMatchingToken if we're in
|
// Parse the ')'. We can't use parseMatchingToken if we're in
|
||||||
// just-checking mode.
|
// just-checking mode.
|
||||||
@@ -1540,7 +1540,7 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
|
|||||||
} else {
|
} else {
|
||||||
diagnose(Tok, diag::opened_attribute_id_value);
|
diagnose(Tok, diag::opened_attribute_id_value);
|
||||||
}
|
}
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
} else {
|
} else {
|
||||||
diagnose(Tok, diag::opened_attribute_id_value);
|
diagnose(Tok, diag::opened_attribute_id_value);
|
||||||
}
|
}
|
||||||
@@ -1576,12 +1576,12 @@ bool Parser::parseDeclAttributeList(DeclAttributes &Attributes,
|
|||||||
FoundCCToken = false;
|
FoundCCToken = false;
|
||||||
while (Tok.is(tok::at_sign)) {
|
while (Tok.is(tok::at_sign)) {
|
||||||
if (peekToken().is(tok::code_complete)) {
|
if (peekToken().is(tok::code_complete)) {
|
||||||
consumeLoc(tok::at_sign);
|
consumeToken(tok::at_sign);
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
FoundCCToken = true;
|
FoundCCToken = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto AtLoc = consumeLoc();
|
auto AtLoc = consumeToken();
|
||||||
if (parseDeclAttribute(Attributes, AtLoc))
|
if (parseDeclAttribute(Attributes, AtLoc))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1715,8 +1715,8 @@ static bool isParenthesizedUnowned(Parser &P) {
|
|||||||
|
|
||||||
// Look ahead to parse the parenthesized expression.
|
// Look ahead to parse the parenthesized expression.
|
||||||
Parser::BacktrackingScope Backtrack(P);
|
Parser::BacktrackingScope Backtrack(P);
|
||||||
P.consumeLoc(tok::identifier);
|
P.consumeToken(tok::identifier);
|
||||||
P.consumeLoc(tok::l_paren);
|
P.consumeToken(tok::l_paren);
|
||||||
return P.Tok.is(tok::identifier) && P.peekToken().is(tok::r_paren) &&
|
return P.Tok.is(tok::identifier) && P.peekToken().is(tok::r_paren) &&
|
||||||
(P.Tok.getText() == "safe" || P.Tok.getText() == "unsafe");
|
(P.Tok.getText() == "safe" || P.Tok.getText() == "unsafe");
|
||||||
}
|
}
|
||||||
@@ -1789,10 +1789,10 @@ bool Parser::isStartOfDecl() {
|
|||||||
if (Tok.getText() == "unowned" && Tok2.is(tok::l_paren) &&
|
if (Tok.getText() == "unowned" && Tok2.is(tok::l_paren) &&
|
||||||
isParenthesizedUnowned(*this)) {
|
isParenthesizedUnowned(*this)) {
|
||||||
Parser::BacktrackingScope Backtrack(*this);
|
Parser::BacktrackingScope Backtrack(*this);
|
||||||
consumeLoc(tok::identifier);
|
consumeToken(tok::identifier);
|
||||||
consumeLoc(tok::l_paren);
|
consumeToken(tok::l_paren);
|
||||||
consumeLoc(tok::identifier);
|
consumeToken(tok::identifier);
|
||||||
consumeLoc(tok::r_paren);
|
consumeToken(tok::r_paren);
|
||||||
return isStartOfDecl();
|
return isStartOfDecl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1802,7 +1802,7 @@ bool Parser::isStartOfDecl() {
|
|||||||
|
|
||||||
// Otherwise, do a recursive parse.
|
// Otherwise, do a recursive parse.
|
||||||
Parser::BacktrackingScope Backtrack(*this);
|
Parser::BacktrackingScope Backtrack(*this);
|
||||||
consumeLoc(tok::identifier);
|
consumeToken(tok::identifier);
|
||||||
return isStartOfDecl();
|
return isStartOfDecl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1813,7 +1813,7 @@ void Parser::consumeDecl(ParserPosition BeginParserPosition,
|
|||||||
SourceLoc BeginLoc = Tok.getLoc();
|
SourceLoc BeginLoc = Tok.getLoc();
|
||||||
// Consume tokens up to code completion token.
|
// Consume tokens up to code completion token.
|
||||||
while (Tok.isNot(tok::code_complete, tok::eof))
|
while (Tok.isNot(tok::code_complete, tok::eof))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
// Consume the code completion token, if there is one.
|
// Consume the code completion token, if there is one.
|
||||||
consumeIf(tok::code_complete);
|
consumeIf(tok::code_complete);
|
||||||
@@ -1828,7 +1828,7 @@ void Parser::consumeDecl(ParserPosition BeginParserPosition,
|
|||||||
// Skip the rest of the file to prevent the parser from constructing the
|
// Skip the rest of the file to prevent the parser from constructing the
|
||||||
// AST for it. Forward references are not allowed at the top level.
|
// AST for it. Forward references are not allowed at the top level.
|
||||||
while (Tok.isNot(tok::eof))
|
while (Tok.isNot(tok::eof))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1858,7 +1858,7 @@ void Parser::delayParseFromBeginningToHere(ParserPosition BeginParserPosition,
|
|||||||
BeginParserPosition.PreviousLoc);
|
BeginParserPosition.PreviousLoc);
|
||||||
|
|
||||||
while (Tok.isNot(tok::eof))
|
while (Tok.isNot(tok::eof))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Parse a single syntactic declaration and return a list of decl
|
/// \brief Parse a single syntactic declaration and return a list of decl
|
||||||
@@ -1946,12 +1946,12 @@ ParserStatus Parser::parseDecl(ParseDeclOptions Flags,
|
|||||||
StaticLoc = Tok.getLoc();
|
StaticLoc = Tok.getLoc();
|
||||||
StaticSpelling = StaticSpellingKind::KeywordStatic;
|
StaticSpelling = StaticSpellingKind::KeywordStatic;
|
||||||
}
|
}
|
||||||
consumeLoc(tok::kw_static);
|
consumeToken(tok::kw_static);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// 'class' is a modifier on func, but is also a top-level decl.
|
// 'class' is a modifier on func, but is also a top-level decl.
|
||||||
case tok::kw_class: {
|
case tok::kw_class: {
|
||||||
SourceLoc ClassLoc = consumeLoc(tok::kw_class);
|
SourceLoc ClassLoc = consumeToken(tok::kw_class);
|
||||||
|
|
||||||
// If 'class' is a modifier on another decl kind, like var or func,
|
// If 'class' is a modifier on another decl kind, like var or func,
|
||||||
// then treat it as a modifier.
|
// then treat it as a modifier.
|
||||||
@@ -2086,7 +2086,7 @@ ParserStatus Parser::parseDecl(ParseDeclOptions Flags,
|
|||||||
return makeParserErrorResult<Decl>();
|
return makeParserErrorResult<Decl>();
|
||||||
|
|
||||||
case tok::unknown:
|
case tok::unknown:
|
||||||
consumeLoc(tok::unknown);
|
consumeToken(tok::unknown);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Unambiguous top level decls.
|
// Unambiguous top level decls.
|
||||||
@@ -2245,7 +2245,7 @@ ParserStatus Parser::parseDecl(ParseDeclOptions Flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Tok.is(tok::semi)) {
|
if (Tok.is(tok::semi)) {
|
||||||
SourceLoc TrailingSemiLoc = consumeLoc(tok::semi);
|
SourceLoc TrailingSemiLoc = consumeToken(tok::semi);
|
||||||
if (Status.isSuccess())
|
if (Status.isSuccess())
|
||||||
LastDecl->TrailingSemiLoc = TrailingSemiLoc;
|
LastDecl->TrailingSemiLoc = TrailingSemiLoc;
|
||||||
}
|
}
|
||||||
@@ -2271,7 +2271,7 @@ void Parser::parseDeclDelayed() {
|
|||||||
|
|
||||||
// ParserPositionRAII needs a primed parser to restore to.
|
// ParserPositionRAII needs a primed parser to restore to.
|
||||||
if (Tok.is(tok::NUM_TOKENS))
|
if (Tok.is(tok::NUM_TOKENS))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
// Ensure that we restore the parser state at exit.
|
// Ensure that we restore the parser state at exit.
|
||||||
ParserPositionRAII PPR(*this);
|
ParserPositionRAII PPR(*this);
|
||||||
@@ -2310,7 +2310,7 @@ void Parser::parseDeclDelayed() {
|
|||||||
/// \endverbatim
|
/// \endverbatim
|
||||||
ParserResult<ImportDecl> Parser::parseDeclImport(ParseDeclOptions Flags,
|
ParserResult<ImportDecl> Parser::parseDeclImport(ParseDeclOptions Flags,
|
||||||
DeclAttributes &Attributes) {
|
DeclAttributes &Attributes) {
|
||||||
SourceLoc ImportLoc = consumeLoc(tok::kw_import);
|
SourceLoc ImportLoc = consumeToken(tok::kw_import);
|
||||||
DebuggerContextChange DCC (*this);
|
DebuggerContextChange DCC (*this);
|
||||||
|
|
||||||
if (!CodeCompletion && !DCC.movedToTopLevel() && !(Flags & PD_AllowTopLevel)) {
|
if (!CodeCompletion && !DCC.movedToTopLevel() && !(Flags & PD_AllowTopLevel)) {
|
||||||
@@ -2350,13 +2350,13 @@ ParserResult<ImportDecl> Parser::parseDeclImport(ParseDeclOptions Flags,
|
|||||||
diagnose(Tok, diag::backticks_to_escape);
|
diagnose(Tok, diag::backticks_to_escape);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
KindLoc = consumeLoc();
|
KindLoc = consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<Identifier, SourceLoc>> ImportPath;
|
std::vector<std::pair<Identifier, SourceLoc>> ImportPath;
|
||||||
do {
|
do {
|
||||||
if (Tok.is(tok::code_complete)) {
|
if (Tok.is(tok::code_complete)) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (CodeCompletion) {
|
if (CodeCompletion) {
|
||||||
CodeCompletion->completeImportDecl(ImportPath);
|
CodeCompletion->completeImportDecl(ImportPath);
|
||||||
}
|
}
|
||||||
@@ -2377,7 +2377,7 @@ ParserResult<ImportDecl> Parser::parseDeclImport(ParseDeclOptions Flags,
|
|||||||
auto CCTokenOffset = SourceMgr.getLocOffsetInBuffer(SourceMgr.
|
auto CCTokenOffset = SourceMgr.getLocOffsetInBuffer(SourceMgr.
|
||||||
getCodeCompletionLoc(), BufferId);
|
getCodeCompletionLoc(), BufferId);
|
||||||
if (IdEndOffset == CCTokenOffset) {
|
if (IdEndOffset == CCTokenOffset) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2404,7 +2404,7 @@ ParserResult<ImportDecl> Parser::parseDeclImport(ParseDeclOptions Flags,
|
|||||||
/// \endverbatim
|
/// \endverbatim
|
||||||
ParserStatus Parser::parseInheritance(SmallVectorImpl<TypeLoc> &Inherited,
|
ParserStatus Parser::parseInheritance(SmallVectorImpl<TypeLoc> &Inherited,
|
||||||
SourceLoc *classRequirementLoc) {
|
SourceLoc *classRequirementLoc) {
|
||||||
consumeLoc(tok::colon);
|
consumeToken(tok::colon);
|
||||||
|
|
||||||
// Clear out the class requirement location.
|
// Clear out the class requirement location.
|
||||||
if (classRequirementLoc)
|
if (classRequirementLoc)
|
||||||
@@ -2416,7 +2416,7 @@ ParserStatus Parser::parseInheritance(SmallVectorImpl<TypeLoc> &Inherited,
|
|||||||
// Parse the 'class' keyword for a class requirement.
|
// Parse the 'class' keyword for a class requirement.
|
||||||
if (Tok.is(tok::kw_class)) {
|
if (Tok.is(tok::kw_class)) {
|
||||||
// If we aren't allowed to have a class requirement here, complain.
|
// If we aren't allowed to have a class requirement here, complain.
|
||||||
auto classLoc = consumeLoc();
|
auto classLoc = consumeToken();
|
||||||
if (!classRequirementLoc) {
|
if (!classRequirementLoc) {
|
||||||
SourceLoc endLoc = Tok.is(tok::comma) ? Tok.getLoc() : classLoc;
|
SourceLoc endLoc = Tok.is(tok::comma) ? Tok.getLoc() : classLoc;
|
||||||
diagnose(classLoc, diag::invalid_class_requirement)
|
diagnose(classLoc, diag::invalid_class_requirement)
|
||||||
@@ -2510,7 +2510,7 @@ static ParserStatus parseIdentifierDeclName(Parser &P, Identifier &Result,
|
|||||||
case tok::identifier:
|
case tok::identifier:
|
||||||
Result = P.Context.getIdentifier(P.Tok.getText());
|
Result = P.Context.getIdentifier(P.Tok.getText());
|
||||||
Loc = P.Tok.getLoc();
|
Loc = P.Tok.getLoc();
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
return makeParserSuccess();
|
return makeParserSuccess();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -2527,7 +2527,7 @@ static ParserStatus parseIdentifierDeclName(Parser &P, Identifier &Result,
|
|||||||
Name += "#";
|
Name += "#";
|
||||||
Result = P.Context.getIdentifier(Name.str());
|
Result = P.Context.getIdentifier(Name.str());
|
||||||
Loc = P.Tok.getLoc();
|
Loc = P.Tok.getLoc();
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
// Return success because we recovered.
|
// Return success because we recovered.
|
||||||
return makeParserSuccess();
|
return makeParserSuccess();
|
||||||
}
|
}
|
||||||
@@ -2586,7 +2586,7 @@ parseIdentifierDeclName(Parser &P, Identifier &Result, SourceLoc &L,
|
|||||||
/// \endverbatim
|
/// \endverbatim
|
||||||
ParserResult<ExtensionDecl>
|
ParserResult<ExtensionDecl>
|
||||||
Parser::parseDeclExtension(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
Parser::parseDeclExtension(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
||||||
SourceLoc ExtensionLoc = consumeLoc(tok::kw_extension);
|
SourceLoc ExtensionLoc = consumeToken(tok::kw_extension);
|
||||||
|
|
||||||
DebuggerContextChange DCC (*this);
|
DebuggerContextChange DCC (*this);
|
||||||
|
|
||||||
@@ -2666,7 +2666,7 @@ Parser::parseDeclExtension(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ParserStatus Parser::parseLineDirective(bool isLine) {
|
ParserStatus Parser::parseLineDirective(bool isLine) {
|
||||||
SourceLoc Loc = consumeLoc();
|
SourceLoc Loc = consumeToken();
|
||||||
if (isLine) {
|
if (isLine) {
|
||||||
diagnose(Loc, diag::line_directive_style_deprecated)
|
diagnose(Loc, diag::line_directive_style_deprecated)
|
||||||
.fixItReplace(Loc, "#sourceLocation");
|
.fixItReplace(Loc, "#sourceLocation");
|
||||||
@@ -2709,7 +2709,7 @@ ParserStatus Parser::parseLineDirective(bool isLine) {
|
|||||||
"#sourceLocation");
|
"#sourceLocation");
|
||||||
if (!Filename.hasValue())
|
if (!Filename.hasValue())
|
||||||
return makeParserError();
|
return makeParserError();
|
||||||
consumeLoc(tok::string_literal);
|
consumeToken(tok::string_literal);
|
||||||
|
|
||||||
if (parseToken(tok::comma, diag::sourceLocation_expected, ",") ||
|
if (parseToken(tok::comma, diag::sourceLocation_expected, ",") ||
|
||||||
parseSpecificIdentifier("line", diag::sourceLocation_expected,"line:")||
|
parseSpecificIdentifier("line", diag::sourceLocation_expected,"line:")||
|
||||||
@@ -2728,7 +2728,7 @@ ParserStatus Parser::parseLineDirective(bool isLine) {
|
|||||||
diagnose(Tok, diag::line_directive_line_zero);
|
diagnose(Tok, diag::line_directive_line_zero);
|
||||||
return makeParserError();
|
return makeParserError();
|
||||||
}
|
}
|
||||||
consumeLoc(tok::integer_literal);
|
consumeToken(tok::integer_literal);
|
||||||
|
|
||||||
LastTokTextEnd = Tok.getText().end();
|
LastTokTextEnd = Tok.getText().end();
|
||||||
if (parseToken(tok::r_paren, diag::sourceLocation_expected, ")"))
|
if (parseToken(tok::r_paren, diag::sourceLocation_expected, ")"))
|
||||||
@@ -2758,7 +2758,7 @@ ParserStatus Parser::parseLineDirective(bool isLine) {
|
|||||||
diagnose(Tok, diag::line_directive_line_zero);
|
diagnose(Tok, diag::line_directive_line_zero);
|
||||||
return makeParserError();
|
return makeParserError();
|
||||||
}
|
}
|
||||||
consumeLoc(tok::integer_literal);
|
consumeToken(tok::integer_literal);
|
||||||
|
|
||||||
if (Tok.isNot(tok::string_literal)) {
|
if (Tok.isNot(tok::string_literal)) {
|
||||||
diagnose(Tok, diag::expected_line_directive_name);
|
diagnose(Tok, diag::expected_line_directive_name);
|
||||||
@@ -2770,7 +2770,7 @@ ParserStatus Parser::parseLineDirective(bool isLine) {
|
|||||||
if (!Filename.hasValue())
|
if (!Filename.hasValue())
|
||||||
return makeParserError();
|
return makeParserError();
|
||||||
LastTokTextEnd = Tok.getText().end();
|
LastTokTextEnd = Tok.getText().end();
|
||||||
consumeLoc(tok::string_literal);
|
consumeToken(tok::string_literal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip over trailing whitespace and a single \n to the start of the next
|
// Skip over trailing whitespace and a single \n to the start of the next
|
||||||
@@ -2807,7 +2807,7 @@ ParserResult<IfConfigDecl> Parser::parseDeclIfConfig(ParseDeclOptions Flags) {
|
|||||||
ConditionalCompilationExprState ConfigState;
|
ConditionalCompilationExprState ConfigState;
|
||||||
while (1) {
|
while (1) {
|
||||||
bool isElse = Tok.is(tok::pound_else);
|
bool isElse = Tok.is(tok::pound_else);
|
||||||
SourceLoc ClauseLoc = consumeLoc();
|
SourceLoc ClauseLoc = consumeToken();
|
||||||
Expr *Condition = nullptr;
|
Expr *Condition = nullptr;
|
||||||
|
|
||||||
if (isElse) {
|
if (isElse) {
|
||||||
@@ -2890,7 +2890,7 @@ ParserResult<IfConfigDecl> Parser::parseDeclIfConfig(ParseDeclOptions Flags) {
|
|||||||
ParserResult<TypeDecl> Parser::
|
ParserResult<TypeDecl> Parser::
|
||||||
parseDeclTypeAlias(Parser::ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
parseDeclTypeAlias(Parser::ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
||||||
ParserPosition startPosition = getParserPosition();
|
ParserPosition startPosition = getParserPosition();
|
||||||
SourceLoc TypeAliasLoc = consumeLoc(tok::kw_typealias);
|
SourceLoc TypeAliasLoc = consumeToken(tok::kw_typealias);
|
||||||
Identifier Id;
|
Identifier Id;
|
||||||
SourceLoc IdLoc;
|
SourceLoc IdLoc;
|
||||||
ParserStatus Status;
|
ParserStatus Status;
|
||||||
@@ -2939,9 +2939,9 @@ parseDeclTypeAlias(Parser::ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
|||||||
// Recognize this and produce a fixit.
|
// Recognize this and produce a fixit.
|
||||||
diagnose(Tok, diag::expected_equal_in_typealias)
|
diagnose(Tok, diag::expected_equal_in_typealias)
|
||||||
.fixItReplace(Tok.getLoc(), " = ");
|
.fixItReplace(Tok.getLoc(), " = ");
|
||||||
consumeLoc(tok::colon);
|
consumeToken(tok::colon);
|
||||||
} else {
|
} else {
|
||||||
consumeLoc(tok::equal);
|
consumeToken(tok::equal);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnderlyingTy = parseType(diag::expected_type_in_typealias);
|
UnderlyingTy = parseType(diag::expected_type_in_typealias);
|
||||||
@@ -2992,11 +2992,11 @@ ParserResult<TypeDecl> Parser::parseDeclAssociatedType(Parser::ParseDeclOptions
|
|||||||
// Look for 'typealias' here and diagnose a fixit because parseDeclTypeAlias can
|
// Look for 'typealias' here and diagnose a fixit because parseDeclTypeAlias can
|
||||||
// ask us to fix up leftover Swift 2 code intending to be an associatedtype.
|
// ask us to fix up leftover Swift 2 code intending to be an associatedtype.
|
||||||
if (Tok.is(tok::kw_typealias)) {
|
if (Tok.is(tok::kw_typealias)) {
|
||||||
AssociatedTypeLoc = consumeLoc(tok::kw_typealias);
|
AssociatedTypeLoc = consumeToken(tok::kw_typealias);
|
||||||
diagnose(AssociatedTypeLoc, diag::typealias_inside_protocol_without_type)
|
diagnose(AssociatedTypeLoc, diag::typealias_inside_protocol_without_type)
|
||||||
.fixItReplace(AssociatedTypeLoc, "associatedtype");
|
.fixItReplace(AssociatedTypeLoc, "associatedtype");
|
||||||
} else {
|
} else {
|
||||||
AssociatedTypeLoc = consumeLoc(tok::kw_associatedtype);
|
AssociatedTypeLoc = consumeToken(tok::kw_associatedtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status =
|
Status =
|
||||||
@@ -3024,7 +3024,7 @@ ParserResult<TypeDecl> Parser::parseDeclAssociatedType(Parser::ParseDeclOptions
|
|||||||
|
|
||||||
ParserResult<TypeRepr> UnderlyingTy;
|
ParserResult<TypeRepr> UnderlyingTy;
|
||||||
if (Tok.is(tok::equal)) {
|
if (Tok.is(tok::equal)) {
|
||||||
consumeLoc(tok::equal);
|
consumeToken(tok::equal);
|
||||||
UnderlyingTy = parseType(diag::expected_type_in_associatedtype);
|
UnderlyingTy = parseType(diag::expected_type_in_associatedtype);
|
||||||
Status |= UnderlyingTy;
|
Status |= UnderlyingTy;
|
||||||
if (UnderlyingTy.isNull())
|
if (UnderlyingTy.isNull())
|
||||||
@@ -3264,18 +3264,18 @@ parseOptionalAccessorArgument(SourceLoc SpecifierLoc, TypeLoc ElementTy,
|
|||||||
// If the SpecifierLoc is invalid, then the caller just wants us to synthesize
|
// If the SpecifierLoc is invalid, then the caller just wants us to synthesize
|
||||||
// the default, not actually try to parse something.
|
// the default, not actually try to parse something.
|
||||||
if (SpecifierLoc.isValid() && P.Tok.is(tok::l_paren)) {
|
if (SpecifierLoc.isValid() && P.Tok.is(tok::l_paren)) {
|
||||||
StartLoc = P.consumeLoc(tok::l_paren);
|
StartLoc = P.consumeToken(tok::l_paren);
|
||||||
if (P.Tok.isNot(tok::identifier)) {
|
if (P.Tok.isNot(tok::identifier)) {
|
||||||
P.diagnose(P.Tok, diag::expected_accessor_name, (unsigned)Kind);
|
P.diagnose(P.Tok, diag::expected_accessor_name, (unsigned)Kind);
|
||||||
P.skipUntil(tok::r_paren, tok::l_brace);
|
P.skipUntil(tok::r_paren, tok::l_brace);
|
||||||
if (P.Tok.is(tok::r_paren))
|
if (P.Tok.is(tok::r_paren))
|
||||||
EndLoc = P.consumeLoc();
|
EndLoc = P.consumeToken();
|
||||||
else
|
else
|
||||||
EndLoc = StartLoc;
|
EndLoc = StartLoc;
|
||||||
} else {
|
} else {
|
||||||
// We have a name.
|
// We have a name.
|
||||||
Name = P.Context.getIdentifier(P.Tok.getText());
|
Name = P.Context.getIdentifier(P.Tok.getText());
|
||||||
NameLoc = P.consumeLoc();
|
NameLoc = P.consumeToken();
|
||||||
|
|
||||||
auto DiagID =
|
auto DiagID =
|
||||||
Kind == AccessorKind::IsSetter ? diag::expected_rparen_set_name :
|
Kind == AccessorKind::IsSetter ? diag::expected_rparen_set_name :
|
||||||
@@ -3305,13 +3305,13 @@ static unsigned skipUntilMatchingRBrace(Parser &P) {
|
|||||||
OpenBraces--;
|
OpenBraces--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
}
|
}
|
||||||
return OpenBraces;
|
return OpenBraces;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned skipBracedBlock(Parser &P) {
|
static unsigned skipBracedBlock(Parser &P) {
|
||||||
P.consumeLoc(tok::l_brace);
|
P.consumeToken(tok::l_brace);
|
||||||
unsigned OpenBraces = skipUntilMatchingRBrace(P);
|
unsigned OpenBraces = skipUntilMatchingRBrace(P);
|
||||||
if (P.consumeIf(tok::r_brace))
|
if (P.consumeIf(tok::r_brace))
|
||||||
OpenBraces--;
|
OpenBraces--;
|
||||||
@@ -3484,7 +3484,7 @@ bool Parser::parseGetSetImpl(ParseDeclOptions Flags, ParameterList *Indices,
|
|||||||
}
|
}
|
||||||
|
|
||||||
FuncDecl *&TheDecl = *TheDeclPtr;
|
FuncDecl *&TheDecl = *TheDeclPtr;
|
||||||
SourceLoc Loc = consumeLoc();
|
SourceLoc Loc = consumeToken();
|
||||||
|
|
||||||
// Have we already parsed this kind of clause?
|
// Have we already parsed this kind of clause?
|
||||||
if (TheDecl) {
|
if (TheDecl) {
|
||||||
@@ -3602,7 +3602,7 @@ bool Parser::parseGetSetImpl(ParseDeclOptions Flags, ParameterList *Indices,
|
|||||||
IsFirstAccessor = false;
|
IsFirstAccessor = false;
|
||||||
|
|
||||||
// Consume the contextual keyword, if present.
|
// Consume the contextual keyword, if present.
|
||||||
SourceLoc Loc = isImplicitGet ? VarLBLoc : consumeLoc();
|
SourceLoc Loc = isImplicitGet ? VarLBLoc : consumeToken();
|
||||||
|
|
||||||
FuncDecl *&TheDecl = *TheDeclPtr;
|
FuncDecl *&TheDecl = *TheDeclPtr;
|
||||||
|
|
||||||
@@ -3687,7 +3687,7 @@ bool Parser::parseGetSet(ParseDeclOptions Flags, ParameterList *Indices,
|
|||||||
TypeLoc ElementTy, ParsedAccessors &accessors,
|
TypeLoc ElementTy, ParsedAccessors &accessors,
|
||||||
SourceLoc StaticLoc,
|
SourceLoc StaticLoc,
|
||||||
SmallVectorImpl<Decl *> &Decls) {
|
SmallVectorImpl<Decl *> &Decls) {
|
||||||
accessors.LBLoc = consumeLoc(tok::l_brace);
|
accessors.LBLoc = consumeToken(tok::l_brace);
|
||||||
SourceLoc LastValidLoc = accessors.LBLoc;
|
SourceLoc LastValidLoc = accessors.LBLoc;
|
||||||
bool Invalid = parseGetSetImpl(Flags, Indices, ElementTy, accessors,
|
bool Invalid = parseGetSetImpl(Flags, Indices, ElementTy, accessors,
|
||||||
LastValidLoc, StaticLoc, accessors.LBLoc,
|
LastValidLoc, StaticLoc, accessors.LBLoc,
|
||||||
@@ -3715,7 +3715,7 @@ void Parser::parseAccessorBodyDelayed(AbstractFunctionDecl *AFD) {
|
|||||||
|
|
||||||
// ParserPositionRAII needs a primed parser to restore to.
|
// ParserPositionRAII needs a primed parser to restore to.
|
||||||
if (Tok.is(tok::NUM_TOKENS))
|
if (Tok.is(tok::NUM_TOKENS))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
// Ensure that we restore the parser state at exit.
|
// Ensure that we restore the parser state at exit.
|
||||||
ParserPositionRAII PPR(*this);
|
ParserPositionRAII PPR(*this);
|
||||||
@@ -4047,7 +4047,7 @@ ParserStatus Parser::parseDeclVar(ParseDeclOptions Flags,
|
|||||||
|
|
||||||
bool isLet = Tok.is(tok::kw_let);
|
bool isLet = Tok.is(tok::kw_let);
|
||||||
assert(Tok.getKind() == tok::kw_let || Tok.getKind() == tok::kw_var);
|
assert(Tok.getKind() == tok::kw_let || Tok.getKind() == tok::kw_var);
|
||||||
SourceLoc VarLoc = consumeLoc();
|
SourceLoc VarLoc = consumeToken();
|
||||||
|
|
||||||
// If this is a var in the top-level of script/repl source file, wrap the
|
// If this is a var in the top-level of script/repl source file, wrap the
|
||||||
// PatternBindingDecl in a TopLevelCodeDecl, since it represents executable
|
// PatternBindingDecl in a TopLevelCodeDecl, since it represents executable
|
||||||
@@ -4174,7 +4174,7 @@ ParserStatus Parser::parseDeclVar(ParseDeclOptions Flags,
|
|||||||
initParser.emplace(*this, initContext);
|
initParser.emplace(*this, initContext);
|
||||||
|
|
||||||
|
|
||||||
SourceLoc EqualLoc = consumeLoc(tok::equal);
|
SourceLoc EqualLoc = consumeToken(tok::equal);
|
||||||
ParserResult<Expr> init = parseExpr(diag::expected_init_value);
|
ParserResult<Expr> init = parseExpr(diag::expected_init_value);
|
||||||
|
|
||||||
// If this Pattern binding was not supposed to have an initializer, but it
|
// If this Pattern binding was not supposed to have an initializer, but it
|
||||||
@@ -4218,7 +4218,7 @@ ParserStatus Parser::parseDeclVar(ParseDeclOptions Flags,
|
|||||||
if (Context.LangOpts.EnableExperimentalPropertyBehaviors
|
if (Context.LangOpts.EnableExperimentalPropertyBehaviors
|
||||||
&& Tok.is(tok::identifier)
|
&& Tok.is(tok::identifier)
|
||||||
&& Tok.getText().equals("__behavior")) {
|
&& Tok.getText().equals("__behavior")) {
|
||||||
consumeLoc(tok::identifier);
|
consumeToken(tok::identifier);
|
||||||
auto type = parseType(diag::expected_behavior_name,
|
auto type = parseType(diag::expected_behavior_name,
|
||||||
/*handle completion*/ true);
|
/*handle completion*/ true);
|
||||||
if (type.isParseError())
|
if (type.isParseError())
|
||||||
@@ -4368,10 +4368,10 @@ void Parser::consumeAbstractFunctionBody(AbstractFunctionDecl *AFD,
|
|||||||
// for the next decl except variable decls and cutting off before
|
// for the next decl except variable decls and cutting off before
|
||||||
// that point.
|
// that point.
|
||||||
backtrackToPosition(BeginParserPosition);
|
backtrackToPosition(BeginParserPosition);
|
||||||
consumeLoc(tok::l_brace);
|
consumeToken(tok::l_brace);
|
||||||
while (Tok.is(tok::kw_var) || Tok.is(tok::kw_let) ||
|
while (Tok.is(tok::kw_var) || Tok.is(tok::kw_let) ||
|
||||||
(Tok.isNot(tok::eof) && !isStartOfDecl())) {
|
(Tok.isNot(tok::eof) && !isStartOfDecl())) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4423,7 +4423,7 @@ Parser::parseDeclFunc(SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceLoc FuncLoc = consumeLoc(tok::kw_func);
|
SourceLoc FuncLoc = consumeToken(tok::kw_func);
|
||||||
|
|
||||||
// Forgive the lexer
|
// Forgive the lexer
|
||||||
if (Tok.is(tok::amp_prefix)) {
|
if (Tok.is(tok::amp_prefix)) {
|
||||||
@@ -4485,7 +4485,7 @@ Parser::parseDeclFunc(SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
|
|||||||
diagnose(Tok.getLoc(), diag::join_identifiers_camel_case)
|
diagnose(Tok.getLoc(), diag::join_identifiers_camel_case)
|
||||||
.fixItReplace(DoubleIdentifierRange, CamelCaseConcatenation);
|
.fixItReplace(DoubleIdentifierRange, CamelCaseConcatenation);
|
||||||
|
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4671,7 +4671,7 @@ bool Parser::parseAbstractFunctionBodyDelayed(AbstractFunctionDecl *AFD) {
|
|||||||
|
|
||||||
// ParserPositionRAII needs a primed parser to restore to.
|
// ParserPositionRAII needs a primed parser to restore to.
|
||||||
if (Tok.is(tok::NUM_TOKENS))
|
if (Tok.is(tok::NUM_TOKENS))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
// Ensure that we restore the parser state at exit.
|
// Ensure that we restore the parser state at exit.
|
||||||
ParserPositionRAII PPR(*this);
|
ParserPositionRAII PPR(*this);
|
||||||
@@ -4713,7 +4713,7 @@ bool Parser::parseAbstractFunctionBodyDelayed(AbstractFunctionDecl *AFD) {
|
|||||||
/// \endverbatim
|
/// \endverbatim
|
||||||
ParserResult<EnumDecl> Parser::parseDeclEnum(ParseDeclOptions Flags,
|
ParserResult<EnumDecl> Parser::parseDeclEnum(ParseDeclOptions Flags,
|
||||||
DeclAttributes &Attributes) {
|
DeclAttributes &Attributes) {
|
||||||
SourceLoc EnumLoc = consumeLoc(tok::kw_enum);
|
SourceLoc EnumLoc = consumeToken(tok::kw_enum);
|
||||||
|
|
||||||
Identifier EnumName;
|
Identifier EnumName;
|
||||||
SourceLoc EnumNameLoc;
|
SourceLoc EnumNameLoc;
|
||||||
@@ -4795,7 +4795,7 @@ ParserStatus Parser::parseDeclEnumCase(ParseDeclOptions Flags,
|
|||||||
DeclAttributes &Attributes,
|
DeclAttributes &Attributes,
|
||||||
llvm::SmallVectorImpl<Decl *> &Decls) {
|
llvm::SmallVectorImpl<Decl *> &Decls) {
|
||||||
ParserStatus Status;
|
ParserStatus Status;
|
||||||
SourceLoc CaseLoc = consumeLoc(tok::kw_case);
|
SourceLoc CaseLoc = consumeToken(tok::kw_case);
|
||||||
|
|
||||||
// Parse comma-separated enum elements.
|
// Parse comma-separated enum elements.
|
||||||
SmallVector<EnumElementDecl*, 4> Elements;
|
SmallVector<EnumElementDecl*, 4> Elements;
|
||||||
@@ -4864,7 +4864,7 @@ ParserStatus Parser::parseDeclEnumCase(ParseDeclOptions Flags,
|
|||||||
ParserResult<Expr> RawValueExpr;
|
ParserResult<Expr> RawValueExpr;
|
||||||
LiteralExpr *LiteralRawValueExpr = nullptr;
|
LiteralExpr *LiteralRawValueExpr = nullptr;
|
||||||
if (Tok.is(tok::equal)) {
|
if (Tok.is(tok::equal)) {
|
||||||
EqualsLoc = consumeLoc();
|
EqualsLoc = consumeToken();
|
||||||
{
|
{
|
||||||
CodeCompletionCallbacks::InEnumElementRawValueRAII
|
CodeCompletionCallbacks::InEnumElementRawValueRAII
|
||||||
InEnumElementRawValue(CodeCompletion);
|
InEnumElementRawValue(CodeCompletion);
|
||||||
@@ -4924,7 +4924,7 @@ ParserStatus Parser::parseDeclEnumCase(ParseDeclOptions Flags,
|
|||||||
// Continue through the comma-separated list.
|
// Continue through the comma-separated list.
|
||||||
if (!Tok.is(tok::comma))
|
if (!Tok.is(tok::comma))
|
||||||
break;
|
break;
|
||||||
CommaLoc = consumeLoc(tok::comma);
|
CommaLoc = consumeToken(tok::comma);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(Flags & PD_AllowEnumElement)) {
|
if (!(Flags & PD_AllowEnumElement)) {
|
||||||
@@ -4997,7 +4997,7 @@ bool Parser::parseNominalDeclMembers(SourceLoc LBLoc, SourceLoc &RBLoc,
|
|||||||
/// \endverbatim
|
/// \endverbatim
|
||||||
ParserResult<StructDecl> Parser::parseDeclStruct(ParseDeclOptions Flags,
|
ParserResult<StructDecl> Parser::parseDeclStruct(ParseDeclOptions Flags,
|
||||||
DeclAttributes &Attributes) {
|
DeclAttributes &Attributes) {
|
||||||
SourceLoc StructLoc = consumeLoc(tok::kw_struct);
|
SourceLoc StructLoc = consumeToken(tok::kw_struct);
|
||||||
|
|
||||||
Identifier StructName;
|
Identifier StructName;
|
||||||
SourceLoc StructNameLoc;
|
SourceLoc StructNameLoc;
|
||||||
@@ -5176,7 +5176,7 @@ ParserResult<ClassDecl> Parser::parseDeclClass(SourceLoc ClassLoc,
|
|||||||
/// \endverbatim
|
/// \endverbatim
|
||||||
ParserResult<ProtocolDecl> Parser::
|
ParserResult<ProtocolDecl> Parser::
|
||||||
parseDeclProtocol(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
parseDeclProtocol(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
||||||
SourceLoc ProtocolLoc = consumeLoc(tok::kw_protocol);
|
SourceLoc ProtocolLoc = consumeToken(tok::kw_protocol);
|
||||||
|
|
||||||
SourceLoc NameLoc;
|
SourceLoc NameLoc;
|
||||||
Identifier ProtocolName;
|
Identifier ProtocolName;
|
||||||
@@ -5272,7 +5272,7 @@ ParserStatus Parser::parseDeclSubscript(ParseDeclOptions Flags,
|
|||||||
DeclAttributes &Attributes,
|
DeclAttributes &Attributes,
|
||||||
SmallVectorImpl<Decl *> &Decls) {
|
SmallVectorImpl<Decl *> &Decls) {
|
||||||
ParserStatus Status;
|
ParserStatus Status;
|
||||||
SourceLoc SubscriptLoc = consumeLoc(tok::kw_subscript);
|
SourceLoc SubscriptLoc = consumeToken(tok::kw_subscript);
|
||||||
|
|
||||||
// parameter-clause
|
// parameter-clause
|
||||||
if (Tok.isNot(tok::l_paren)) {
|
if (Tok.isNot(tok::l_paren)) {
|
||||||
@@ -5292,7 +5292,7 @@ ParserStatus Parser::parseDeclSubscript(ParseDeclOptions Flags,
|
|||||||
diagnose(Tok, diag::expected_arrow_subscript);
|
diagnose(Tok, diag::expected_arrow_subscript);
|
||||||
return makeParserError();
|
return makeParserError();
|
||||||
}
|
}
|
||||||
SourceLoc ArrowLoc = consumeLoc();
|
SourceLoc ArrowLoc = consumeToken();
|
||||||
|
|
||||||
// type
|
// type
|
||||||
ParserResult<TypeRepr> ElementTy = parseType(diag::expected_type_subscript);
|
ParserResult<TypeRepr> ElementTy = parseType(diag::expected_type_subscript);
|
||||||
@@ -5353,7 +5353,7 @@ ParserStatus Parser::parseDeclSubscript(ParseDeclOptions Flags,
|
|||||||
ParserResult<ConstructorDecl>
|
ParserResult<ConstructorDecl>
|
||||||
Parser::parseDeclInit(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
Parser::parseDeclInit(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
||||||
assert(Tok.is(tok::kw_init));
|
assert(Tok.is(tok::kw_init));
|
||||||
SourceLoc ConstructorLoc = consumeLoc();
|
SourceLoc ConstructorLoc = consumeToken();
|
||||||
OptionalTypeKind Failability = OTK_None;
|
OptionalTypeKind Failability = OTK_None;
|
||||||
SourceLoc FailabilityLoc;
|
SourceLoc FailabilityLoc;
|
||||||
|
|
||||||
@@ -5368,10 +5368,10 @@ Parser::parseDeclInit(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
|||||||
if (Tok.isAny(tok::exclaim_postfix, tok::sil_exclamation) ||
|
if (Tok.isAny(tok::exclaim_postfix, tok::sil_exclamation) ||
|
||||||
(Tok.isAnyOperator() && Tok.getText() == "!")) {
|
(Tok.isAnyOperator() && Tok.getText() == "!")) {
|
||||||
Failability = OTK_ImplicitlyUnwrappedOptional;
|
Failability = OTK_ImplicitlyUnwrappedOptional;
|
||||||
FailabilityLoc = consumeLoc();
|
FailabilityLoc = consumeToken();
|
||||||
} else if (Tok.isAny(tok::question_postfix, tok::question_infix)) {
|
} else if (Tok.isAny(tok::question_postfix, tok::question_infix)) {
|
||||||
Failability = OTK_Optional;
|
Failability = OTK_Optional;
|
||||||
FailabilityLoc = consumeLoc();
|
FailabilityLoc = consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the generic-params, if present.
|
// Parse the generic-params, if present.
|
||||||
@@ -5481,17 +5481,17 @@ Parser::parseDeclInit(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
|||||||
|
|
||||||
ParserResult<DestructorDecl> Parser::
|
ParserResult<DestructorDecl> Parser::
|
||||||
parseDeclDeinit(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
parseDeclDeinit(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
||||||
SourceLoc DestructorLoc = consumeLoc(tok::kw_deinit);
|
SourceLoc DestructorLoc = consumeToken(tok::kw_deinit);
|
||||||
|
|
||||||
// Parse extraneous parentheses and remove them with a fixit.
|
// Parse extraneous parentheses and remove them with a fixit.
|
||||||
if (Tok.is(tok::l_paren)) {
|
if (Tok.is(tok::l_paren)) {
|
||||||
SourceRange ParenRange;
|
SourceRange ParenRange;
|
||||||
SourceLoc LParenLoc = consumeLoc();
|
SourceLoc LParenLoc = consumeToken();
|
||||||
SourceLoc RParenLoc;
|
SourceLoc RParenLoc;
|
||||||
skipUntil(tok::r_paren);
|
skipUntil(tok::r_paren);
|
||||||
|
|
||||||
if (Tok.is(tok::r_paren)) {
|
if (Tok.is(tok::r_paren)) {
|
||||||
SourceLoc RParenLoc = consumeLoc();
|
SourceLoc RParenLoc = consumeToken();
|
||||||
ParenRange = SourceRange(LParenLoc, RParenLoc);
|
ParenRange = SourceRange(LParenLoc, RParenLoc);
|
||||||
|
|
||||||
diagnose(ParenRange.Start, diag::destructor_params)
|
diagnose(ParenRange.Start, diag::destructor_params)
|
||||||
@@ -5552,7 +5552,7 @@ parseDeclDeinit(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
|||||||
|
|
||||||
ParserResult<OperatorDecl>
|
ParserResult<OperatorDecl>
|
||||||
Parser::parseDeclOperator(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
Parser::parseDeclOperator(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
||||||
SourceLoc OperatorLoc = consumeLoc(tok::kw_operator);
|
SourceLoc OperatorLoc = consumeToken(tok::kw_operator);
|
||||||
bool AllowTopLevel = Flags.contains(PD_AllowTopLevel);
|
bool AllowTopLevel = Flags.contains(PD_AllowTopLevel);
|
||||||
|
|
||||||
if (!Tok.isAnyOperator() && !Tok.is(tok::exclaim_postfix)) {
|
if (!Tok.isAnyOperator() && !Tok.is(tok::exclaim_postfix)) {
|
||||||
@@ -5569,7 +5569,7 @@ Parser::parseDeclOperator(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
|||||||
// If so, swallow until the end } to avoid tripping over the body of the
|
// If so, swallow until the end } to avoid tripping over the body of the
|
||||||
// malformed operator decl.
|
// malformed operator decl.
|
||||||
if (peekToken().is(tok::l_brace)) {
|
if (peekToken().is(tok::l_brace)) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
skipSingle();
|
skipSingle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5579,7 +5579,7 @@ Parser::parseDeclOperator(ParseDeclOptions Flags, DeclAttributes &Attributes) {
|
|||||||
DebuggerContextChange DCC (*this);
|
DebuggerContextChange DCC (*this);
|
||||||
|
|
||||||
Identifier Name = Context.getIdentifier(Tok.getText());
|
Identifier Name = Context.getIdentifier(Tok.getText());
|
||||||
SourceLoc NameLoc = consumeLoc();
|
SourceLoc NameLoc = consumeToken();
|
||||||
|
|
||||||
if (Attributes.hasAttribute<PostfixAttr>()) {
|
if (Attributes.hasAttribute<PostfixAttr>()) {
|
||||||
if (!Name.empty() && (Name.get()[0] == '?' || Name.get()[0] == '!'))
|
if (!Name.empty() && (Name.get()[0] == '?' || Name.get()[0] == '!'))
|
||||||
@@ -5610,7 +5610,7 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
|
|||||||
if (consumeIf(tok::colon, colonLoc)) {
|
if (consumeIf(tok::colon, colonLoc)) {
|
||||||
if (Tok.is(tok::identifier)) {
|
if (Tok.is(tok::identifier)) {
|
||||||
precedenceGroupName = Context.getIdentifier(Tok.getText());
|
precedenceGroupName = Context.getIdentifier(Tok.getText());
|
||||||
precedenceGroupNameLoc = consumeLoc(tok::identifier);
|
precedenceGroupNameLoc = consumeToken(tok::identifier);
|
||||||
|
|
||||||
if (isPrefix || isPostfix)
|
if (isPrefix || isPostfix)
|
||||||
diagnose(colonLoc, diag::precedencegroup_not_infix)
|
diagnose(colonLoc, diag::precedencegroup_not_infix)
|
||||||
@@ -5662,7 +5662,7 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
|
|||||||
ParserResult<PrecedenceGroupDecl>
|
ParserResult<PrecedenceGroupDecl>
|
||||||
Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
|
Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
|
||||||
DeclAttributes &attributes) {
|
DeclAttributes &attributes) {
|
||||||
SourceLoc precedenceGroupLoc = consumeLoc(tok::kw_precedencegroup);
|
SourceLoc precedenceGroupLoc = consumeToken(tok::kw_precedencegroup);
|
||||||
DebuggerContextChange DCC (*this);
|
DebuggerContextChange DCC (*this);
|
||||||
|
|
||||||
if (!CodeCompletion && !DCC.movedToTopLevel() && !(flags & PD_AllowTopLevel))
|
if (!CodeCompletion && !DCC.movedToTopLevel() && !(flags & PD_AllowTopLevel))
|
||||||
@@ -5680,7 +5680,7 @@ Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
|
|||||||
skipUntilDeclRBrace();
|
skipUntilDeclRBrace();
|
||||||
(void) consumeIf(tok::r_brace);
|
(void) consumeIf(tok::r_brace);
|
||||||
} else if (Tok.isNot(tok::eof) && peekToken().is(tok::l_brace)) {
|
} else if (Tok.isNot(tok::eof) && peekToken().is(tok::l_brace)) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
skipBracedBlock(*this);
|
skipBracedBlock(*this);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -5742,7 +5742,7 @@ Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
|
|||||||
// We want to continue parsing after this.
|
// We want to continue parsing after this.
|
||||||
invalid = true;
|
invalid = true;
|
||||||
}
|
}
|
||||||
attrKeywordLoc = consumeLoc(tok::identifier);
|
attrKeywordLoc = consumeToken(tok::identifier);
|
||||||
if (!consumeIf(tok::colon)) {
|
if (!consumeIf(tok::colon)) {
|
||||||
diagnose(Tok, diag::expected_precedencegroup_attribute_colon, attrName);
|
diagnose(Tok, diag::expected_precedencegroup_attribute_colon, attrName);
|
||||||
// Try to recover by allowing the colon to be missing.
|
// Try to recover by allowing the colon to be missing.
|
||||||
@@ -5777,7 +5777,7 @@ Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
|
|||||||
invalid = true;
|
invalid = true;
|
||||||
}
|
}
|
||||||
associativity = *parsedAssociativity;
|
associativity = *parsedAssociativity;
|
||||||
associativityValueLoc = consumeLoc();
|
associativityValueLoc = consumeToken();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5808,7 +5808,7 @@ Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
|
|||||||
return abortBody();
|
return abortBody();
|
||||||
}
|
}
|
||||||
auto name = Context.getIdentifier(Tok.getText());
|
auto name = Context.getIdentifier(Tok.getText());
|
||||||
auto loc = consumeLoc();
|
auto loc = consumeToken();
|
||||||
relations.push_back({loc, name, nullptr});
|
relations.push_back({loc, name, nullptr});
|
||||||
} while (consumeIf(tok::comma));
|
} while (consumeIf(tok::comma));
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ ParserResult<Expr> Parser::parseExprImpl(Diag<> Message, bool isExprBasic) {
|
|||||||
/// expr-is:
|
/// expr-is:
|
||||||
/// 'is' type
|
/// 'is' type
|
||||||
ParserResult<Expr> Parser::parseExprIs() {
|
ParserResult<Expr> Parser::parseExprIs() {
|
||||||
SourceLoc isLoc = consumeLoc(tok::kw_is);
|
SourceLoc isLoc = consumeToken(tok::kw_is);
|
||||||
|
|
||||||
ParserResult<TypeRepr> type = parseType(diag::expected_type_after_is);
|
ParserResult<TypeRepr> type = parseType(diag::expected_type_after_is);
|
||||||
if (type.hasCodeCompletion())
|
if (type.hasCodeCompletion())
|
||||||
@@ -82,15 +82,15 @@ ParserResult<Expr> Parser::parseExprIs() {
|
|||||||
/// 'as!' type
|
/// 'as!' type
|
||||||
ParserResult<Expr> Parser::parseExprAs() {
|
ParserResult<Expr> Parser::parseExprAs() {
|
||||||
// Parse the 'as'.
|
// Parse the 'as'.
|
||||||
SourceLoc asLoc = consumeLoc(tok::kw_as);
|
SourceLoc asLoc = consumeToken(tok::kw_as);
|
||||||
|
|
||||||
// Parse the postfix '?'.
|
// Parse the postfix '?'.
|
||||||
SourceLoc questionLoc;
|
SourceLoc questionLoc;
|
||||||
SourceLoc exclaimLoc;
|
SourceLoc exclaimLoc;
|
||||||
if (Tok.is(tok::question_postfix)) {
|
if (Tok.is(tok::question_postfix)) {
|
||||||
questionLoc = consumeLoc(tok::question_postfix);
|
questionLoc = consumeToken(tok::question_postfix);
|
||||||
} else if (Tok.is(tok::exclaim_postfix)) {
|
} else if (Tok.is(tok::exclaim_postfix)) {
|
||||||
exclaimLoc = consumeLoc(tok::exclaim_postfix);
|
exclaimLoc = consumeToken(tok::exclaim_postfix);
|
||||||
}
|
}
|
||||||
|
|
||||||
ParserResult<TypeRepr> type = parseType(diag::expected_type_after_as);
|
ParserResult<TypeRepr> type = parseType(diag::expected_type_after_as);
|
||||||
@@ -120,16 +120,16 @@ ParserResult<Expr> Parser::parseExprAs() {
|
|||||||
ParserResult<Expr> Parser::parseExprArrow() {
|
ParserResult<Expr> Parser::parseExprArrow() {
|
||||||
SourceLoc throwsLoc, arrowLoc;
|
SourceLoc throwsLoc, arrowLoc;
|
||||||
if (Tok.is(tok::kw_throws)) {
|
if (Tok.is(tok::kw_throws)) {
|
||||||
throwsLoc = consumeLoc(tok::kw_throws);
|
throwsLoc = consumeToken(tok::kw_throws);
|
||||||
if (!Tok.is(tok::arrow)) {
|
if (!Tok.is(tok::arrow)) {
|
||||||
diagnose(throwsLoc, diag::throws_in_wrong_position);
|
diagnose(throwsLoc, diag::throws_in_wrong_position);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arrowLoc = consumeLoc(tok::arrow);
|
arrowLoc = consumeToken(tok::arrow);
|
||||||
if (Tok.is(tok::kw_throws)) {
|
if (Tok.is(tok::kw_throws)) {
|
||||||
diagnose(Tok.getLoc(), diag::throws_in_wrong_position);
|
diagnose(Tok.getLoc(), diag::throws_in_wrong_position);
|
||||||
throwsLoc = consumeLoc(tok::kw_throws);
|
throwsLoc = consumeToken(tok::kw_throws);
|
||||||
}
|
}
|
||||||
auto arrow = new (Context) ArrowExpr(throwsLoc, arrowLoc);
|
auto arrow = new (Context) ArrowExpr(throwsLoc, arrowLoc);
|
||||||
return makeParserResult(arrow);
|
return makeParserResult(arrow);
|
||||||
@@ -208,7 +208,7 @@ parse_operator:
|
|||||||
|
|
||||||
case tok::question_infix: {
|
case tok::question_infix: {
|
||||||
// Save the '?'.
|
// Save the '?'.
|
||||||
SourceLoc questionLoc = consumeLoc();
|
SourceLoc questionLoc = consumeToken();
|
||||||
|
|
||||||
// Parse the middle expression of the ternary.
|
// Parse the middle expression of the ternary.
|
||||||
ParserResult<Expr> middle =
|
ParserResult<Expr> middle =
|
||||||
@@ -226,7 +226,7 @@ parse_operator:
|
|||||||
{startLoc, middle.get()->getSourceRange().End}));
|
{startLoc, middle.get()->getSourceRange().End}));
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceLoc colonLoc = consumeLoc();
|
SourceLoc colonLoc = consumeToken();
|
||||||
|
|
||||||
auto *unresolvedIf
|
auto *unresolvedIf
|
||||||
= new (Context) IfExpr(questionLoc,
|
= new (Context) IfExpr(questionLoc,
|
||||||
@@ -245,7 +245,7 @@ parse_operator:
|
|||||||
if (InVarOrLetPattern)
|
if (InVarOrLetPattern)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
SourceLoc equalsLoc = consumeLoc();
|
SourceLoc equalsLoc = consumeToken();
|
||||||
auto *assign = new (Context) AssignExpr(equalsLoc);
|
auto *assign = new (Context) AssignExpr(equalsLoc);
|
||||||
SequencedExprs.push_back(assign);
|
SequencedExprs.push_back(assign);
|
||||||
Message = diag::expected_expr_assignment;
|
Message = diag::expected_expr_assignment;
|
||||||
@@ -260,7 +260,7 @@ parse_operator:
|
|||||||
SequencedExprs.push_back(assign);
|
SequencedExprs.push_back(assign);
|
||||||
CodeCompletion->completeAssignmentRHS(assign);
|
CodeCompletion->completeAssignmentRHS(assign);
|
||||||
}
|
}
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (SequencedExprs.size() > 0 && (SequencedExprs.size() & 1) == 0) {
|
if (SequencedExprs.size() > 0 && (SequencedExprs.size() & 1) == 0) {
|
||||||
// Make sure we have odd number of sequence exprs.
|
// Make sure we have odd number of sequence exprs.
|
||||||
SequencedExprs.pop_back();
|
SequencedExprs.pop_back();
|
||||||
@@ -362,7 +362,7 @@ ParserResult<Expr> Parser::parseExprSequenceElement(Diag<> message,
|
|||||||
Optional<syntax::Token> trySuffix;
|
Optional<syntax::Token> trySuffix;
|
||||||
if (hadTry && Tok.isAny(tok::exclaim_postfix, tok::question_postfix)) {
|
if (hadTry && Tok.isAny(tok::exclaim_postfix, tok::question_postfix)) {
|
||||||
trySuffix = Tok;
|
trySuffix = Tok;
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
ParserResult<Expr> sub = parseExprUnary(message, isExprBasic);
|
ParserResult<Expr> sub = parseExprUnary(message, isExprBasic);
|
||||||
@@ -422,7 +422,7 @@ ParserResult<Expr> Parser::parseExprUnary(Diag<> Message, bool isExprBasic) {
|
|||||||
return parseExprPostfix(Message, isExprBasic);
|
return parseExprPostfix(Message, isExprBasic);
|
||||||
|
|
||||||
case tok::amp_prefix: {
|
case tok::amp_prefix: {
|
||||||
SourceLoc Loc = consumeLoc(tok::amp_prefix);
|
SourceLoc Loc = consumeToken(tok::amp_prefix);
|
||||||
|
|
||||||
ParserResult<Expr> SubExpr = parseExprUnary(Message, isExprBasic);
|
ParserResult<Expr> SubExpr = parseExprUnary(Message, isExprBasic);
|
||||||
if (SubExpr.hasCodeCompletion())
|
if (SubExpr.hasCodeCompletion())
|
||||||
@@ -486,14 +486,14 @@ ParserResult<Expr> Parser::parseExprUnary(Diag<> Message, bool isExprBasic) {
|
|||||||
///
|
///
|
||||||
ParserResult<Expr> Parser::parseExprKeyPath() {
|
ParserResult<Expr> Parser::parseExprKeyPath() {
|
||||||
// Consume '#keyPath'.
|
// Consume '#keyPath'.
|
||||||
SourceLoc keywordLoc = consumeLoc(tok::pound_keyPath);
|
SourceLoc keywordLoc = consumeToken(tok::pound_keyPath);
|
||||||
|
|
||||||
// Parse the leading '('.
|
// Parse the leading '('.
|
||||||
if (!Tok.is(tok::l_paren)) {
|
if (!Tok.is(tok::l_paren)) {
|
||||||
diagnose(Tok, diag::expr_keypath_expected_lparen);
|
diagnose(Tok, diag::expr_keypath_expected_lparen);
|
||||||
return makeParserError();
|
return makeParserError();
|
||||||
}
|
}
|
||||||
SourceLoc lParenLoc = consumeLoc(tok::l_paren);
|
SourceLoc lParenLoc = consumeToken(tok::l_paren);
|
||||||
|
|
||||||
// Handle code completion.
|
// Handle code completion.
|
||||||
SmallVector<Identifier, 4> names;
|
SmallVector<Identifier, 4> names;
|
||||||
@@ -509,7 +509,7 @@ ParserResult<Expr> Parser::parseExprKeyPath() {
|
|||||||
CodeCompletion->completeExprKeyPath(expr, hasDot);
|
CodeCompletion->completeExprKeyPath(expr, hasDot);
|
||||||
|
|
||||||
// Eat the code completion token because we handled it.
|
// Eat the code completion token because we handled it.
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
return makeParserCodeCompletionResult(expr);
|
return makeParserCodeCompletionResult(expr);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -558,7 +558,7 @@ ParserResult<Expr> Parser::parseExprKeyPath() {
|
|||||||
if (status.isError()) {
|
if (status.isError()) {
|
||||||
skipUntilDeclStmtRBrace(tok::r_paren);
|
skipUntilDeclStmtRBrace(tok::r_paren);
|
||||||
if (Tok.is(tok::r_paren))
|
if (Tok.is(tok::r_paren))
|
||||||
rParenLoc = consumeLoc();
|
rParenLoc = consumeToken();
|
||||||
else
|
else
|
||||||
rParenLoc = Tok.getLoc();
|
rParenLoc = Tok.getLoc();
|
||||||
} else {
|
} else {
|
||||||
@@ -588,14 +588,14 @@ ParserResult<Expr> Parser::parseExprKeyPath() {
|
|||||||
///
|
///
|
||||||
ParserResult<Expr> Parser::parseExprSelector() {
|
ParserResult<Expr> Parser::parseExprSelector() {
|
||||||
// Consume '#selector'.
|
// Consume '#selector'.
|
||||||
SourceLoc keywordLoc = consumeLoc(tok::pound_selector);
|
SourceLoc keywordLoc = consumeToken(tok::pound_selector);
|
||||||
|
|
||||||
// Parse the leading '('.
|
// Parse the leading '('.
|
||||||
if (!Tok.is(tok::l_paren)) {
|
if (!Tok.is(tok::l_paren)) {
|
||||||
diagnose(Tok, diag::expr_selector_expected_lparen);
|
diagnose(Tok, diag::expr_selector_expected_lparen);
|
||||||
return makeParserError();
|
return makeParserError();
|
||||||
}
|
}
|
||||||
SourceLoc lParenLoc = consumeLoc(tok::l_paren);
|
SourceLoc lParenLoc = consumeToken(tok::l_paren);
|
||||||
SourceLoc modifierLoc;
|
SourceLoc modifierLoc;
|
||||||
|
|
||||||
// Parse possible 'getter:' or 'setter:' modifiers, and determine
|
// Parse possible 'getter:' or 'setter:' modifiers, and determine
|
||||||
@@ -610,8 +610,8 @@ ParserResult<Expr> Parser::parseExprSelector() {
|
|||||||
else
|
else
|
||||||
selectorKind = ObjCSelectorExpr::Setter;
|
selectorKind = ObjCSelectorExpr::Setter;
|
||||||
|
|
||||||
modifierLoc = consumeLoc(tok::identifier);
|
modifierLoc = consumeToken(tok::identifier);
|
||||||
(void)consumeLoc(tok::colon);
|
(void)consumeToken(tok::colon);
|
||||||
} else {
|
} else {
|
||||||
selectorKind = ObjCSelectorExpr::Method;
|
selectorKind = ObjCSelectorExpr::Method;
|
||||||
}
|
}
|
||||||
@@ -643,7 +643,7 @@ ParserResult<Expr> Parser::parseExprSelector() {
|
|||||||
if (subExpr.isParseError()) {
|
if (subExpr.isParseError()) {
|
||||||
skipUntilDeclStmtRBrace(tok::r_paren);
|
skipUntilDeclStmtRBrace(tok::r_paren);
|
||||||
if (Tok.is(tok::r_paren))
|
if (Tok.is(tok::r_paren))
|
||||||
rParenLoc = consumeLoc();
|
rParenLoc = consumeToken();
|
||||||
else
|
else
|
||||||
rParenLoc = Tok.getLoc();
|
rParenLoc = Tok.getLoc();
|
||||||
} else {
|
} else {
|
||||||
@@ -689,7 +689,7 @@ UnresolvedDeclRefExpr *Parser::parseExprOperator() {
|
|||||||
DeclRefKind refKind = getDeclRefKindForOperator(Tok.getKind());
|
DeclRefKind refKind = getDeclRefKindForOperator(Tok.getKind());
|
||||||
SourceLoc loc = Tok.getLoc();
|
SourceLoc loc = Tok.getLoc();
|
||||||
Identifier name = Context.getIdentifier(Tok.getText());
|
Identifier name = Context.getIdentifier(Tok.getText());
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
// Bypass local lookup.
|
// Bypass local lookup.
|
||||||
return new (Context) UnresolvedDeclRefExpr(name, refKind, DeclNameLoc(loc));
|
return new (Context) UnresolvedDeclRefExpr(name, refKind, DeclNameLoc(loc));
|
||||||
@@ -732,7 +732,7 @@ static VarDecl *getImplicitSelfDeclForSuperContext(Parser &P,
|
|||||||
/// 'super' '[' expr ']'
|
/// 'super' '[' expr ']'
|
||||||
ParserResult<Expr> Parser::parseExprSuper(bool isExprBasic) {
|
ParserResult<Expr> Parser::parseExprSuper(bool isExprBasic) {
|
||||||
// Parse the 'super' reference.
|
// Parse the 'super' reference.
|
||||||
SourceLoc superLoc = consumeLoc(tok::kw_super);
|
SourceLoc superLoc = consumeToken(tok::kw_super);
|
||||||
|
|
||||||
VarDecl *selfDecl = getImplicitSelfDeclForSuperContext(*this,
|
VarDecl *selfDecl = getImplicitSelfDeclForSuperContext(*this,
|
||||||
CurDeclContext,
|
CurDeclContext,
|
||||||
@@ -747,7 +747,7 @@ ParserResult<Expr> Parser::parseExprSuper(bool isExprBasic) {
|
|||||||
if (Tok.isAny(tok::period, tok::period_prefix)) {
|
if (Tok.isAny(tok::period, tok::period_prefix)) {
|
||||||
// 'super.' must be followed by a member or initializer ref.
|
// 'super.' must be followed by a member or initializer ref.
|
||||||
|
|
||||||
SourceLoc dotLoc = consumeLoc();
|
SourceLoc dotLoc = consumeToken();
|
||||||
|
|
||||||
if (Tok.is(tok::code_complete)) {
|
if (Tok.is(tok::code_complete)) {
|
||||||
if (CodeCompletion) {
|
if (CodeCompletion) {
|
||||||
@@ -756,7 +756,7 @@ ParserResult<Expr> Parser::parseExprSuper(bool isExprBasic) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Eat the code completion token because we handled it.
|
// Eat the code completion token because we handled it.
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
return makeParserCodeCompletionResult(superRef);
|
return makeParserCodeCompletionResult(superRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -802,7 +802,7 @@ ParserResult<Expr> Parser::parseExprSuper(bool isExprBasic) {
|
|||||||
CodeCompletion->completeExprSuper(SRE);
|
CodeCompletion->completeExprSuper(SRE);
|
||||||
}
|
}
|
||||||
// Eat the code completion token because we handled it.
|
// Eat the code completion token because we handled it.
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
return makeParserCodeCompletionResult(superRef);
|
return makeParserCodeCompletionResult(superRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -856,7 +856,7 @@ static bool isStartOfGetSetAccessor(Parser &P) {
|
|||||||
Parser::BacktrackingScope Backtrack(P);
|
Parser::BacktrackingScope Backtrack(P);
|
||||||
|
|
||||||
// Eat the "{".
|
// Eat the "{".
|
||||||
P.consumeLoc(tok::l_brace);
|
P.consumeToken(tok::l_brace);
|
||||||
|
|
||||||
// Eat attributes, if present.
|
// Eat attributes, if present.
|
||||||
while (P.consumeIf(tok::at_sign)) {
|
while (P.consumeIf(tok::at_sign)) {
|
||||||
@@ -909,7 +909,7 @@ static bool isValidTrailingClosure(bool isExprBasic, Parser &P){
|
|||||||
// to see if it is immediately followed by '{', 'where', or comma. If so,
|
// to see if it is immediately followed by '{', 'where', or comma. If so,
|
||||||
// we consider it to be part of the proceeding expression.
|
// we consider it to be part of the proceeding expression.
|
||||||
Parser::BacktrackingScope backtrack(P);
|
Parser::BacktrackingScope backtrack(P);
|
||||||
P.consumeLoc(tok::l_brace);
|
P.consumeToken(tok::l_brace);
|
||||||
P.skipUntil(tok::r_brace);
|
P.skipUntil(tok::r_brace);
|
||||||
SourceLoc endLoc;
|
SourceLoc endLoc;
|
||||||
if (!P.consumeIf(tok::r_brace, endLoc) ||
|
if (!P.consumeIf(tok::r_brace, endLoc) ||
|
||||||
@@ -957,8 +957,8 @@ static bool canParseTypeOf(Parser &P) {
|
|||||||
}
|
}
|
||||||
// Look ahead to parse the parenthesized expression.
|
// Look ahead to parse the parenthesized expression.
|
||||||
Parser::BacktrackingScope Backtrack(P);
|
Parser::BacktrackingScope Backtrack(P);
|
||||||
P.consumeLoc(tok::identifier);
|
P.consumeToken(tok::identifier);
|
||||||
P.consumeLoc(tok::l_paren);
|
P.consumeToken(tok::l_paren);
|
||||||
// The first argument label must be 'of'.
|
// The first argument label must be 'of'.
|
||||||
if (!(P.Tok.getText() == "of" && P.peekToken().is(tok::colon))) {
|
if (!(P.Tok.getText() == "of" && P.peekToken().is(tok::colon))) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1047,14 +1047,14 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
switch (Tok.getKind()) {
|
switch (Tok.getKind()) {
|
||||||
case tok::integer_literal: {
|
case tok::integer_literal: {
|
||||||
StringRef Text = copyAndStripUnderscores(Context, Tok.getText());
|
StringRef Text = copyAndStripUnderscores(Context, Tok.getText());
|
||||||
SourceLoc Loc = consumeLoc(tok::integer_literal);
|
SourceLoc Loc = consumeToken(tok::integer_literal);
|
||||||
Result = makeParserResult(new (Context) IntegerLiteralExpr(Text, Loc,
|
Result = makeParserResult(new (Context) IntegerLiteralExpr(Text, Loc,
|
||||||
/*Implicit=*/false));
|
/*Implicit=*/false));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case tok::floating_literal: {
|
case tok::floating_literal: {
|
||||||
StringRef Text = copyAndStripUnderscores(Context, Tok.getText());
|
StringRef Text = copyAndStripUnderscores(Context, Tok.getText());
|
||||||
SourceLoc Loc = consumeLoc(tok::floating_literal);
|
SourceLoc Loc = consumeToken(tok::floating_literal);
|
||||||
Result = makeParserResult(new (Context) FloatLiteralExpr(Text, Loc,
|
Result = makeParserResult(new (Context) FloatLiteralExpr(Text, Loc,
|
||||||
/*Implicit=*/false));
|
/*Implicit=*/false));
|
||||||
break;
|
break;
|
||||||
@@ -1068,7 +1068,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
|
|
||||||
diagnose(Tok.getLoc(), diag::string_literal_no_atsign)
|
diagnose(Tok.getLoc(), diag::string_literal_no_atsign)
|
||||||
.fixItRemove(Tok.getLoc());
|
.fixItRemove(Tok.getLoc());
|
||||||
consumeLoc(tok::at_sign);
|
consumeToken(tok::at_sign);
|
||||||
SWIFT_FALLTHROUGH;
|
SWIFT_FALLTHROUGH;
|
||||||
|
|
||||||
case tok::string_literal: // "foo"
|
case tok::string_literal: // "foo"
|
||||||
@@ -1077,14 +1077,14 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
|
|
||||||
case tok::kw_nil:
|
case tok::kw_nil:
|
||||||
Result = makeParserResult(
|
Result = makeParserResult(
|
||||||
new (Context) NilLiteralExpr(consumeLoc(tok::kw_nil)));
|
new (Context) NilLiteralExpr(consumeToken(tok::kw_nil)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case tok::kw_true:
|
case tok::kw_true:
|
||||||
case tok::kw_false: {
|
case tok::kw_false: {
|
||||||
bool isTrue = Tok.is(tok::kw_true);
|
bool isTrue = Tok.is(tok::kw_true);
|
||||||
Result = makeParserResult(
|
Result = makeParserResult(
|
||||||
new (Context) BooleanLiteralExpr(isTrue, consumeLoc()));
|
new (Context) BooleanLiteralExpr(isTrue, consumeToken()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1114,7 +1114,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
case tok::pound_line:
|
case tok::pound_line:
|
||||||
case tok::pound_dsohandle: {
|
case tok::pound_dsohandle: {
|
||||||
auto Kind = getMagicIdentifierLiteralKind(Tok.getKind());
|
auto Kind = getMagicIdentifierLiteralKind(Tok.getKind());
|
||||||
SourceLoc Loc = consumeLoc();
|
SourceLoc Loc = consumeToken();
|
||||||
Result = makeParserResult(
|
Result = makeParserResult(
|
||||||
new (Context) MagicIdentifierLiteralExpr(Kind, Loc, /*Implicit=*/false));
|
new (Context) MagicIdentifierLiteralExpr(Kind, Loc, /*Implicit=*/false));
|
||||||
break;
|
break;
|
||||||
@@ -1174,7 +1174,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
// If the next token is '_', parse a discard expression.
|
// If the next token is '_', parse a discard expression.
|
||||||
case tok::kw__:
|
case tok::kw__:
|
||||||
Result = makeParserResult(
|
Result = makeParserResult(
|
||||||
new (Context) DiscardAssignmentExpr(consumeLoc(), /*Implicit=*/false));
|
new (Context) DiscardAssignmentExpr(consumeToken(), /*Implicit=*/false));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case tok::pound_selector: // expr-selector
|
case tok::pound_selector: // expr-selector
|
||||||
@@ -1187,7 +1187,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
|
|
||||||
case tok::period: //=.foo
|
case tok::period: //=.foo
|
||||||
case tok::period_prefix: { // .foo
|
case tok::period_prefix: { // .foo
|
||||||
SourceLoc DotLoc = consumeLoc();
|
SourceLoc DotLoc = consumeToken();
|
||||||
|
|
||||||
// Special case ".<integer_literal>" like ".4". This isn't valid, but the
|
// Special case ".<integer_literal>" like ".4". This isn't valid, but the
|
||||||
// developer almost certainly meant to use "0.4". Diagnose this, and
|
// developer almost certainly meant to use "0.4". Diagnose this, and
|
||||||
@@ -1203,7 +1203,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
auto FltText = StringRef(Ptr, Tok.getWidth()+2);
|
auto FltText = StringRef(Ptr, Tok.getWidth()+2);
|
||||||
FltText = copyAndStripUnderscores(Context, FltText);
|
FltText = copyAndStripUnderscores(Context, FltText);
|
||||||
|
|
||||||
consumeLoc(tok::integer_literal);
|
consumeToken(tok::integer_literal);
|
||||||
Result = makeParserResult(new (Context)
|
Result = makeParserResult(new (Context)
|
||||||
FloatLiteralExpr(FltText, DotLoc,
|
FloatLiteralExpr(FltText, DotLoc,
|
||||||
/*Implicit=*/false));
|
/*Implicit=*/false));
|
||||||
@@ -1228,7 +1228,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
bool HasReturn = false;
|
bool HasReturn = false;
|
||||||
|
|
||||||
// Until we see the code completion token, collect identifiers.
|
// Until we see the code completion token, collect identifiers.
|
||||||
for (Tok = L->lex(); !Tok.is(tok::code_complete); consumeLoc()) {
|
for (Tok = L->lex(); !Tok.is(tok::code_complete); consumeToken()) {
|
||||||
if (!HasReturn)
|
if (!HasReturn)
|
||||||
HasReturn = Tok.is(tok::kw_return);
|
HasReturn = Tok.is(tok::kw_return);
|
||||||
if (Tok.is(tok::identifier)) {
|
if (Tok.is(tok::identifier)) {
|
||||||
@@ -1239,7 +1239,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
} else {
|
} else {
|
||||||
Result.setHasCodeCompletion();
|
Result.setHasCodeCompletion();
|
||||||
}
|
}
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1346,10 +1346,10 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
|
|
||||||
auto LSquareLoc = Tok.getLoc();
|
auto LSquareLoc = Tok.getLoc();
|
||||||
auto LSquareTokRange = Tok.getRange();
|
auto LSquareTokRange = Tok.getRange();
|
||||||
(void)consumeLoc(tok::l_square_lit);
|
(void)consumeToken(tok::l_square_lit);
|
||||||
|
|
||||||
if (Tok.is(tok::pound)) {
|
if (Tok.is(tok::pound)) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (!Tok.is(tok::identifier))
|
if (!Tok.is(tok::identifier))
|
||||||
diagnose(LSquareLoc, diag::expected_object_literal_identifier);
|
diagnose(LSquareLoc, diag::expected_object_literal_identifier);
|
||||||
skipUntil(tok::r_square_lit);
|
skipUntil(tok::r_square_lit);
|
||||||
@@ -1362,7 +1362,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
// This should be an invariant based on the check in
|
// This should be an invariant based on the check in
|
||||||
// isCollectionLiteralStartingWithLSquareLit().
|
// isCollectionLiteralStartingWithLSquareLit().
|
||||||
auto RSquareTokRange = Tok.getRange();
|
auto RSquareTokRange = Tok.getRange();
|
||||||
(void)consumeLoc(tok::r_square_lit);
|
(void)consumeToken(tok::r_square_lit);
|
||||||
|
|
||||||
// Issue a diagnostic for the legacy syntax and provide a fixit
|
// Issue a diagnostic for the legacy syntax and provide a fixit
|
||||||
// to strip away the '[#' and '#]'
|
// to strip away the '[#' and '#]'
|
||||||
@@ -1393,13 +1393,13 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
(!InVarOrLetPattern || InVarOrLetPattern == IVOLP_InMatchingPattern))
|
(!InVarOrLetPattern || InVarOrLetPattern == IVOLP_InMatchingPattern))
|
||||||
CodeCompletion->completePostfixExprBeginning(dyn_cast<CodeCompletionExpr>(
|
CodeCompletion->completePostfixExprBeginning(dyn_cast<CodeCompletionExpr>(
|
||||||
Result.get()));
|
Result.get()));
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Eat an invalid token in an expression context. Error tokens are diagnosed
|
// Eat an invalid token in an expression context. Error tokens are diagnosed
|
||||||
// by the lexer, so there is no reason to emit another diagnostic.
|
// by the lexer, so there is no reason to emit another diagnostic.
|
||||||
case tok::unknown:
|
case tok::unknown:
|
||||||
consumeLoc(tok::unknown);
|
consumeToken(tok::unknown);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1429,7 +1429,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
// Handle "x.42" - a tuple index.
|
// Handle "x.42" - a tuple index.
|
||||||
if (Tok.is(tok::integer_literal)) {
|
if (Tok.is(tok::integer_literal)) {
|
||||||
DeclName name = Context.getIdentifier(Tok.getText());
|
DeclName name = Context.getIdentifier(Tok.getText());
|
||||||
SourceLoc nameLoc = consumeLoc(tok::integer_literal);
|
SourceLoc nameLoc = consumeToken(tok::integer_literal);
|
||||||
|
|
||||||
// Don't allow '.<integer literal>' following a numeric literal
|
// Don't allow '.<integer literal>' following a numeric literal
|
||||||
// expression (unless in #if env, for 1.2.3.4 version numbers)
|
// expression (unless in #if env, for 1.2.3.4 version numbers)
|
||||||
@@ -1450,7 +1450,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
// Handle "x.self" expr.
|
// Handle "x.self" expr.
|
||||||
if (Tok.is(tok::kw_self)) {
|
if (Tok.is(tok::kw_self)) {
|
||||||
Result = makeParserResult(
|
Result = makeParserResult(
|
||||||
new (Context) DotSelfExpr(Result.get(), TokLoc, consumeLoc()));
|
new (Context) DotSelfExpr(Result.get(), TokLoc, consumeToken()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1474,7 +1474,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
new (Context) UnresolvedDotExpr(Result.get(), TokLoc,
|
new (Context) UnresolvedDotExpr(Result.get(), TokLoc,
|
||||||
Name, DeclNameLoc(Tok.getLoc()),
|
Name, DeclNameLoc(Tok.getLoc()),
|
||||||
/*Implicit=*/false));
|
/*Implicit=*/false));
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
// Fall into the next code completion handler.
|
// Fall into the next code completion handler.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1483,7 +1483,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
if (CodeCompletion && Result.isNonNull())
|
if (CodeCompletion && Result.isNonNull())
|
||||||
CodeCompletion->completeDotExpr(Result.get(), /*DotLoc=*/TokLoc);
|
CodeCompletion->completeDotExpr(Result.get(), /*DotLoc=*/TokLoc);
|
||||||
// Eat the code completion token because we handled it.
|
// Eat the code completion token because we handled it.
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
Result.setHasCodeCompletion();
|
Result.setHasCodeCompletion();
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
@@ -1609,7 +1609,7 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
CodeCompletion->completePostfixExpr(Result.get(), hasSpace);
|
CodeCompletion->completePostfixExpr(Result.get(), hasSpace);
|
||||||
}
|
}
|
||||||
// Eat the code completion token because we handled it.
|
// Eat the code completion token because we handled it.
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
return makeParserCodeCompletionResult<Expr>();
|
return makeParserCodeCompletionResult<Expr>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1657,7 +1657,7 @@ createStringLiteralExprFromSegment(ASTContext &Ctx,
|
|||||||
ParserResult<Expr> Parser::parseExprStringLiteral() {
|
ParserResult<Expr> Parser::parseExprStringLiteral() {
|
||||||
SmallVector<Lexer::StringSegment, 1> Segments;
|
SmallVector<Lexer::StringSegment, 1> Segments;
|
||||||
L->getStringLiteralSegments(Tok, Segments);
|
L->getStringLiteralSegments(Tok, Segments);
|
||||||
SourceLoc Loc = consumeLoc();
|
SourceLoc Loc = consumeToken();
|
||||||
|
|
||||||
// The simple case: just a single literal segment.
|
// The simple case: just a single literal segment.
|
||||||
if (Segments.size() == 1 &&
|
if (Segments.size() == 1 &&
|
||||||
@@ -1701,10 +1701,10 @@ ParserResult<Expr> Parser::parseExprStringLiteral() {
|
|||||||
llvm::SaveAndRestore<Lexer *> T(L, &LocalLex);
|
llvm::SaveAndRestore<Lexer *> T(L, &LocalLex);
|
||||||
|
|
||||||
// Prime the new lexer with a '(' as the first token.
|
// Prime the new lexer with a '(' as the first token.
|
||||||
// We might be at tok::eof now, so ensure that consumeLoc() does not
|
// We might be at tok::eof now, so ensure that consumeToken() does not
|
||||||
// assert about lexing past eof.
|
// assert about lexing past eof.
|
||||||
Tok = syntax::Token::unknown();
|
Tok = syntax::Token::unknown();
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
assert(Tok.is(tok::l_paren));
|
assert(Tok.is(tok::l_paren));
|
||||||
|
|
||||||
ParserResult<Expr> E = parseExprList(tok::l_paren, tok::r_paren);
|
ParserResult<Expr> E = parseExprList(tok::l_paren, tok::r_paren);
|
||||||
@@ -1754,7 +1754,7 @@ DeclName Parser::parseUnqualifiedDeclName(bool afterDot,
|
|||||||
if (Tok.isAny(tok::identifier, tok::kw_Self, tok::kw_self)) {
|
if (Tok.isAny(tok::identifier, tok::kw_Self, tok::kw_self)) {
|
||||||
baseNameLoc = consumeIdentifier(&baseName);
|
baseNameLoc = consumeIdentifier(&baseName);
|
||||||
} else if (afterDot && Tok.isKeyword()) {
|
} else if (afterDot && Tok.isKeyword()) {
|
||||||
baseNameLoc = consumeLoc();
|
baseNameLoc = consumeToken();
|
||||||
} else {
|
} else {
|
||||||
checkForInputIncomplete();
|
checkForInputIncomplete();
|
||||||
diagnose(Tok, diag);
|
diagnose(Tok, diag);
|
||||||
@@ -1780,12 +1780,12 @@ DeclName Parser::parseUnqualifiedDeclName(bool afterDot,
|
|||||||
|
|
||||||
SmallVector<Identifier, 2> argumentLabels;
|
SmallVector<Identifier, 2> argumentLabels;
|
||||||
SmallVector<SourceLoc, 2> argumentLabelLocs;
|
SmallVector<SourceLoc, 2> argumentLabelLocs;
|
||||||
SourceLoc lparenLoc = consumeLoc(tok::l_paren);
|
SourceLoc lparenLoc = consumeToken(tok::l_paren);
|
||||||
SourceLoc rparenLoc;
|
SourceLoc rparenLoc;
|
||||||
while (true) {
|
while (true) {
|
||||||
// Terminate at ')'.
|
// Terminate at ')'.
|
||||||
if (Tok.is(tok::r_paren)) {
|
if (Tok.is(tok::r_paren)) {
|
||||||
rparenLoc = consumeLoc(tok::r_paren);
|
rparenLoc = consumeToken(tok::r_paren);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1794,7 +1794,7 @@ DeclName Parser::parseUnqualifiedDeclName(bool afterDot,
|
|||||||
diagnose(Tok, diag::empty_arg_label_underscore)
|
diagnose(Tok, diag::empty_arg_label_underscore)
|
||||||
.fixItInsert(Tok.getLoc(), "_");
|
.fixItInsert(Tok.getLoc(), "_");
|
||||||
argumentLabels.push_back(Identifier());
|
argumentLabels.push_back(Identifier());
|
||||||
argumentLabelLocs.push_back(consumeLoc(tok::colon));
|
argumentLabelLocs.push_back(consumeToken(tok::colon));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we see a potential argument label followed by a ':', consume
|
// If we see a potential argument label followed by a ':', consume
|
||||||
@@ -1809,8 +1809,8 @@ DeclName Parser::parseUnqualifiedDeclName(bool afterDot,
|
|||||||
argumentLabels.push_back(Identifier());
|
argumentLabels.push_back(Identifier());
|
||||||
else
|
else
|
||||||
argumentLabels.push_back(Context.getIdentifier(Tok.getText()));
|
argumentLabels.push_back(Context.getIdentifier(Tok.getText()));
|
||||||
argumentLabelLocs.push_back(consumeLoc());
|
argumentLabelLocs.push_back(consumeToken());
|
||||||
(void)consumeLoc(tok::colon);
|
(void)consumeToken(tok::colon);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1968,7 +1968,7 @@ Expr *Parser::parseExprEditorPlaceholder(const syntax::Token &PlaceholderTok,
|
|||||||
// Temporarily swap out the parser's current lexer with our new one.
|
// Temporarily swap out the parser's current lexer with our new one.
|
||||||
llvm::SaveAndRestore<Lexer *> T(L, &LocalLex);
|
llvm::SaveAndRestore<Lexer *> T(L, &LocalLex);
|
||||||
Tok = syntax::Token::unknown(); // we might be at tok::eof now.
|
Tok = syntax::Token::unknown(); // we might be at tok::eof now.
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return parseType().getPtrOrNull();
|
return parseType().getPtrOrNull();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2033,10 +2033,10 @@ parseClosureSignatureIfPresent(SmallVectorImpl<CaptureListEntry> &captureList,
|
|||||||
// Okay, we have a closure signature.
|
// Okay, we have a closure signature.
|
||||||
} else if (Tok.isIdentifierOrUnderscore()) {
|
} else if (Tok.isIdentifierOrUnderscore()) {
|
||||||
// Parse identifier (',' identifier)*
|
// Parse identifier (',' identifier)*
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
while (consumeIf(tok::comma)) {
|
while (consumeIf(tok::comma)) {
|
||||||
if (Tok.isIdentifierOrUnderscore()) {
|
if (Tok.isIdentifierOrUnderscore()) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2072,10 +2072,10 @@ parseClosureSignatureIfPresent(SmallVectorImpl<CaptureListEntry> &captureList,
|
|||||||
SourceLoc loc;
|
SourceLoc loc;
|
||||||
Ownership ownershipKind = Ownership::Strong;
|
Ownership ownershipKind = Ownership::Strong;
|
||||||
if (Tok.isContextualKeyword("weak")){
|
if (Tok.isContextualKeyword("weak")){
|
||||||
loc = consumeLoc(tok::identifier);
|
loc = consumeToken(tok::identifier);
|
||||||
ownershipKind = Ownership::Weak;
|
ownershipKind = Ownership::Weak;
|
||||||
} else if (Tok.isContextualKeyword("unowned")) {
|
} else if (Tok.isContextualKeyword("unowned")) {
|
||||||
loc = consumeLoc(tok::identifier);
|
loc = consumeToken(tok::identifier);
|
||||||
ownershipKind = Ownership::Unowned;
|
ownershipKind = Ownership::Unowned;
|
||||||
|
|
||||||
// Skip over "safe" and "unsafe" if present.
|
// Skip over "safe" and "unsafe" if present.
|
||||||
@@ -2128,7 +2128,7 @@ parseClosureSignatureIfPresent(SmallVectorImpl<CaptureListEntry> &captureList,
|
|||||||
} else {
|
} else {
|
||||||
// Otherwise, the name is a new declaration.
|
// Otherwise, the name is a new declaration.
|
||||||
consumeIdentifier(&name);
|
consumeIdentifier(&name);
|
||||||
consumeLoc(tok::equal);
|
consumeToken(tok::equal);
|
||||||
|
|
||||||
auto ExprResult = parseExpr(diag::expected_init_capture_specifier);
|
auto ExprResult = parseExpr(diag::expected_init_capture_specifier);
|
||||||
if (ExprResult.isNull())
|
if (ExprResult.isNull())
|
||||||
@@ -2163,7 +2163,7 @@ parseClosureSignatureIfPresent(SmallVectorImpl<CaptureListEntry> &captureList,
|
|||||||
diagnose(Tok, diag::expected_capture_list_end_rsquare);
|
diagnose(Tok, diag::expected_capture_list_end_rsquare);
|
||||||
skipUntil(tok::r_square);
|
skipUntil(tok::r_square);
|
||||||
if (Tok.is(tok::r_square))
|
if (Tok.is(tok::r_square))
|
||||||
consumeLoc(tok::r_square);
|
consumeToken(tok::r_square);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2192,7 +2192,7 @@ parseClosureSignatureIfPresent(SmallVectorImpl<CaptureListEntry> &captureList,
|
|||||||
SourceLoc(), Identifier(),
|
SourceLoc(), Identifier(),
|
||||||
Tok.getLoc(), name, Type(), nullptr);
|
Tok.getLoc(), name, Type(), nullptr);
|
||||||
elements.push_back(var);
|
elements.push_back(var);
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
// Consume a comma to continue.
|
// Consume a comma to continue.
|
||||||
} while (consumeIf(tok::comma));
|
} while (consumeIf(tok::comma));
|
||||||
@@ -2201,16 +2201,16 @@ parseClosureSignatureIfPresent(SmallVectorImpl<CaptureListEntry> &captureList,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Tok.is(tok::kw_throws)) {
|
if (Tok.is(tok::kw_throws)) {
|
||||||
throwsLoc = consumeLoc();
|
throwsLoc = consumeToken();
|
||||||
} else if (Tok.is(tok::kw_rethrows)) {
|
} else if (Tok.is(tok::kw_rethrows)) {
|
||||||
throwsLoc = consumeLoc();
|
throwsLoc = consumeToken();
|
||||||
diagnose(throwsLoc, diag::rethrowing_function_type);
|
diagnose(throwsLoc, diag::rethrowing_function_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the optional explicit return type.
|
// Parse the optional explicit return type.
|
||||||
if (Tok.is(tok::arrow)) {
|
if (Tok.is(tok::arrow)) {
|
||||||
// Consume the '->'.
|
// Consume the '->'.
|
||||||
arrowLoc = consumeLoc();
|
arrowLoc = consumeToken();
|
||||||
|
|
||||||
// Parse the type.
|
// Parse the type.
|
||||||
explicitResultType =
|
explicitResultType =
|
||||||
@@ -2225,7 +2225,7 @@ parseClosureSignatureIfPresent(SmallVectorImpl<CaptureListEntry> &captureList,
|
|||||||
|
|
||||||
// Parse the 'in'.
|
// Parse the 'in'.
|
||||||
if (Tok.is(tok::kw_in)) {
|
if (Tok.is(tok::kw_in)) {
|
||||||
inLoc = consumeLoc();
|
inLoc = consumeToken();
|
||||||
} else {
|
} else {
|
||||||
// Scan forward to see if we can find the 'in'. This re-synchronizes the
|
// Scan forward to see if we can find the 'in'. This re-synchronizes the
|
||||||
// parser so we can at least parse the body correctly.
|
// parser so we can at least parse the body correctly.
|
||||||
@@ -2242,7 +2242,7 @@ parseClosureSignatureIfPresent(SmallVectorImpl<CaptureListEntry> &captureList,
|
|||||||
if (!invalid) {
|
if (!invalid) {
|
||||||
diagnose(startLoc, diag::unexpected_tokens_before_closure_in);
|
diagnose(startLoc, diag::unexpected_tokens_before_closure_in);
|
||||||
}
|
}
|
||||||
inLoc = consumeLoc();
|
inLoc = consumeToken();
|
||||||
} else {
|
} else {
|
||||||
// We didn't find an 'in', backtrack to where we started. If this is the
|
// We didn't find an 'in', backtrack to where we started. If this is the
|
||||||
// first error, complain about the missing 'in'.
|
// first error, complain about the missing 'in'.
|
||||||
@@ -2267,7 +2267,7 @@ ParserResult<Expr> Parser::parseExprClosure() {
|
|||||||
T(InVarOrLetPattern, IVOLP_NotInVarOrLet);
|
T(InVarOrLetPattern, IVOLP_NotInVarOrLet);
|
||||||
|
|
||||||
// Parse the opening left brace.
|
// Parse the opening left brace.
|
||||||
SourceLoc leftBrace = consumeLoc();
|
SourceLoc leftBrace = consumeToken();
|
||||||
|
|
||||||
// Parse the closure-signature, if present.
|
// Parse the closure-signature, if present.
|
||||||
ParameterList *params = nullptr;
|
ParameterList *params = nullptr;
|
||||||
@@ -2285,7 +2285,7 @@ ParserResult<Expr> Parser::parseExprClosure() {
|
|||||||
if (!CurLocalContext) {
|
if (!CurLocalContext) {
|
||||||
skipUntil(tok::r_brace);
|
skipUntil(tok::r_brace);
|
||||||
if (Tok.is(tok::r_brace))
|
if (Tok.is(tok::r_brace))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return makeParserError();
|
return makeParserError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2401,7 +2401,7 @@ ParserResult<Expr> Parser::parseExprClosure() {
|
|||||||
/// dollarident
|
/// dollarident
|
||||||
Expr *Parser::parseExprAnonClosureArg() {
|
Expr *Parser::parseExprAnonClosureArg() {
|
||||||
StringRef Name = Tok.getText();
|
StringRef Name = Tok.getText();
|
||||||
SourceLoc Loc = consumeLoc(tok::dollarident);
|
SourceLoc Loc = consumeToken(tok::dollarident);
|
||||||
assert(Name[0] == '$' && "Not a dollarident");
|
assert(Name[0] == '$' && "Not a dollarident");
|
||||||
|
|
||||||
// We know from the lexer that this is all-numeric.
|
// We know from the lexer that this is all-numeric.
|
||||||
@@ -2508,7 +2508,7 @@ ParserStatus Parser::parseExprList(tok leftTok, tok rightTok,
|
|||||||
|
|
||||||
StructureMarkerRAII ParsingExprList(*this, Tok);
|
StructureMarkerRAII ParsingExprList(*this, Tok);
|
||||||
|
|
||||||
leftLoc = consumeLoc(leftTok);
|
leftLoc = consumeToken(leftTok);
|
||||||
ParserStatus status = parseList(rightTok, leftLoc, rightLoc, tok::comma,
|
ParserStatus status = parseList(rightTok, leftLoc, rightLoc, tok::comma,
|
||||||
/*OptionalSep=*/false,
|
/*OptionalSep=*/false,
|
||||||
/*AllowSepAfterLast=*/false,
|
/*AllowSepAfterLast=*/false,
|
||||||
@@ -2528,8 +2528,8 @@ ParserStatus Parser::parseExprList(tok leftTok, tok rightTok,
|
|||||||
|
|
||||||
if (!Tok.is(tok::kw__))
|
if (!Tok.is(tok::kw__))
|
||||||
FieldName = Context.getIdentifier(Tok.getText());
|
FieldName = Context.getIdentifier(Tok.getText());
|
||||||
FieldNameLoc = consumeLoc();
|
FieldNameLoc = consumeToken();
|
||||||
consumeLoc(tok::colon);
|
consumeToken(tok::colon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we have an operator decl ref '(<op>)'. The operator token in
|
// See if we have an operator decl ref '(<op>)'. The operator token in
|
||||||
@@ -2620,17 +2620,17 @@ ParserResult<Expr> Parser::parseTrailingClosure(SourceRange calleeRange) {
|
|||||||
// This will be removed in the future.
|
// This will be removed in the future.
|
||||||
bool Parser::isCollectionLiteralStartingWithLSquareLit() {
|
bool Parser::isCollectionLiteralStartingWithLSquareLit() {
|
||||||
BacktrackingScope backtracking(*this);
|
BacktrackingScope backtracking(*this);
|
||||||
(void)consumeLoc(tok::l_square_lit);
|
(void)consumeToken(tok::l_square_lit);
|
||||||
switch (Tok.getKind()) {
|
switch (Tok.getKind()) {
|
||||||
// Handle both degenerate '#' and '# identifier'.
|
// Handle both degenerate '#' and '# identifier'.
|
||||||
case tok::pound:
|
case tok::pound:
|
||||||
(void) consumeLoc();
|
(void) consumeToken();
|
||||||
if (Tok.is(tok::identifier)) skipSingle();
|
if (Tok.is(tok::identifier)) skipSingle();
|
||||||
break;
|
break;
|
||||||
#define POUND_OBJECT_LITERAL(kw, desc, proto)\
|
#define POUND_OBJECT_LITERAL(kw, desc, proto)\
|
||||||
case tok::pound_##kw: (void)consumeLoc(); break;
|
case tok::pound_##kw: (void)consumeToken(); break;
|
||||||
#define POUND_OLD_OBJECT_LITERAL(kw, new_kw, old_arg, new_arg)\
|
#define POUND_OLD_OBJECT_LITERAL(kw, new_kw, old_arg, new_arg)\
|
||||||
case tok::pound_##kw: (void)consumeLoc(); break;
|
case tok::pound_##kw: (void)consumeToken(); break;
|
||||||
#include "swift/Parse/Tokens.def"
|
#include "swift/Parse/Tokens.def"
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
@@ -2651,7 +2651,7 @@ Parser::parseExprObjectLiteral(ObjectLiteralExpr::LiteralKind LitKind,
|
|||||||
bool isExprBasic,
|
bool isExprBasic,
|
||||||
StringRef NewName) {
|
StringRef NewName) {
|
||||||
auto PoundTok = Tok;
|
auto PoundTok = Tok;
|
||||||
SourceLoc PoundLoc = consumeLoc();
|
SourceLoc PoundLoc = consumeToken();
|
||||||
// Parse a tuple of args
|
// Parse a tuple of args
|
||||||
if (!Tok.is(tok::l_paren)) {
|
if (!Tok.is(tok::l_paren)) {
|
||||||
diagnose(Tok, diag::expected_arg_list_in_object_literal);
|
diagnose(Tok, diag::expected_arg_list_in_object_literal);
|
||||||
@@ -2733,7 +2733,7 @@ Parser::parseExprCallSuffix(ParserResult<Expr> fn, bool isExprBasic) {
|
|||||||
// If there is a code completion token right after the '(', do a special case
|
// If there is a code completion token right after the '(', do a special case
|
||||||
// callback.
|
// callback.
|
||||||
if (peekToken().is(tok::code_complete) && CodeCompletion) {
|
if (peekToken().is(tok::code_complete) && CodeCompletion) {
|
||||||
consumeLoc(tok::l_paren);
|
consumeToken(tok::l_paren);
|
||||||
auto CCE = new (Context) CodeCompletionExpr(Tok.getRange());
|
auto CCE = new (Context) CodeCompletionExpr(Tok.getRange());
|
||||||
auto Result = makeParserResult(
|
auto Result = makeParserResult(
|
||||||
CallExpr::create(Context, fn.get(), SourceLoc(),
|
CallExpr::create(Context, fn.get(), SourceLoc(),
|
||||||
@@ -2745,7 +2745,7 @@ Parser::parseExprCallSuffix(ParserResult<Expr> fn, bool isExprBasic) {
|
|||||||
/*implicit=*/false));
|
/*implicit=*/false));
|
||||||
CodeCompletion->completePostfixExprParen(fn.get(), CCE);
|
CodeCompletion->completePostfixExprParen(fn.get(), CCE);
|
||||||
// Eat the code completion token because we handled it.
|
// Eat the code completion token because we handled it.
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
Result.setHasCodeCompletion();
|
Result.setHasCodeCompletion();
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
@@ -2790,7 +2790,7 @@ Parser::parseExprCallSuffix(ParserResult<Expr> fn, bool isExprBasic) {
|
|||||||
ParserResult<Expr> Parser::parseExprCollection(SourceLoc LSquareLoc) {
|
ParserResult<Expr> Parser::parseExprCollection(SourceLoc LSquareLoc) {
|
||||||
// If the caller didn't already consume the '[', do so now.
|
// If the caller didn't already consume the '[', do so now.
|
||||||
if (LSquareLoc.isInvalid())
|
if (LSquareLoc.isInvalid())
|
||||||
LSquareLoc = consumeLoc(tok::l_square);
|
LSquareLoc = consumeToken(tok::l_square);
|
||||||
|
|
||||||
Parser::StructureMarkerRAII ParsingCollection(
|
Parser::StructureMarkerRAII ParsingCollection(
|
||||||
*this, LSquareLoc,
|
*this, LSquareLoc,
|
||||||
@@ -2798,15 +2798,15 @@ ParserResult<Expr> Parser::parseExprCollection(SourceLoc LSquareLoc) {
|
|||||||
|
|
||||||
// [] is always an array.
|
// [] is always an array.
|
||||||
if (Tok.is(tok::r_square)) {
|
if (Tok.is(tok::r_square)) {
|
||||||
SourceLoc RSquareLoc = consumeLoc(tok::r_square);
|
SourceLoc RSquareLoc = consumeToken(tok::r_square);
|
||||||
return makeParserResult(
|
return makeParserResult(
|
||||||
ArrayExpr::create(Context, LSquareLoc, {}, {}, RSquareLoc));
|
ArrayExpr::create(Context, LSquareLoc, {}, {}, RSquareLoc));
|
||||||
}
|
}
|
||||||
|
|
||||||
// [:] is always an empty dictionary.
|
// [:] is always an empty dictionary.
|
||||||
if (Tok.is(tok::colon) && peekToken().is(tok::r_square)) {
|
if (Tok.is(tok::colon) && peekToken().is(tok::r_square)) {
|
||||||
consumeLoc(tok::colon);
|
consumeToken(tok::colon);
|
||||||
SourceLoc RSquareLoc = consumeLoc(tok::r_square);
|
SourceLoc RSquareLoc = consumeToken(tok::r_square);
|
||||||
return makeParserResult(
|
return makeParserResult(
|
||||||
DictionaryExpr::create(Context, LSquareLoc, {}, RSquareLoc));
|
DictionaryExpr::create(Context, LSquareLoc, {}, RSquareLoc));
|
||||||
}
|
}
|
||||||
@@ -2817,7 +2817,7 @@ ParserResult<Expr> Parser::parseExprCollection(SourceLoc LSquareLoc) {
|
|||||||
if (FirstExpr.isNull() || FirstExpr.hasCodeCompletion()) {
|
if (FirstExpr.isNull() || FirstExpr.hasCodeCompletion()) {
|
||||||
skipUntil(tok::r_square);
|
skipUntil(tok::r_square);
|
||||||
if (Tok.is(tok::r_square))
|
if (Tok.is(tok::r_square))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (FirstExpr.hasCodeCompletion())
|
if (FirstExpr.hasCodeCompletion())
|
||||||
return makeParserCodeCompletionResult<Expr>();
|
return makeParserCodeCompletionResult<Expr>();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -2928,7 +2928,7 @@ ParserResult<Expr> Parser::parseExprDictionary(SourceLoc LSquareLoc,
|
|||||||
diagnose(Tok, diag::expected_colon_in_dictionary_literal);
|
diagnose(Tok, diag::expected_colon_in_dictionary_literal);
|
||||||
return makeParserError();
|
return makeParserError();
|
||||||
}
|
}
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
// Parse the next value.
|
// Parse the next value.
|
||||||
ParserResult<Expr> Value =
|
ParserResult<Expr> Value =
|
||||||
@@ -2980,7 +2980,7 @@ void Parser::addParametersToScope(ParameterList *PL) {
|
|||||||
ParserResult<AvailabilitySpec> Parser::parseAvailabilitySpec() {
|
ParserResult<AvailabilitySpec> Parser::parseAvailabilitySpec() {
|
||||||
if (Tok.isBinaryOperator() && Tok.getText() == "*") {
|
if (Tok.isBinaryOperator() && Tok.getText() == "*") {
|
||||||
SourceLoc StarLoc = Tok.getLoc();
|
SourceLoc StarLoc = Tok.getLoc();
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
return makeParserResult(new (Context) OtherPlatformAvailabilitySpec(StarLoc));
|
return makeParserResult(new (Context) OtherPlatformAvailabilitySpec(StarLoc));
|
||||||
}
|
}
|
||||||
@@ -3004,7 +3004,7 @@ Parser::parseLanguageVersionConstraintSpec() {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
SwiftLoc = Tok.getLoc();
|
SwiftLoc = Tok.getLoc();
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (parseVersionTuple(Version, VersionRange,
|
if (parseVersionTuple(Version, VersionRange,
|
||||||
diag::avail_query_expected_version_number)) {
|
diag::avail_query_expected_version_number)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -3023,7 +3023,7 @@ Parser::parsePlatformVersionConstraintSpec() {
|
|||||||
Identifier PlatformIdentifier;
|
Identifier PlatformIdentifier;
|
||||||
SourceLoc PlatformLoc;
|
SourceLoc PlatformLoc;
|
||||||
if (Tok.is(tok::code_complete)) {
|
if (Tok.is(tok::code_complete)) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (CodeCompletion) {
|
if (CodeCompletion) {
|
||||||
CodeCompletion->completePoundAvailablePlatform();
|
CodeCompletion->completePoundAvailablePlatform();
|
||||||
}
|
}
|
||||||
@@ -3038,7 +3038,7 @@ Parser::parsePlatformVersionConstraintSpec() {
|
|||||||
if (Tok.isBinaryOperator() && Tok.getText() == ">=") {
|
if (Tok.isBinaryOperator() && Tok.getText() == ">=") {
|
||||||
diagnose(Tok, diag::avail_query_version_comparison_not_needed)
|
diagnose(Tok, diag::avail_query_version_comparison_not_needed)
|
||||||
.fixItRemove(Tok.getLoc());
|
.fixItRemove(Tok.getLoc());
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
clang::VersionTuple Version;
|
clang::VersionTuple Version;
|
||||||
@@ -3069,16 +3069,16 @@ Parser::parsePlatformVersionConstraintSpec() {
|
|||||||
///
|
///
|
||||||
ParserResult<Expr> Parser::parseExprTypeOf() {
|
ParserResult<Expr> Parser::parseExprTypeOf() {
|
||||||
// Consume 'type'
|
// Consume 'type'
|
||||||
SourceLoc keywordLoc = consumeLoc();
|
SourceLoc keywordLoc = consumeToken();
|
||||||
|
|
||||||
// Parse the leading '('.
|
// Parse the leading '('.
|
||||||
SourceLoc lParenLoc = consumeLoc(tok::l_paren);
|
SourceLoc lParenLoc = consumeToken(tok::l_paren);
|
||||||
|
|
||||||
// Parse `of` label.
|
// Parse `of` label.
|
||||||
if (Tok.getText() == "of" && peekToken().is(tok::colon)) {
|
if (Tok.getText() == "of" && peekToken().is(tok::colon)) {
|
||||||
// Consume the label.
|
// Consume the label.
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
consumeLoc(tok::colon);
|
consumeToken(tok::colon);
|
||||||
} else {
|
} else {
|
||||||
// There cannot be a richer diagnostic here because the user may have
|
// There cannot be a richer diagnostic here because the user may have
|
||||||
// defined a function `type(...)` that conflicts with the magic expr.
|
// defined a function `type(...)` that conflicts with the magic expr.
|
||||||
@@ -3095,7 +3095,7 @@ ParserResult<Expr> Parser::parseExprTypeOf() {
|
|||||||
if (subExpr.isParseError()) {
|
if (subExpr.isParseError()) {
|
||||||
skipUntilDeclStmtRBrace(tok::r_paren);
|
skipUntilDeclStmtRBrace(tok::r_paren);
|
||||||
if (Tok.is(tok::r_paren))
|
if (Tok.is(tok::r_paren))
|
||||||
rParenLoc = consumeLoc();
|
rParenLoc = consumeToken();
|
||||||
else
|
else
|
||||||
rParenLoc = Tok.getLoc();
|
rParenLoc = Tok.getLoc();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ Parser::parseGenericParameters(SourceLoc LAngleLoc) {
|
|||||||
// Parse the ':' followed by a type.
|
// Parse the ':' followed by a type.
|
||||||
SmallVector<TypeLoc, 1> Inherited;
|
SmallVector<TypeLoc, 1> Inherited;
|
||||||
if (Tok.is(tok::colon)) {
|
if (Tok.is(tok::colon)) {
|
||||||
(void)consumeLoc();
|
(void)consumeToken();
|
||||||
ParserResult<TypeRepr> Ty;
|
ParserResult<TypeRepr> Ty;
|
||||||
|
|
||||||
if (Tok.isAny(tok::identifier, tok::code_complete, tok::kw_protocol, tok::kw_Any)) {
|
if (Tok.isAny(tok::identifier, tok::code_complete, tok::kw_protocol, tok::kw_Any)) {
|
||||||
@@ -81,7 +81,7 @@ Parser::parseGenericParameters(SourceLoc LAngleLoc) {
|
|||||||
diagnose(Tok, diag::unexpected_class_constraint);
|
diagnose(Tok, diag::unexpected_class_constraint);
|
||||||
diagnose(Tok, diag::suggest_anyobject, Name)
|
diagnose(Tok, diag::suggest_anyobject, Name)
|
||||||
.fixItReplace(Tok.getLoc(), "AnyObject");
|
.fixItReplace(Tok.getLoc(), "AnyObject");
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
Invalid = true;
|
Invalid = true;
|
||||||
} else {
|
} else {
|
||||||
diagnose(Tok, diag::expected_generics_type_restriction, Name);
|
diagnose(Tok, diag::expected_generics_type_restriction, Name);
|
||||||
@@ -248,7 +248,7 @@ ParserStatus Parser::parseGenericWhereClause(
|
|||||||
bool &FirstTypeInComplete) {
|
bool &FirstTypeInComplete) {
|
||||||
ParserStatus Status;
|
ParserStatus Status;
|
||||||
// Parse the 'where'.
|
// Parse the 'where'.
|
||||||
WhereLoc = consumeLoc(tok::kw_where);
|
WhereLoc = consumeToken(tok::kw_where);
|
||||||
FirstTypeInComplete = false;
|
FirstTypeInComplete = false;
|
||||||
do {
|
do {
|
||||||
// Parse the leading type-identifier.
|
// Parse the leading type-identifier.
|
||||||
@@ -264,7 +264,7 @@ ParserStatus Parser::parseGenericWhereClause(
|
|||||||
|
|
||||||
if (Tok.is(tok::colon)) {
|
if (Tok.is(tok::colon)) {
|
||||||
// A conformance-requirement.
|
// A conformance-requirement.
|
||||||
SourceLoc ColonLoc = consumeLoc();
|
SourceLoc ColonLoc = consumeToken();
|
||||||
|
|
||||||
// Parse the protocol or composition.
|
// Parse the protocol or composition.
|
||||||
ParserResult<TypeRepr> Protocol = parseTypeForInheritance(
|
ParserResult<TypeRepr> Protocol = parseTypeForInheritance(
|
||||||
@@ -288,7 +288,7 @@ ParserStatus Parser::parseGenericWhereClause(
|
|||||||
diagnose(Tok, diag::requires_single_equal)
|
diagnose(Tok, diag::requires_single_equal)
|
||||||
.fixItReplace(SourceRange(Tok.getLoc()), "==");
|
.fixItReplace(SourceRange(Tok.getLoc()), "==");
|
||||||
}
|
}
|
||||||
SourceLoc EqualLoc = consumeLoc();
|
SourceLoc EqualLoc = consumeToken();
|
||||||
|
|
||||||
// Parse the second type.
|
// Parse the second type.
|
||||||
ParserResult<TypeRepr> SecondType = parseType();
|
ParserResult<TypeRepr> SecondType = parseType();
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ static ParserStatus parseDefaultArgument(Parser &P,
|
|||||||
unsigned argIndex,
|
unsigned argIndex,
|
||||||
Expr *&init,
|
Expr *&init,
|
||||||
Parser::ParameterContextKind paramContext) {
|
Parser::ParameterContextKind paramContext) {
|
||||||
SourceLoc equalLoc = P.consumeLoc(tok::equal);
|
SourceLoc equalLoc = P.consumeToken(tok::equal);
|
||||||
|
|
||||||
// Enter a fresh default-argument context with a meaningless parent.
|
// Enter a fresh default-argument context with a meaningless parent.
|
||||||
// We'll change the parent to the function later after we've created
|
// We'll change the parent to the function later after we've created
|
||||||
@@ -149,11 +149,11 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
|
|||||||
rightParenLoc.isInvalid() && "Must start with empty state");
|
rightParenLoc.isInvalid() && "Must start with empty state");
|
||||||
|
|
||||||
// Consume the starting '(';
|
// Consume the starting '(';
|
||||||
leftParenLoc = consumeLoc(tok::l_paren);
|
leftParenLoc = consumeToken(tok::l_paren);
|
||||||
|
|
||||||
// Trivial case: empty parameter list.
|
// Trivial case: empty parameter list.
|
||||||
if (Tok.is(tok::r_paren)) {
|
if (Tok.is(tok::r_paren)) {
|
||||||
rightParenLoc = consumeLoc(tok::r_paren);
|
rightParenLoc = consumeToken(tok::r_paren);
|
||||||
return ParserStatus();
|
return ParserStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,25 +193,25 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
|
|||||||
param.SpecifierKind = Tok.is(tok::kw_inout) ? ParsedParameter::InOut :
|
param.SpecifierKind = Tok.is(tok::kw_inout) ? ParsedParameter::InOut :
|
||||||
ParsedParameter::Var;
|
ParsedParameter::Var;
|
||||||
}
|
}
|
||||||
param.LetVarInOutLoc = consumeLoc();
|
param.LetVarInOutLoc = consumeToken();
|
||||||
hasSpecifier = true;
|
hasSpecifier = true;
|
||||||
} else {
|
} else {
|
||||||
// Redundant specifiers are fairly common, recognize, reject, and recover
|
// Redundant specifiers are fairly common, recognize, reject, and recover
|
||||||
// from this gracefully.
|
// from this gracefully.
|
||||||
diagnose(Tok, diag::parameter_inout_var_let_repeated)
|
diagnose(Tok, diag::parameter_inout_var_let_repeated)
|
||||||
.fixItRemove(Tok.getLoc());
|
.fixItRemove(Tok.getLoc());
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startsParameterName(*this, isClosure)) {
|
if (startsParameterName(*this, isClosure)) {
|
||||||
// identifier-or-none for the first name
|
// identifier-or-none for the first name
|
||||||
if (Tok.is(tok::kw__)) {
|
if (Tok.is(tok::kw__)) {
|
||||||
param.FirstNameLoc = consumeLoc();
|
param.FirstNameLoc = consumeToken();
|
||||||
} else {
|
} else {
|
||||||
assert(Tok.canBeArgumentLabel() && "startsParameterName() lied");
|
assert(Tok.canBeArgumentLabel() && "startsParameterName() lied");
|
||||||
param.FirstName = Context.getIdentifier(Tok.getText());
|
param.FirstName = Context.getIdentifier(Tok.getText());
|
||||||
param.FirstNameLoc = consumeLoc();
|
param.FirstNameLoc = consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
// identifier-or-none? for the second name
|
// identifier-or-none? for the second name
|
||||||
@@ -219,7 +219,7 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
|
|||||||
if (!Tok.is(tok::kw__))
|
if (!Tok.is(tok::kw__))
|
||||||
param.SecondName = Context.getIdentifier(Tok.getText());
|
param.SecondName = Context.getIdentifier(Tok.getText());
|
||||||
|
|
||||||
param.SecondNameLoc = consumeLoc();
|
param.SecondNameLoc = consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Operators and closures cannot have API names.
|
// Operators and closures cannot have API names.
|
||||||
@@ -250,10 +250,10 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
|
|||||||
if (hasSpecifier) {
|
if (hasSpecifier) {
|
||||||
diagnose(Tok.getLoc(), diag::parameter_inout_var_let_repeated)
|
diagnose(Tok.getLoc(), diag::parameter_inout_var_let_repeated)
|
||||||
.fixItRemove(param.LetVarInOutLoc);
|
.fixItRemove(param.LetVarInOutLoc);
|
||||||
consumeLoc(tok::kw_inout);
|
consumeToken(tok::kw_inout);
|
||||||
} else {
|
} else {
|
||||||
hasSpecifier = true;
|
hasSpecifier = true;
|
||||||
param.LetVarInOutLoc = consumeLoc(tok::kw_inout);
|
param.LetVarInOutLoc = consumeToken(tok::kw_inout);
|
||||||
param.SpecifierKind = ParsedParameter::InOut;
|
param.SpecifierKind = ParsedParameter::InOut;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,7 +330,7 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
|
|||||||
|
|
||||||
// '...'?
|
// '...'?
|
||||||
if (Tok.isEllipsis())
|
if (Tok.isEllipsis())
|
||||||
param.EllipsisLoc = consumeLoc();
|
param.EllipsisLoc = consumeToken();
|
||||||
|
|
||||||
// ('=' expr)?
|
// ('=' expr)?
|
||||||
if (Tok.is(tok::equal)) {
|
if (Tok.is(tok::equal)) {
|
||||||
@@ -649,12 +649,12 @@ Parser::parseFunctionSignature(Identifier SimpleName,
|
|||||||
// Check for the 'throws' keyword.
|
// Check for the 'throws' keyword.
|
||||||
rethrows = false;
|
rethrows = false;
|
||||||
if (Tok.is(tok::kw_throws)) {
|
if (Tok.is(tok::kw_throws)) {
|
||||||
throwsLoc = consumeLoc();
|
throwsLoc = consumeToken();
|
||||||
} else if (Tok.is(tok::kw_rethrows)) {
|
} else if (Tok.is(tok::kw_rethrows)) {
|
||||||
throwsLoc = consumeLoc();
|
throwsLoc = consumeToken();
|
||||||
rethrows = true;
|
rethrows = true;
|
||||||
} else if (Tok.is(tok::kw_throw)) {
|
} else if (Tok.is(tok::kw_throw)) {
|
||||||
throwsLoc = consumeLoc();
|
throwsLoc = consumeToken();
|
||||||
diagnose(throwsLoc, diag::throw_in_function_type)
|
diagnose(throwsLoc, diag::throw_in_function_type)
|
||||||
.fixItReplace(throwsLoc, "throws");
|
.fixItReplace(throwsLoc, "throws");
|
||||||
}
|
}
|
||||||
@@ -666,9 +666,9 @@ Parser::parseFunctionSignature(Identifier SimpleName,
|
|||||||
return None;
|
return None;
|
||||||
|
|
||||||
if (Tok.is(tok::kw_throws)) {
|
if (Tok.is(tok::kw_throws)) {
|
||||||
throwsLoc = consumeLoc();
|
throwsLoc = consumeToken();
|
||||||
} else if (Tok.is(tok::kw_rethrows)) {
|
} else if (Tok.is(tok::kw_rethrows)) {
|
||||||
throwsLoc = consumeLoc();
|
throwsLoc = consumeToken();
|
||||||
rethrows = true;
|
rethrows = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,7 +686,7 @@ Parser::parseFunctionSignature(Identifier SimpleName,
|
|||||||
// FixIt ':' to '->'.
|
// FixIt ':' to '->'.
|
||||||
diagnose(Tok, diag::func_decl_expected_arrow)
|
diagnose(Tok, diag::func_decl_expected_arrow)
|
||||||
.fixItReplace(Tok.getLoc(), " -> ");
|
.fixItReplace(Tok.getLoc(), " -> ");
|
||||||
arrowLoc = consumeLoc(tok::colon);
|
arrowLoc = consumeToken(tok::colon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for 'throws' and 'rethrows' after the arrow, but
|
// Check for 'throws' and 'rethrows' after the arrow, but
|
||||||
@@ -776,7 +776,7 @@ ParserResult<Pattern> Parser::parseTypedPattern() {
|
|||||||
|
|
||||||
// Now parse an optional type annotation.
|
// Now parse an optional type annotation.
|
||||||
if (Tok.is(tok::colon)) {
|
if (Tok.is(tok::colon)) {
|
||||||
SourceLoc colonLoc = consumeLoc(tok::colon);
|
SourceLoc colonLoc = consumeToken(tok::colon);
|
||||||
|
|
||||||
if (result.isNull()) // Recover by creating AnyPattern.
|
if (result.isNull()) // Recover by creating AnyPattern.
|
||||||
result = makeParserErrorResult(new (Context) AnyPattern(colonLoc));
|
result = makeParserErrorResult(new (Context) AnyPattern(colonLoc));
|
||||||
@@ -842,7 +842,7 @@ ParserResult<Pattern> Parser::parsePattern() {
|
|||||||
return parsePatternTuple();
|
return parsePatternTuple();
|
||||||
|
|
||||||
case tok::kw__:
|
case tok::kw__:
|
||||||
return makeParserResult(new (Context) AnyPattern(consumeLoc(tok::kw__)));
|
return makeParserResult(new (Context) AnyPattern(consumeToken(tok::kw__)));
|
||||||
|
|
||||||
case tok::identifier: {
|
case tok::identifier: {
|
||||||
Identifier name;
|
Identifier name;
|
||||||
@@ -855,14 +855,14 @@ ParserResult<Pattern> Parser::parsePattern() {
|
|||||||
if (!CurDeclContext->getAsNominalTypeOrNominalTypeExtensionContext()) {
|
if (!CurDeclContext->getAsNominalTypeOrNominalTypeExtensionContext()) {
|
||||||
// This cannot be an overridden property, so just eat the token. We cannot
|
// This cannot be an overridden property, so just eat the token. We cannot
|
||||||
// code complete anything here -- we expect an identifier.
|
// code complete anything here -- we expect an identifier.
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
case tok::kw_var:
|
case tok::kw_var:
|
||||||
case tok::kw_let: {
|
case tok::kw_let: {
|
||||||
bool isLet = Tok.is(tok::kw_let);
|
bool isLet = Tok.is(tok::kw_let);
|
||||||
SourceLoc varLoc = consumeLoc();
|
SourceLoc varLoc = consumeToken();
|
||||||
|
|
||||||
// 'var' and 'let' patterns shouldn't nest.
|
// 'var' and 'let' patterns shouldn't nest.
|
||||||
if (InVarOrLetPattern == IVOLP_InLet ||
|
if (InVarOrLetPattern == IVOLP_InLet ||
|
||||||
@@ -893,7 +893,7 @@ ParserResult<Pattern> Parser::parsePattern() {
|
|||||||
diagnose(Tok, diag::backticks_to_escape)
|
diagnose(Tok, diag::backticks_to_escape)
|
||||||
.fixItReplace(Tok.getLoc(), "`" + Tok.getText().str() + "`");
|
.fixItReplace(Tok.getLoc(), "`" + Tok.getText().str() + "`");
|
||||||
SourceLoc Loc = Tok.getLoc();
|
SourceLoc Loc = Tok.getLoc();
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return makeParserErrorResult(new (Context) AnyPattern(Loc));
|
return makeParserErrorResult(new (Context) AnyPattern(Loc));
|
||||||
}
|
}
|
||||||
diagnose(Tok, diag::expected_pattern);
|
diagnose(Tok, diag::expected_pattern);
|
||||||
@@ -921,7 +921,7 @@ Parser::parsePatternTupleElement() {
|
|||||||
// If the tuple element has a label, parse it.
|
// If the tuple element has a label, parse it.
|
||||||
if (Tok.is(tok::identifier) && peekToken().is(tok::colon)) {
|
if (Tok.is(tok::identifier) && peekToken().is(tok::colon)) {
|
||||||
LabelLoc = consumeIdentifier(&Label);
|
LabelLoc = consumeIdentifier(&Label);
|
||||||
consumeLoc(tok::colon);
|
consumeToken(tok::colon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the pattern.
|
// Parse the pattern.
|
||||||
@@ -943,7 +943,7 @@ Parser::parsePatternTupleElement() {
|
|||||||
/// pattern-tuple-element (',' pattern-tuple-body)*
|
/// pattern-tuple-element (',' pattern-tuple-body)*
|
||||||
ParserResult<Pattern> Parser::parsePatternTuple() {
|
ParserResult<Pattern> Parser::parsePatternTuple() {
|
||||||
StructureMarkerRAII ParsingPatternTuple(*this, Tok);
|
StructureMarkerRAII ParsingPatternTuple(*this, Tok);
|
||||||
SourceLoc LPLoc = consumeLoc(tok::l_paren);
|
SourceLoc LPLoc = consumeToken(tok::l_paren);
|
||||||
SourceLoc RPLoc;
|
SourceLoc RPLoc;
|
||||||
|
|
||||||
// Parse all the elements.
|
// Parse all the elements.
|
||||||
@@ -1022,14 +1022,14 @@ ParserResult<Pattern> Parser::parseMatchingPattern(bool isExprBasic) {
|
|||||||
if (Tok.isAny(tok::kw_var, tok::kw_let)) {
|
if (Tok.isAny(tok::kw_var, tok::kw_let)) {
|
||||||
assert(Tok.isAny(tok::kw_let, tok::kw_var) && "expects var or let");
|
assert(Tok.isAny(tok::kw_let, tok::kw_var) && "expects var or let");
|
||||||
bool isLet = Tok.is(tok::kw_let);
|
bool isLet = Tok.is(tok::kw_let);
|
||||||
SourceLoc varLoc = consumeLoc();
|
SourceLoc varLoc = consumeToken();
|
||||||
|
|
||||||
return parseMatchingPatternAsLetOrVar(isLet, varLoc, isExprBasic);
|
return parseMatchingPatternAsLetOrVar(isLet, varLoc, isExprBasic);
|
||||||
}
|
}
|
||||||
|
|
||||||
// matching-pattern ::= 'is' type
|
// matching-pattern ::= 'is' type
|
||||||
if (Tok.is(tok::kw_is)) {
|
if (Tok.is(tok::kw_is)) {
|
||||||
SourceLoc isLoc = consumeLoc(tok::kw_is);
|
SourceLoc isLoc = consumeToken(tok::kw_is);
|
||||||
ParserResult<TypeRepr> castType = parseType();
|
ParserResult<TypeRepr> castType = parseType();
|
||||||
if (castType.isNull() || castType.hasCodeCompletion())
|
if (castType.isNull() || castType.hasCodeCompletion())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -1096,11 +1096,11 @@ static bool canParsePattern(Parser &P) {
|
|||||||
switch (P.Tok.getKind()) {
|
switch (P.Tok.getKind()) {
|
||||||
case tok::identifier:
|
case tok::identifier:
|
||||||
case tok::kw__:
|
case tok::kw__:
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
return true;
|
return true;
|
||||||
case tok::kw_let:
|
case tok::kw_let:
|
||||||
case tok::kw_var:
|
case tok::kw_var:
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
return canParsePattern(P);
|
return canParsePattern(P);
|
||||||
case tok::l_paren:
|
case tok::l_paren:
|
||||||
return canParsePatternTuple(P);
|
return canParsePatternTuple(P);
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ namespace {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
P.Tok.getText().getAsInteger(0, Result);
|
P.Tok.getText().getAsInteger(0, Result);
|
||||||
P.consumeLoc(tok::integer_literal);
|
P.consumeToken(tok::integer_literal);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ bool SILParser::parseSILIdentifier(Identifier &Result, SourceLoc &Loc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Loc = P.Tok.getLoc();
|
Loc = P.Tok.getLoc();
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -610,14 +610,14 @@ static bool parseSILLinkage(Optional<SILLinkage> &Result, Parser &P) {
|
|||||||
// Unfortunate collision with access control keywords.
|
// Unfortunate collision with access control keywords.
|
||||||
if (P.Tok.is(tok::kw_public)) {
|
if (P.Tok.is(tok::kw_public)) {
|
||||||
Result = SILLinkage::Public;
|
Result = SILLinkage::Public;
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unfortunate collision with access control keywords.
|
// Unfortunate collision with access control keywords.
|
||||||
if (P.Tok.is(tok::kw_private)) {
|
if (P.Tok.is(tok::kw_private)) {
|
||||||
Result = SILLinkage::Private;
|
Result = SILLinkage::Private;
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -638,7 +638,7 @@ static bool parseSILLinkage(Optional<SILLinkage> &Result, Parser &P) {
|
|||||||
|
|
||||||
// If we succeed, consume the token.
|
// If we succeed, consume the token.
|
||||||
if (Result) {
|
if (Result) {
|
||||||
P.consumeLoc(tok::identifier);
|
P.consumeToken(tok::identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -689,7 +689,7 @@ static bool parseDeclSILOptional(bool *isTransparent, bool *isFragile,
|
|||||||
while (SP.P.consumeIf(tok::l_square)) {
|
while (SP.P.consumeIf(tok::l_square)) {
|
||||||
if (isLet && SP.P.Tok.is(tok::kw_let)) {
|
if (isLet && SP.P.Tok.is(tok::kw_let)) {
|
||||||
*isLet = true;
|
*isLet = true;
|
||||||
SP.P.consumeLoc(tok::kw_let);
|
SP.P.consumeToken(tok::kw_let);
|
||||||
SP.P.parseToken(tok::r_square, diag::expected_in_attribute_list);
|
SP.P.parseToken(tok::r_square, diag::expected_in_attribute_list);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -717,7 +717,7 @@ static bool parseDeclSILOptional(bool *isTransparent, bool *isFragile,
|
|||||||
else if (MRK && SP.P.Tok.getText() == "readwrite")
|
else if (MRK && SP.P.Tok.getText() == "readwrite")
|
||||||
*MRK = EffectsKind::ReadWrite;
|
*MRK = EffectsKind::ReadWrite;
|
||||||
else if (Semantics && SP.P.Tok.getText() == "_semantics") {
|
else if (Semantics && SP.P.Tok.getText() == "_semantics") {
|
||||||
SP.P.consumeLoc(tok::identifier);
|
SP.P.consumeToken(tok::identifier);
|
||||||
if (SP.P.Tok.getKind() != tok::string_literal) {
|
if (SP.P.Tok.getKind() != tok::string_literal) {
|
||||||
SP.P.diagnose(SP.P.Tok, diag::expected_in_attribute_list);
|
SP.P.diagnose(SP.P.Tok, diag::expected_in_attribute_list);
|
||||||
return true;
|
return true;
|
||||||
@@ -726,13 +726,13 @@ static bool parseDeclSILOptional(bool *isTransparent, bool *isFragile,
|
|||||||
// Drop the double quotes.
|
// Drop the double quotes.
|
||||||
StringRef rawString = SP.P.Tok.getText().drop_front().drop_back();
|
StringRef rawString = SP.P.Tok.getText().drop_front().drop_back();
|
||||||
Semantics->push_back(rawString);
|
Semantics->push_back(rawString);
|
||||||
SP.P.consumeLoc(tok::string_literal);
|
SP.P.consumeToken(tok::string_literal);
|
||||||
|
|
||||||
SP.P.parseToken(tok::r_square, diag::expected_in_attribute_list);
|
SP.P.parseToken(tok::r_square, diag::expected_in_attribute_list);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (SpecAttrs && SP.P.Tok.getText() == "_specialize") {
|
else if (SpecAttrs && SP.P.Tok.getText() == "_specialize") {
|
||||||
SP.P.consumeLoc(tok::identifier);
|
SP.P.consumeToken(tok::identifier);
|
||||||
|
|
||||||
/// Parse a specialized attributed, building a parsed substitution list
|
/// Parse a specialized attributed, building a parsed substitution list
|
||||||
/// and pushing a new ParsedSpecAttr on the SpecAttrs list. Conformances
|
/// and pushing a new ParsedSpecAttr on the SpecAttrs list. Conformances
|
||||||
@@ -748,7 +748,7 @@ static bool parseDeclSILOptional(bool *isTransparent, bool *isFragile,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (ClangDecl && SP.P.Tok.getText() == "clang") {
|
else if (ClangDecl && SP.P.Tok.getText() == "clang") {
|
||||||
SP.P.consumeLoc(tok::identifier);
|
SP.P.consumeToken(tok::identifier);
|
||||||
if (SP.parseSILDottedPathWithoutPound(*ClangDecl))
|
if (SP.parseSILDottedPathWithoutPound(*ClangDecl))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -759,7 +759,7 @@ static bool parseDeclSILOptional(bool *isTransparent, bool *isFragile,
|
|||||||
SP.P.diagnose(SP.P.Tok, diag::expected_in_attribute_list);
|
SP.P.diagnose(SP.P.Tok, diag::expected_in_attribute_list);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SP.P.consumeLoc(tok::identifier);
|
SP.P.consumeToken(tok::identifier);
|
||||||
SP.P.parseToken(tok::r_square, diag::expected_in_attribute_list);
|
SP.P.parseToken(tok::r_square, diag::expected_in_attribute_list);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -848,7 +848,7 @@ bool SILParser::parseSILType(SILType &Result,
|
|||||||
SILValueCategory category = SILValueCategory::Object;
|
SILValueCategory category = SILValueCategory::Object;
|
||||||
if (P.Tok.isAnyOperator() && P.Tok.getText() == "*") {
|
if (P.Tok.isAnyOperator() && P.Tok.getText() == "*") {
|
||||||
category = SILValueCategory::Address;
|
category = SILValueCategory::Address;
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse attributes.
|
// Parse attributes.
|
||||||
@@ -1067,7 +1067,7 @@ bool SILParser::parseSILDeclRef(SILDeclRef &Result,
|
|||||||
break;
|
break;
|
||||||
} else if (ParseState < 2 && P.Tok.is(tok::integer_literal)) {
|
} else if (ParseState < 2 && P.Tok.is(tok::integer_literal)) {
|
||||||
P.Tok.getText().getAsInteger(0, uncurryLevel);
|
P.Tok.getText().getAsInteger(0, uncurryLevel);
|
||||||
P.consumeLoc(tok::integer_literal);
|
P.consumeToken(tok::integer_literal);
|
||||||
ParseState = 2;
|
ParseState = 2;
|
||||||
} else
|
} else
|
||||||
// TODO: resilience expansion?
|
// TODO: resilience expansion?
|
||||||
@@ -1090,7 +1090,7 @@ bool SILParser::parseValueName(UnresolvedValueName &Result) {
|
|||||||
Result.Name = P.Tok.getText();
|
Result.Name = P.Tok.getText();
|
||||||
|
|
||||||
if (P.Tok.is(tok::kw_undef)) {
|
if (P.Tok.is(tok::kw_undef)) {
|
||||||
Result.NameLoc = P.consumeLoc(tok::kw_undef);
|
Result.NameLoc = P.consumeToken(tok::kw_undef);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1150,7 +1150,7 @@ bool SILParser::parseSILOpcode(ValueKind &Opcode, SourceLoc &OpcodeLoc,
|
|||||||
.Default(ValueKind::SILArgument);
|
.Default(ValueKind::SILArgument);
|
||||||
|
|
||||||
if (Opcode != ValueKind::SILArgument) {
|
if (Opcode != ValueKind::SILArgument) {
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
P.diagnose(OpcodeLoc, diag::expected_sil_instr_opcode);
|
P.diagnose(OpcodeLoc, diag::expected_sil_instr_opcode);
|
||||||
@@ -1164,10 +1164,10 @@ static bool peekSILDebugLocation(Parser &P) {
|
|||||||
|
|
||||||
bool SILParser::parseSILDebugVar(SILDebugVariable &Var) {
|
bool SILParser::parseSILDebugVar(SILDebugVariable &Var) {
|
||||||
while (P.Tok.is(tok::comma) && !peekSILDebugLocation(P)) {
|
while (P.Tok.is(tok::comma) && !peekSILDebugLocation(P)) {
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
StringRef Key = P.Tok.getText();
|
StringRef Key = P.Tok.getText();
|
||||||
if (Key == "name") {
|
if (Key == "name") {
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
if (P.Tok.getKind() != tok::string_literal) {
|
if (P.Tok.getKind() != tok::string_literal) {
|
||||||
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, "string");
|
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, "string");
|
||||||
return true;
|
return true;
|
||||||
@@ -1176,7 +1176,7 @@ bool SILParser::parseSILDebugVar(SILDebugVariable &Var) {
|
|||||||
StringRef Val = P.Tok.getText().drop_front().drop_back();
|
StringRef Val = P.Tok.getText().drop_front().drop_back();
|
||||||
Var.Name = Val;
|
Var.Name = Val;
|
||||||
} else if (Key == "argno") {
|
} else if (Key == "argno") {
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
if (P.Tok.getKind() != tok::integer_literal) {
|
if (P.Tok.getKind() != tok::integer_literal) {
|
||||||
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, "integer");
|
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, "integer");
|
||||||
return true;
|
return true;
|
||||||
@@ -1193,7 +1193,7 @@ bool SILParser::parseSILDebugVar(SILDebugVariable &Var) {
|
|||||||
P.diagnose(P.Tok, diag::sil_dbg_unknown_key, Key);
|
P.diagnose(P.Tok, diag::sil_dbg_unknown_key, Key);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1201,7 +1201,7 @@ bool SILParser::parseSILDebugVar(SILDebugVariable &Var) {
|
|||||||
bool SILParser::parseSILBBArgsAtBranch(SmallVector<SILValue, 6> &Args,
|
bool SILParser::parseSILBBArgsAtBranch(SmallVector<SILValue, 6> &Args,
|
||||||
SILBuilder &B) {
|
SILBuilder &B) {
|
||||||
if (P.Tok.is(tok::l_paren)) {
|
if (P.Tok.is(tok::l_paren)) {
|
||||||
SourceLoc LParenLoc = P.consumeLoc(tok::l_paren);
|
SourceLoc LParenLoc = P.consumeToken(tok::l_paren);
|
||||||
SourceLoc RParenLoc;
|
SourceLoc RParenLoc;
|
||||||
|
|
||||||
if (P.parseList(tok::r_paren, LParenLoc, RParenLoc,
|
if (P.parseList(tok::r_paren, LParenLoc, RParenLoc,
|
||||||
@@ -1229,7 +1229,7 @@ bool SILParser::parseSubstitutions(SmallVectorImpl<ParsedSubstitution> &parsed,
|
|||||||
if (!P.Tok.isContextualPunctuator("<"))
|
if (!P.Tok.isContextualPunctuator("<"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
|
|
||||||
// Parse a list of Substitutions.
|
// Parse a list of Substitutions.
|
||||||
do {
|
do {
|
||||||
@@ -1250,7 +1250,7 @@ bool SILParser::parseSubstitutions(SmallVectorImpl<ParsedSubstitution> &parsed,
|
|||||||
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, ">");
|
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, ">");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1415,7 +1415,7 @@ bool SILParser::parseSILLocation(SILLocation &Loc) {
|
|||||||
// Drop the double quotes.
|
// Drop the double quotes.
|
||||||
StringRef File = P.Tok.getText().drop_front().drop_back();
|
StringRef File = P.Tok.getText().drop_front().drop_back();
|
||||||
L.Filename = P.Context.getIdentifier(File).str().data();
|
L.Filename = P.Context.getIdentifier(File).str().data();
|
||||||
P.consumeLoc(tok::string_literal);
|
P.consumeToken(tok::string_literal);
|
||||||
if (P.parseToken(tok::colon, diag::expected_colon_in_sil_location))
|
if (P.parseToken(tok::colon, diag::expected_colon_in_sil_location))
|
||||||
return true;
|
return true;
|
||||||
if (parseInteger(L.Line, diag::sil_invalid_line_in_sil_location))
|
if (parseInteger(L.Line, diag::sil_invalid_line_in_sil_location))
|
||||||
@@ -1448,7 +1448,7 @@ bool SILParser::parseSILDebugLocation(SILLocation &L, SILBuilder &B,
|
|||||||
bool parsedComma) {
|
bool parsedComma) {
|
||||||
// Parse the debug information, if any.
|
// Parse the debug information, if any.
|
||||||
if (P.Tok.is(tok::comma)) {
|
if (P.Tok.is(tok::comma)) {
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
parsedComma = true;
|
parsedComma = true;
|
||||||
}
|
}
|
||||||
if (!parsedComma)
|
if (!parsedComma)
|
||||||
@@ -1460,7 +1460,7 @@ bool SILParser::parseSILDebugLocation(SILLocation &L, SILBuilder &B,
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (P.Tok.is(tok::comma)) {
|
if (P.Tok.is(tok::comma)) {
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
requireScope = true;
|
requireScope = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1544,7 +1544,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
if (P.Tok.is(tok::sil_local_name)) {
|
if (P.Tok.is(tok::sil_local_name)) {
|
||||||
ResultName = P.Tok.getText();
|
ResultName = P.Tok.getText();
|
||||||
ResultNameLoc = P.Tok.getLoc();
|
ResultNameLoc = P.Tok.getLoc();
|
||||||
P.consumeLoc(tok::sil_local_name);
|
P.consumeToken(tok::sil_local_name);
|
||||||
if (P.parseToken(tok::equal, diag::expected_equal_in_sil_instr))
|
if (P.parseToken(tok::equal, diag::expected_equal_in_sil_instr))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1613,7 +1613,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
bool Negative = false;
|
bool Negative = false;
|
||||||
if (P.Tok.isAnyOperator() && P.Tok.getText() == "-") {
|
if (P.Tok.isAnyOperator() && P.Tok.getText() == "-") {
|
||||||
Negative = true;
|
Negative = true;
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
}
|
}
|
||||||
if (P.Tok.getKind() != tok::integer_literal) {
|
if (P.Tok.getKind() != tok::integer_literal) {
|
||||||
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, "integer");
|
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, "integer");
|
||||||
@@ -1636,7 +1636,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
if (value.getBitWidth() != intTy->getGreatestWidth())
|
if (value.getBitWidth() != intTy->getGreatestWidth())
|
||||||
value = value.zextOrTrunc(intTy->getGreatestWidth());
|
value = value.zextOrTrunc(intTy->getGreatestWidth());
|
||||||
|
|
||||||
P.consumeLoc(tok::integer_literal);
|
P.consumeToken(tok::integer_literal);
|
||||||
if (parseSILDebugLocation(InstLoc, B))
|
if (parseSILDebugLocation(InstLoc, B))
|
||||||
return true;
|
return true;
|
||||||
ResultVal = B.createIntegerLiteral(InstLoc, Ty, value);
|
ResultVal = B.createIntegerLiteral(InstLoc, Ty, value);
|
||||||
@@ -1672,7 +1672,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
if (parseSILDebugLocation(InstLoc, B))
|
if (parseSILDebugLocation(InstLoc, B))
|
||||||
return true;
|
return true;
|
||||||
ResultVal = B.createFloatLiteral(InstLoc, Ty, value);
|
ResultVal = B.createFloatLiteral(InstLoc, Ty, value);
|
||||||
P.consumeLoc(tok::integer_literal);
|
P.consumeToken(tok::integer_literal);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ValueKind::StringLiteralInst: {
|
case ValueKind::StringLiteralInst: {
|
||||||
@@ -1692,7 +1692,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
P.diagnose(P.Tok, diag::sil_string_invalid_encoding, P.Tok.getText());
|
P.diagnose(P.Tok, diag::sil_string_invalid_encoding, P.Tok.getText());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
P.consumeLoc(tok::identifier);
|
P.consumeToken(tok::identifier);
|
||||||
|
|
||||||
if (P.Tok.getKind() != tok::string_literal) {
|
if (P.Tok.getKind() != tok::string_literal) {
|
||||||
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, "string");
|
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, "string");
|
||||||
@@ -1705,7 +1705,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
// Ask the lexer to interpret the entire string as a literal segment.
|
// Ask the lexer to interpret the entire string as a literal segment.
|
||||||
SmallVector<char, 128> stringBuffer;
|
SmallVector<char, 128> stringBuffer;
|
||||||
StringRef string = P.L->getEncodedStringSegment(rawString, stringBuffer);
|
StringRef string = P.L->getEncodedStringSegment(rawString, stringBuffer);
|
||||||
P.consumeLoc(tok::string_literal);
|
P.consumeToken(tok::string_literal);
|
||||||
if (parseSILDebugLocation(InstLoc, B))
|
if (parseSILDebugLocation(InstLoc, B))
|
||||||
return true;
|
return true;
|
||||||
ResultVal = B.createStringLiteral(InstLoc, string, encoding);
|
ResultVal = B.createStringLiteral(InstLoc, string, encoding);
|
||||||
@@ -1758,7 +1758,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
assert(!error && "project_box index did not parse as integer?!");
|
assert(!error && "project_box index did not parse as integer?!");
|
||||||
(void)error;
|
(void)error;
|
||||||
|
|
||||||
P.consumeLoc(tok::integer_literal);
|
P.consumeToken(tok::integer_literal);
|
||||||
if (parseSILDebugLocation(InstLoc, B))
|
if (parseSILDebugLocation(InstLoc, B))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -1788,7 +1788,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
}
|
}
|
||||||
StringRef Str = P.Tok.getText();
|
StringRef Str = P.Tok.getText();
|
||||||
Identifier Id = P.Context.getIdentifier(Str.substr(1, Str.size()-2));
|
Identifier Id = P.Context.getIdentifier(Str.substr(1, Str.size()-2));
|
||||||
P.consumeLoc(tok::string_literal);
|
P.consumeToken(tok::string_literal);
|
||||||
|
|
||||||
// Find the builtin in the Builtin module
|
// Find the builtin in the Builtin module
|
||||||
SmallVector<ValueDecl*, 2> foundBuiltins;
|
SmallVector<ValueDecl*, 2> foundBuiltins;
|
||||||
@@ -1822,7 +1822,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, "(");
|
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, "(");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
P.consumeLoc(tok::l_paren);
|
P.consumeToken(tok::l_paren);
|
||||||
|
|
||||||
SmallVector<SILValue, 4> Args;
|
SmallVector<SILValue, 4> Args;
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -1845,7 +1845,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, ":");
|
P.diagnose(P.Tok, diag::expected_tok_in_sil_instr, ":");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
P.consumeLoc(tok::colon);
|
P.consumeToken(tok::colon);
|
||||||
|
|
||||||
SILType ResultTy;
|
SILType ResultTy;
|
||||||
if (parseSILType(ResultTy))
|
if (parseSILType(ResultTy))
|
||||||
@@ -2572,7 +2572,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
!P.Tok.isAnyOperator() ||
|
!P.Tok.isAnyOperator() ||
|
||||||
P.Tok.getText() != "*")
|
P.Tok.getText() != "*")
|
||||||
return true;
|
return true;
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
|
|
||||||
SILValue ElemCount;
|
SILValue ElemCount;
|
||||||
if (parseTypedValueRef(ElemCount, B))
|
if (parseTypedValueRef(ElemCount, B))
|
||||||
@@ -2770,7 +2770,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (P.Tok.is(tok::comma) && !peekSILDebugLocation(P)) {
|
if (P.Tok.is(tok::comma) && !peekSILDebugLocation(P)) {
|
||||||
P.consumeLoc(tok::comma);
|
P.consumeToken(tok::comma);
|
||||||
if (parseTypedValueRef(Operand, B))
|
if (parseTypedValueRef(Operand, B))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2839,7 +2839,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
P.diagnose(P.Tok, diag::sil_tuple_inst_wrong_field);
|
P.diagnose(P.Tok, diag::sil_tuple_inst_wrong_field);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
P.consumeLoc(tok::integer_literal);
|
P.consumeToken(tok::integer_literal);
|
||||||
if (parseSILDebugLocation(InstLoc, B))
|
if (parseSILDebugLocation(InstLoc, B))
|
||||||
return true;
|
return true;
|
||||||
auto ResultTy = TT->getElement(Field).getType()->getCanonicalType();
|
auto ResultTy = TT->getElement(Field).getType()->getCanonicalType();
|
||||||
@@ -3019,7 +3019,7 @@ bool SILParser::parseSILInstruction(SILBasicBlock *BB, SILBuilder &B) {
|
|||||||
// Optional operand.
|
// Optional operand.
|
||||||
SILValue Operand;
|
SILValue Operand;
|
||||||
if (P.Tok.is(tok::comma)) {
|
if (P.Tok.is(tok::comma)) {
|
||||||
P.consumeLoc(tok::comma);
|
P.consumeToken(tok::comma);
|
||||||
if (parseTypedValueRef(Operand, B))
|
if (parseTypedValueRef(Operand, B))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -4007,7 +4007,7 @@ bool Parser::parseDeclSIL() {
|
|||||||
// properly handled.
|
// properly handled.
|
||||||
Lexer::SILBodyRAII Tmp(*L);
|
Lexer::SILBodyRAII Tmp(*L);
|
||||||
|
|
||||||
consumeLoc(tok::kw_sil);
|
consumeToken(tok::kw_sil);
|
||||||
|
|
||||||
SILParser FunctionState(*this);
|
SILParser FunctionState(*this);
|
||||||
|
|
||||||
@@ -4140,7 +4140,7 @@ bool Parser::parseDeclSIL() {
|
|||||||
/// decl-sil-stage: [[only in SIL mode]]
|
/// decl-sil-stage: [[only in SIL mode]]
|
||||||
/// 'sil_stage' ('raw' | 'canonical')
|
/// 'sil_stage' ('raw' | 'canonical')
|
||||||
bool Parser::parseDeclSILStage() {
|
bool Parser::parseDeclSILStage() {
|
||||||
SourceLoc stageLoc = consumeLoc(tok::kw_sil_stage);
|
SourceLoc stageLoc = consumeToken(tok::kw_sil_stage);
|
||||||
if (!Tok.is(tok::identifier)) {
|
if (!Tok.is(tok::identifier)) {
|
||||||
diagnose(Tok, diag::expected_sil_stage_name);
|
diagnose(Tok, diag::expected_sil_stage_name);
|
||||||
return true;
|
return true;
|
||||||
@@ -4148,13 +4148,13 @@ bool Parser::parseDeclSILStage() {
|
|||||||
SILStage stage;
|
SILStage stage;
|
||||||
if (Tok.isContextualKeyword("raw")) {
|
if (Tok.isContextualKeyword("raw")) {
|
||||||
stage = SILStage::Raw;
|
stage = SILStage::Raw;
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
} else if (Tok.isContextualKeyword("canonical")) {
|
} else if (Tok.isContextualKeyword("canonical")) {
|
||||||
stage = SILStage::Canonical;
|
stage = SILStage::Canonical;
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
} else {
|
} else {
|
||||||
diagnose(Tok, diag::expected_sil_stage_name);
|
diagnose(Tok, diag::expected_sil_stage_name);
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4171,7 +4171,7 @@ bool Parser::parseDeclSILStage() {
|
|||||||
/// decl-sil-global: [[only in SIL mode]]
|
/// decl-sil-global: [[only in SIL mode]]
|
||||||
/// 'sil_global' sil-linkage @name : sil-type [external]
|
/// 'sil_global' sil-linkage @name : sil-type [external]
|
||||||
bool Parser::parseSILGlobal() {
|
bool Parser::parseSILGlobal() {
|
||||||
consumeLoc(tok::kw_sil_global);
|
consumeToken(tok::kw_sil_global);
|
||||||
Optional<SILLinkage> GlobalLinkage;
|
Optional<SILLinkage> GlobalLinkage;
|
||||||
Identifier GlobalName;
|
Identifier GlobalName;
|
||||||
SILType GlobalType;
|
SILType GlobalType;
|
||||||
@@ -4234,7 +4234,7 @@ bool Parser::parseSILGlobal() {
|
|||||||
/// sil-vtable-entry:
|
/// sil-vtable-entry:
|
||||||
/// SILDeclRef ':' SILFunctionName
|
/// SILDeclRef ':' SILFunctionName
|
||||||
bool Parser::parseSILVTable() {
|
bool Parser::parseSILVTable() {
|
||||||
consumeLoc(tok::kw_sil_vtable);
|
consumeToken(tok::kw_sil_vtable);
|
||||||
SILParser VTableState(*this);
|
SILParser VTableState(*this);
|
||||||
|
|
||||||
// Parse the class name.
|
// Parse the class name.
|
||||||
@@ -4260,7 +4260,7 @@ bool Parser::parseSILVTable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SourceLoc LBraceLoc = Tok.getLoc();
|
SourceLoc LBraceLoc = Tok.getLoc();
|
||||||
consumeLoc(tok::l_brace);
|
consumeToken(tok::l_brace);
|
||||||
|
|
||||||
// We need to turn on InSILBody to parse SILDeclRef.
|
// We need to turn on InSILBody to parse SILDeclRef.
|
||||||
Lexer::SILBodyRAII Tmp(*L);
|
Lexer::SILBodyRAII Tmp(*L);
|
||||||
@@ -4276,7 +4276,7 @@ bool Parser::parseSILVTable() {
|
|||||||
return true;
|
return true;
|
||||||
SILFunction *Func = nullptr;
|
SILFunction *Func = nullptr;
|
||||||
if (Tok.is(tok::kw_nil)) {
|
if (Tok.is(tok::kw_nil)) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
} else {
|
} else {
|
||||||
if (parseToken(tok::colon, diag::expected_sil_vtable_colon) ||
|
if (parseToken(tok::colon, diag::expected_sil_vtable_colon) ||
|
||||||
VTableState.parseSILIdentifier(FuncName, FuncLoc,
|
VTableState.parseSILIdentifier(FuncName, FuncLoc,
|
||||||
@@ -4435,7 +4435,7 @@ ProtocolConformance *SILParser::parseProtocolConformanceHelper(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (P.Tok.is(tok::identifier) && P.Tok.getText() == "specialize") {
|
if (P.Tok.is(tok::identifier) && P.Tok.getText() == "specialize") {
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
|
|
||||||
// Parse substitutions for specialized conformance.
|
// Parse substitutions for specialized conformance.
|
||||||
SmallVector<ParsedSubstitution, 4> parsedSubs;
|
SmallVector<ParsedSubstitution, 4> parsedSubs;
|
||||||
@@ -4464,7 +4464,7 @@ ProtocolConformance *SILParser::parseProtocolConformanceHelper(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (P.Tok.is(tok::identifier) && P.Tok.getText() == "inherit") {
|
if (P.Tok.is(tok::identifier) && P.Tok.getText() == "inherit") {
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
|
|
||||||
if (P.parseToken(tok::l_paren, diag::expected_sil_witness_lparen))
|
if (P.parseToken(tok::l_paren, diag::expected_sil_witness_lparen))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -4494,7 +4494,7 @@ ProtocolConformance *SILParser::parseProtocolConformanceHelper(
|
|||||||
/// protocol-conformance|dependent
|
/// protocol-conformance|dependent
|
||||||
/// base_protocol ProtocolName: protocol-conformance
|
/// base_protocol ProtocolName: protocol-conformance
|
||||||
bool Parser::parseSILWitnessTable() {
|
bool Parser::parseSILWitnessTable() {
|
||||||
consumeLoc(tok::kw_sil_witness_table);
|
consumeToken(tok::kw_sil_witness_table);
|
||||||
SILParser WitnessState(*this);
|
SILParser WitnessState(*this);
|
||||||
|
|
||||||
// Parse the linkage.
|
// Parse the linkage.
|
||||||
@@ -4549,7 +4549,7 @@ bool Parser::parseSILWitnessTable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SourceLoc LBraceLoc = Tok.getLoc();
|
SourceLoc LBraceLoc = Tok.getLoc();
|
||||||
consumeLoc(tok::l_brace);
|
consumeToken(tok::l_brace);
|
||||||
|
|
||||||
// We need to turn on InSILBody to parse SILDeclRef.
|
// We need to turn on InSILBody to parse SILDeclRef.
|
||||||
Lexer::SILBodyRAII Tmp(*L);
|
Lexer::SILBodyRAII Tmp(*L);
|
||||||
@@ -4603,7 +4603,7 @@ bool Parser::parseSILWitnessTable() {
|
|||||||
continue;
|
continue;
|
||||||
conformance = ProtocolConformanceRef(concrete);
|
conformance = ProtocolConformanceRef(concrete);
|
||||||
} else {
|
} else {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
witnessEntries.push_back(SILWitnessTable::AssociatedTypeProtocolWitness{
|
witnessEntries.push_back(SILWitnessTable::AssociatedTypeProtocolWitness{
|
||||||
@@ -4652,7 +4652,7 @@ bool Parser::parseSILWitnessTable() {
|
|||||||
|
|
||||||
SILFunction *Func = nullptr;
|
SILFunction *Func = nullptr;
|
||||||
if (Tok.is(tok::kw_nil)) {
|
if (Tok.is(tok::kw_nil)) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
} else {
|
} else {
|
||||||
if (parseToken(tok::at_sign, diag::expected_sil_function_name) ||
|
if (parseToken(tok::at_sign, diag::expected_sil_function_name) ||
|
||||||
WitnessState.parseSILIdentifier(FuncName, FuncLoc,
|
WitnessState.parseSILIdentifier(FuncName, FuncLoc,
|
||||||
@@ -4695,7 +4695,7 @@ bool Parser::parseSILWitnessTable() {
|
|||||||
/// 'method' SILDeclRef ':' @SILFunctionName
|
/// 'method' SILDeclRef ':' @SILFunctionName
|
||||||
/// 'no_default'
|
/// 'no_default'
|
||||||
bool Parser::parseSILDefaultWitnessTable() {
|
bool Parser::parseSILDefaultWitnessTable() {
|
||||||
consumeLoc(tok::kw_sil_default_witness_table);
|
consumeToken(tok::kw_sil_default_witness_table);
|
||||||
SILParser WitnessState(*this);
|
SILParser WitnessState(*this);
|
||||||
|
|
||||||
// Parse the linkage.
|
// Parse the linkage.
|
||||||
@@ -4713,7 +4713,7 @@ bool Parser::parseSILDefaultWitnessTable() {
|
|||||||
|
|
||||||
// Parse the body.
|
// Parse the body.
|
||||||
SourceLoc LBraceLoc = Tok.getLoc();
|
SourceLoc LBraceLoc = Tok.getLoc();
|
||||||
consumeLoc(tok::l_brace);
|
consumeToken(tok::l_brace);
|
||||||
|
|
||||||
// We need to turn on InSILBody to parse SILDeclRef.
|
// We need to turn on InSILBody to parse SILDeclRef.
|
||||||
Lexer::SILBodyRAII Tmp(*L);
|
Lexer::SILBodyRAII Tmp(*L);
|
||||||
@@ -4794,7 +4794,7 @@ llvm::Optional<llvm::coverage::Counter> SILParser::parseSILCoverageExpr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (P.Tok.is(tok::l_paren)) {
|
if (P.Tok.is(tok::l_paren)) {
|
||||||
P.consumeLoc(tok::l_paren);
|
P.consumeToken(tok::l_paren);
|
||||||
auto LHS = parseSILCoverageExpr(Builder);
|
auto LHS = parseSILCoverageExpr(Builder);
|
||||||
if (!LHS)
|
if (!LHS)
|
||||||
return None;
|
return None;
|
||||||
@@ -4833,7 +4833,7 @@ llvm::Optional<llvm::coverage::Counter> SILParser::parseSILCoverageExpr(
|
|||||||
/// sil-coverage-expr:
|
/// sil-coverage-expr:
|
||||||
/// ...
|
/// ...
|
||||||
bool Parser::parseSILCoverageMap() {
|
bool Parser::parseSILCoverageMap() {
|
||||||
consumeLoc(tok::kw_sil_coverage_map);
|
consumeToken(tok::kw_sil_coverage_map);
|
||||||
SILParser State(*this);
|
SILParser State(*this);
|
||||||
|
|
||||||
// Parse the filename.
|
// Parse the filename.
|
||||||
@@ -4865,7 +4865,7 @@ bool Parser::parseSILCoverageMap() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SourceLoc LBraceLoc = Tok.getLoc();
|
SourceLoc LBraceLoc = Tok.getLoc();
|
||||||
consumeLoc(tok::l_brace);
|
consumeToken(tok::l_brace);
|
||||||
|
|
||||||
llvm::coverage::CounterExpressionBuilder Builder;
|
llvm::coverage::CounterExpressionBuilder Builder;
|
||||||
std::vector<SILCoverageMap::MappedRegion> Regions;
|
std::vector<SILCoverageMap::MappedRegion> Regions;
|
||||||
@@ -4922,7 +4922,7 @@ bool Parser::parseSILCoverageMap() {
|
|||||||
/// scope-parent ::= sil-scope-ref
|
/// scope-parent ::= sil-scope-ref
|
||||||
/// debug-loc ::= 'loc' string-literal ':' [0-9]+ ':' [0-9]+
|
/// debug-loc ::= 'loc' string-literal ':' [0-9]+ ':' [0-9]+
|
||||||
bool Parser::parseSILScope() {
|
bool Parser::parseSILScope() {
|
||||||
consumeLoc(tok::kw_sil_scope);
|
consumeToken(tok::kw_sil_scope);
|
||||||
SILParser ScopeState(*this);
|
SILParser ScopeState(*this);
|
||||||
|
|
||||||
SourceLoc SlotLoc = Tok.getLoc();
|
SourceLoc SlotLoc = Tok.getLoc();
|
||||||
@@ -4931,7 +4931,7 @@ bool Parser::parseSILScope() {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
SourceLoc LBraceLoc = Tok.getLoc();
|
SourceLoc LBraceLoc = Tok.getLoc();
|
||||||
consumeLoc(tok::l_brace);
|
consumeToken(tok::l_brace);
|
||||||
|
|
||||||
StringRef Key = Tok.getText();
|
StringRef Key = Tok.getText();
|
||||||
RegularLocation Loc{SILLocation::DebugLoc()};
|
RegularLocation Loc{SILLocation::DebugLoc()};
|
||||||
@@ -4972,7 +4972,7 @@ bool Parser::parseSILScope() {
|
|||||||
|
|
||||||
SILDebugScope *InlinedAt = nullptr;
|
SILDebugScope *InlinedAt = nullptr;
|
||||||
if (Tok.getText() == "inlined_at") {
|
if (Tok.getText() == "inlined_at") {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (ScopeState.parseScopeRef(InlinedAt))
|
if (ScopeState.parseScopeRef(InlinedAt))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ bool Parser::isStartOfStmt() {
|
|||||||
// "try" cannot actually start any statements, but we parse it there for
|
// "try" cannot actually start any statements, but we parse it there for
|
||||||
// better recovery.
|
// better recovery.
|
||||||
Parser::BacktrackingScope backtrack(*this);
|
Parser::BacktrackingScope backtrack(*this);
|
||||||
consumeLoc(tok::kw_try);
|
consumeToken(tok::kw_try);
|
||||||
return isStartOfStmt();
|
return isStartOfStmt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,8 +70,8 @@ bool Parser::isStartOfStmt() {
|
|||||||
// question colon expression or something else, we look ahead to the second
|
// question colon expression or something else, we look ahead to the second
|
||||||
// token.
|
// token.
|
||||||
Parser::BacktrackingScope backtrack(*this);
|
Parser::BacktrackingScope backtrack(*this);
|
||||||
consumeLoc(tok::identifier);
|
consumeToken(tok::identifier);
|
||||||
consumeLoc(tok::colon);
|
consumeToken(tok::colon);
|
||||||
// For better recovery, we just accept a label on any statement. We reject
|
// For better recovery, we just accept a label on any statement. We reject
|
||||||
// putting a label on something inappropriate in parseStmt().
|
// putting a label on something inappropriate in parseStmt().
|
||||||
return isStartOfStmt();
|
return isStartOfStmt();
|
||||||
@@ -83,7 +83,7 @@ ParserStatus Parser::parseExprOrStmt(ASTNode &Result) {
|
|||||||
if (Tok.is(tok::semi)) {
|
if (Tok.is(tok::semi)) {
|
||||||
diagnose(Tok, diag::illegal_semi_stmt)
|
diagnose(Tok, diag::illegal_semi_stmt)
|
||||||
.fixItRemove(SourceRange(Tok.getLoc()));
|
.fixItRemove(SourceRange(Tok.getLoc()));
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return makeParserError();
|
return makeParserError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ ParserStatus Parser::parseExprOrStmt(ASTNode &Result) {
|
|||||||
if (Tok.is(tok::code_complete)) {
|
if (Tok.is(tok::code_complete)) {
|
||||||
if (CodeCompletion)
|
if (CodeCompletion)
|
||||||
CodeCompletion->completeStmtOrExpr();
|
CodeCompletion->completeStmtOrExpr();
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
return makeParserCodeCompletionStatus();
|
return makeParserCodeCompletionStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ void Parser::consumeTopLevelDecl(ParserPosition BeginParserPosition,
|
|||||||
SourceLoc BeginLoc = Tok.getLoc();
|
SourceLoc BeginLoc = Tok.getLoc();
|
||||||
// Consume tokens up to code completion token.
|
// Consume tokens up to code completion token.
|
||||||
while (Tok.isNot(tok::code_complete, tok::eof)) {
|
while (Tok.isNot(tok::code_complete, tok::eof)) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
// Consume the code completion token, if there is one.
|
// Consume the code completion token, if there is one.
|
||||||
consumeIf(tok::code_complete);
|
consumeIf(tok::code_complete);
|
||||||
@@ -414,9 +414,9 @@ ParserStatus Parser::parseBraceItems(SmallVectorImpl<ASTNode> &Entries,
|
|||||||
if (!NeedParseErrorRecovery && !PreviousHadSemi && Tok.is(tok::semi)) {
|
if (!NeedParseErrorRecovery && !PreviousHadSemi && Tok.is(tok::semi)) {
|
||||||
if (Result) {
|
if (Result) {
|
||||||
if (Result.is<Expr*>()) {
|
if (Result.is<Expr*>()) {
|
||||||
Result.get<Expr*>()->TrailingSemiLoc = consumeLoc(tok::semi);
|
Result.get<Expr*>()->TrailingSemiLoc = consumeToken(tok::semi);
|
||||||
} else {
|
} else {
|
||||||
Result.get<Stmt*>()->TrailingSemiLoc = consumeLoc(tok::semi);
|
Result.get<Stmt*>()->TrailingSemiLoc = consumeToken(tok::semi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PreviousHadSemi = true;
|
PreviousHadSemi = true;
|
||||||
@@ -449,7 +449,7 @@ void Parser::parseTopLevelCodeDeclDelayed() {
|
|||||||
|
|
||||||
// ParserPositionRAII needs a primed parser to restore to.
|
// ParserPositionRAII needs a primed parser to restore to.
|
||||||
if (Tok.is(tok::NUM_TOKENS))
|
if (Tok.is(tok::NUM_TOKENS))
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
// Ensure that we restore the parser state at exit.
|
// Ensure that we restore the parser state at exit.
|
||||||
ParserPositionRAII PPR(*this);
|
ParserPositionRAII PPR(*this);
|
||||||
@@ -512,7 +512,7 @@ ParserResult<Stmt> Parser::parseStmt() {
|
|||||||
// parsing logic below.
|
// parsing logic below.
|
||||||
if (Tok.is(tok::identifier) && peekToken().is(tok::colon)) {
|
if (Tok.is(tok::identifier) && peekToken().is(tok::colon)) {
|
||||||
LabelInfo.Loc = consumeIdentifier(&LabelInfo.Name);
|
LabelInfo.Loc = consumeIdentifier(&LabelInfo.Name);
|
||||||
consumeLoc(tok::colon);
|
consumeToken(tok::colon);
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceLoc tryLoc;
|
SourceLoc tryLoc;
|
||||||
@@ -582,7 +582,7 @@ ParserResult<Stmt> Parser::parseStmt() {
|
|||||||
if (LabelInfo) diagnose(LabelInfo.Loc, diag::invalid_label_on_stmt);
|
if (LabelInfo) diagnose(LabelInfo.Loc, diag::invalid_label_on_stmt);
|
||||||
if (tryLoc.isValid()) diagnose(tryLoc, diag::try_on_stmt, Tok.getText());
|
if (tryLoc.isValid()) diagnose(tryLoc, diag::try_on_stmt, Tok.getText());
|
||||||
return makeParserResult(
|
return makeParserResult(
|
||||||
new (Context) FallthroughStmt(consumeLoc(tok::kw_fallthrough)));
|
new (Context) FallthroughStmt(consumeToken(tok::kw_fallthrough)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,7 +598,7 @@ ParserResult<BraceStmt> Parser::parseBraceItemList(Diag<> ID) {
|
|||||||
diagnose(Tok, ID);
|
diagnose(Tok, ID);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
SourceLoc LBLoc = consumeLoc(tok::l_brace);
|
SourceLoc LBLoc = consumeToken(tok::l_brace);
|
||||||
|
|
||||||
SmallVector<ASTNode, 16> Entries;
|
SmallVector<ASTNode, 16> Entries;
|
||||||
SourceLoc RBLoc;
|
SourceLoc RBLoc;
|
||||||
@@ -628,7 +628,7 @@ void Parser::parseIfConfigClauseElements(bool isActive,
|
|||||||
/// 'break' identifier?
|
/// 'break' identifier?
|
||||||
///
|
///
|
||||||
ParserResult<Stmt> Parser::parseStmtBreak() {
|
ParserResult<Stmt> Parser::parseStmtBreak() {
|
||||||
SourceLoc Loc = consumeLoc(tok::kw_break);
|
SourceLoc Loc = consumeToken(tok::kw_break);
|
||||||
SourceLoc TargetLoc;
|
SourceLoc TargetLoc;
|
||||||
Identifier Target;
|
Identifier Target;
|
||||||
|
|
||||||
@@ -650,7 +650,7 @@ ParserResult<Stmt> Parser::parseStmtBreak() {
|
|||||||
/// 'continue' identifier?
|
/// 'continue' identifier?
|
||||||
///
|
///
|
||||||
ParserResult<Stmt> Parser::parseStmtContinue() {
|
ParserResult<Stmt> Parser::parseStmtContinue() {
|
||||||
SourceLoc Loc = consumeLoc(tok::kw_continue);
|
SourceLoc Loc = consumeToken(tok::kw_continue);
|
||||||
SourceLoc TargetLoc;
|
SourceLoc TargetLoc;
|
||||||
Identifier Target;
|
Identifier Target;
|
||||||
|
|
||||||
@@ -673,7 +673,7 @@ ParserResult<Stmt> Parser::parseStmtContinue() {
|
|||||||
/// 'return' expr?
|
/// 'return' expr?
|
||||||
///
|
///
|
||||||
ParserResult<Stmt> Parser::parseStmtReturn(SourceLoc tryLoc) {
|
ParserResult<Stmt> Parser::parseStmtReturn(SourceLoc tryLoc) {
|
||||||
SourceLoc ReturnLoc = consumeLoc(tok::kw_return);
|
SourceLoc ReturnLoc = consumeToken(tok::kw_return);
|
||||||
|
|
||||||
if (Tok.is(tok::code_complete)) {
|
if (Tok.is(tok::code_complete)) {
|
||||||
auto CCE = new (Context) CodeCompletionExpr(SourceRange(Tok.getLoc()));
|
auto CCE = new (Context) CodeCompletionExpr(SourceRange(Tok.getLoc()));
|
||||||
@@ -682,7 +682,7 @@ ParserResult<Stmt> Parser::parseStmtReturn(SourceLoc tryLoc) {
|
|||||||
CodeCompletion->completeReturnStmt(CCE);
|
CodeCompletion->completeReturnStmt(CCE);
|
||||||
}
|
}
|
||||||
Result.setHasCodeCompletion();
|
Result.setHasCodeCompletion();
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -737,7 +737,7 @@ ParserResult<Stmt> Parser::parseStmtReturn(SourceLoc tryLoc) {
|
|||||||
/// 'throw' expr
|
/// 'throw' expr
|
||||||
///
|
///
|
||||||
ParserResult<Stmt> Parser::parseStmtThrow(SourceLoc tryLoc) {
|
ParserResult<Stmt> Parser::parseStmtThrow(SourceLoc tryLoc) {
|
||||||
SourceLoc throwLoc = consumeLoc(tok::kw_throw);
|
SourceLoc throwLoc = consumeToken(tok::kw_throw);
|
||||||
SourceLoc exprLoc;
|
SourceLoc exprLoc;
|
||||||
if (Tok.isNot(tok::eof))
|
if (Tok.isNot(tok::eof))
|
||||||
exprLoc = Tok.getLoc();
|
exprLoc = Tok.getLoc();
|
||||||
@@ -771,7 +771,7 @@ ParserResult<Stmt> Parser::parseStmtThrow(SourceLoc tryLoc) {
|
|||||||
/// 'defer' brace-stmt
|
/// 'defer' brace-stmt
|
||||||
///
|
///
|
||||||
ParserResult<Stmt> Parser::parseStmtDefer() {
|
ParserResult<Stmt> Parser::parseStmtDefer() {
|
||||||
SourceLoc DeferLoc = consumeLoc(tok::kw_defer);
|
SourceLoc DeferLoc = consumeToken(tok::kw_defer);
|
||||||
|
|
||||||
// Macro expand out the defer into a closure and call, which we can typecheck
|
// Macro expand out the defer into a closure and call, which we can typecheck
|
||||||
// and emit where needed.
|
// and emit where needed.
|
||||||
@@ -881,7 +881,7 @@ static void parseGuardedPattern(Parser &P, GuardedPattern &result,
|
|||||||
P.CodeCompletion->completePostfixExprBeginning(nullptr);
|
P.CodeCompletion->completePostfixExprBeginning(nullptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
} else {
|
} else {
|
||||||
result.ThePattern = patternResult.get();
|
result.ThePattern = patternResult.get();
|
||||||
status.setHasCodeCompletion();
|
status.setHasCodeCompletion();
|
||||||
@@ -893,9 +893,9 @@ static void parseGuardedPattern(Parser &P, GuardedPattern &result,
|
|||||||
P.peekToken().is(tok::code_complete)) {
|
P.peekToken().is(tok::code_complete)) {
|
||||||
setErrorResult();
|
setErrorResult();
|
||||||
if (P.CodeCompletion) {
|
if (P.CodeCompletion) {
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
P.CodeCompletion->completeCaseStmtDotPrefix();
|
P.CodeCompletion->completeCaseStmtDotPrefix();
|
||||||
P.consumeLoc();
|
P.consumeToken();
|
||||||
} else {
|
} else {
|
||||||
result.ThePattern = patternResult.get();
|
result.ThePattern = patternResult.get();
|
||||||
status.setHasCodeCompletion();
|
status.setHasCodeCompletion();
|
||||||
@@ -1084,7 +1084,7 @@ static void validateAvailabilitySpecList(Parser &P,
|
|||||||
|
|
||||||
// #available(...)
|
// #available(...)
|
||||||
ParserResult<PoundAvailableInfo> Parser::parseStmtConditionPoundAvailable() {
|
ParserResult<PoundAvailableInfo> Parser::parseStmtConditionPoundAvailable() {
|
||||||
SourceLoc PoundLoc = consumeLoc(tok::pound_available);
|
SourceLoc PoundLoc = consumeToken(tok::pound_available);
|
||||||
|
|
||||||
if (!Tok.isFollowingLParen()) {
|
if (!Tok.isFollowingLParen()) {
|
||||||
diagnose(Tok, diag::avail_query_expected_condition);
|
diagnose(Tok, diag::avail_query_expected_condition);
|
||||||
@@ -1092,7 +1092,7 @@ ParserResult<PoundAvailableInfo> Parser::parseStmtConditionPoundAvailable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StructureMarkerRAII ParsingAvailabilitySpecList(*this, Tok);
|
StructureMarkerRAII ParsingAvailabilitySpecList(*this, Tok);
|
||||||
SourceLoc LParenLoc = consumeLoc(tok::l_paren);
|
SourceLoc LParenLoc = consumeToken(tok::l_paren);
|
||||||
|
|
||||||
SmallVector<AvailabilitySpec *, 5> Specs;
|
SmallVector<AvailabilitySpec *, 5> Specs;
|
||||||
ParserStatus Status = parseAvailabilitySpecList(Specs);
|
ParserStatus Status = parseAvailabilitySpecList(Specs);
|
||||||
@@ -1135,7 +1135,7 @@ Parser::parseAvailabilitySpecList(SmallVectorImpl<AvailabilitySpec *> &Specs) {
|
|||||||
// We don't allow binary operators to combine specs.
|
// We don't allow binary operators to combine specs.
|
||||||
if (Tok.isBinaryOperator()) {
|
if (Tok.isBinaryOperator()) {
|
||||||
diagnose(Tok, diag::avail_query_disallowed_operator, Tok.getText());
|
diagnose(Tok, diag::avail_query_disallowed_operator, Tok.getText());
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
Status.setIsParseError();
|
Status.setIsParseError();
|
||||||
} else if (consumeIf(tok::comma)) {
|
} else if (consumeIf(tok::comma)) {
|
||||||
// keep going.
|
// keep going.
|
||||||
@@ -1180,7 +1180,7 @@ ParserStatus Parser::parseStmtCondition(StmtCondition &Condition,
|
|||||||
Tok.getText() == "&&") {
|
Tok.getText() == "&&") {
|
||||||
diagnose(Tok, diag::expected_comma_stmtcondition)
|
diagnose(Tok, diag::expected_comma_stmtcondition)
|
||||||
.fixItReplaceChars(getEndOfPreviousLoc(), Tok.getRange().getEnd(), ",");
|
.fixItReplaceChars(getEndOfPreviousLoc(), Tok.getRange().getEnd(), ",");
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1189,7 +1189,7 @@ ParserStatus Parser::parseStmtCondition(StmtCondition &Condition,
|
|||||||
if (Tok.is(tok::kw_where)) {
|
if (Tok.is(tok::kw_where)) {
|
||||||
diagnose(Tok, diag::expected_comma_stmtcondition)
|
diagnose(Tok, diag::expected_comma_stmtcondition)
|
||||||
.fixItReplaceChars(getEndOfPreviousLoc(), Tok.getRange().getEnd(), ",");
|
.fixItReplaceChars(getEndOfPreviousLoc(), Tok.getRange().getEnd(), ",");
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1224,8 +1224,8 @@ ParserStatus Parser::parseStmtCondition(StmtCondition &Condition,
|
|||||||
|
|
||||||
// Handle code completion after the #.
|
// Handle code completion after the #.
|
||||||
if (Tok.is(tok::pound) && peekToken().is(tok::code_complete)) {
|
if (Tok.is(tok::pound) && peekToken().is(tok::code_complete)) {
|
||||||
auto PoundPos = consumeLoc();
|
auto PoundPos = consumeToken();
|
||||||
auto CodeCompletionPos = consumeLoc();
|
auto CodeCompletionPos = consumeToken();
|
||||||
auto Expr = new (Context) CodeCompletionExpr(CharSourceRange(SourceMgr,
|
auto Expr = new (Context) CodeCompletionExpr(CharSourceRange(SourceMgr,
|
||||||
PoundPos, CodeCompletionPos));
|
PoundPos, CodeCompletionPos));
|
||||||
if (CodeCompletion)
|
if (CodeCompletion)
|
||||||
@@ -1271,7 +1271,7 @@ ParserStatus Parser::parseStmtCondition(StmtCondition &Condition,
|
|||||||
SourceLoc IntroducerLoc;
|
SourceLoc IntroducerLoc;
|
||||||
if (Tok.isAny(tok::kw_let, tok::kw_var, tok::kw_case)) {
|
if (Tok.isAny(tok::kw_let, tok::kw_var, tok::kw_case)) {
|
||||||
BindingKindStr = Tok.getText();
|
BindingKindStr = Tok.getText();
|
||||||
IntroducerLoc = consumeLoc();
|
IntroducerLoc = consumeToken();
|
||||||
} else {
|
} else {
|
||||||
// If we lack the leading let/var/case keyword, then we're here because
|
// If we lack the leading let/var/case keyword, then we're here because
|
||||||
// the user wrote something like "if let x = foo(), y = bar() {". Fix
|
// the user wrote something like "if let x = foo(), y = bar() {". Fix
|
||||||
@@ -1304,7 +1304,7 @@ ParserStatus Parser::parseStmtCondition(StmtCondition &Condition,
|
|||||||
.fixItRemove(IntroducerLoc)
|
.fixItRemove(IntroducerLoc)
|
||||||
.fixItInsertAfter(Tok.getLoc(), " " + BindingKindStr.str());
|
.fixItInsertAfter(Tok.getLoc(), " " + BindingKindStr.str());
|
||||||
|
|
||||||
consumeLoc(tok::kw_case);
|
consumeToken(tok::kw_case);
|
||||||
|
|
||||||
bool wasLet = BindingKindStr == "let";
|
bool wasLet = BindingKindStr == "let";
|
||||||
|
|
||||||
@@ -1379,7 +1379,7 @@ ParserStatus Parser::parseStmtCondition(StmtCondition &Condition,
|
|||||||
/// 'else' stmt-brace
|
/// 'else' stmt-brace
|
||||||
/// 'else' stmt-if
|
/// 'else' stmt-if
|
||||||
ParserResult<Stmt> Parser::parseStmtIf(LabeledStmtInfo LabelInfo) {
|
ParserResult<Stmt> Parser::parseStmtIf(LabeledStmtInfo LabelInfo) {
|
||||||
SourceLoc IfLoc = consumeLoc(tok::kw_if);
|
SourceLoc IfLoc = consumeToken(tok::kw_if);
|
||||||
|
|
||||||
ParserStatus Status;
|
ParserStatus Status;
|
||||||
StmtCondition Condition;
|
StmtCondition Condition;
|
||||||
@@ -1430,7 +1430,7 @@ ParserResult<Stmt> Parser::parseStmtIf(LabeledStmtInfo LabelInfo) {
|
|||||||
SourceLoc ElseLoc;
|
SourceLoc ElseLoc;
|
||||||
ParserResult<Stmt> ElseBody;
|
ParserResult<Stmt> ElseBody;
|
||||||
if (Tok.is(tok::kw_else)) {
|
if (Tok.is(tok::kw_else)) {
|
||||||
ElseLoc = consumeLoc(tok::kw_else);
|
ElseLoc = consumeToken(tok::kw_else);
|
||||||
if (Tok.is(tok::kw_if))
|
if (Tok.is(tok::kw_if))
|
||||||
ElseBody = parseStmtIf(LabeledStmtInfo());
|
ElseBody = parseStmtIf(LabeledStmtInfo());
|
||||||
else
|
else
|
||||||
@@ -1448,7 +1448,7 @@ ParserResult<Stmt> Parser::parseStmtIf(LabeledStmtInfo LabelInfo) {
|
|||||||
/// 'guard' condition 'else' stmt-brace
|
/// 'guard' condition 'else' stmt-brace
|
||||||
///
|
///
|
||||||
ParserResult<Stmt> Parser::parseStmtGuard() {
|
ParserResult<Stmt> Parser::parseStmtGuard() {
|
||||||
SourceLoc GuardLoc = consumeLoc(tok::kw_guard);
|
SourceLoc GuardLoc = consumeToken(tok::kw_guard);
|
||||||
|
|
||||||
ParserStatus Status;
|
ParserStatus Status;
|
||||||
StmtCondition Condition;
|
StmtCondition Condition;
|
||||||
@@ -1766,7 +1766,7 @@ ParserResult<Stmt> Parser::parseStmtIfConfig(BraceItemListKind Kind) {
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
bool isElse = Tok.is(tok::pound_else);
|
bool isElse = Tok.is(tok::pound_else);
|
||||||
SourceLoc ClauseLoc = consumeLoc();
|
SourceLoc ClauseLoc = consumeToken();
|
||||||
Expr *Condition = nullptr;
|
Expr *Condition = nullptr;
|
||||||
|
|
||||||
if (isElse) {
|
if (isElse) {
|
||||||
@@ -1830,7 +1830,7 @@ ParserResult<Stmt> Parser::parseStmtIfConfig(BraceItemListKind Kind) {
|
|||||||
/// stmt-while:
|
/// stmt-while:
|
||||||
/// (identifier ':')? 'while' expr-basic stmt-brace
|
/// (identifier ':')? 'while' expr-basic stmt-brace
|
||||||
ParserResult<Stmt> Parser::parseStmtWhile(LabeledStmtInfo LabelInfo) {
|
ParserResult<Stmt> Parser::parseStmtWhile(LabeledStmtInfo LabelInfo) {
|
||||||
SourceLoc WhileLoc = consumeLoc(tok::kw_while);
|
SourceLoc WhileLoc = consumeToken(tok::kw_while);
|
||||||
|
|
||||||
Scope S(this, ScopeKind::WhileVars);
|
Scope S(this, ScopeKind::WhileVars);
|
||||||
|
|
||||||
@@ -1881,7 +1881,7 @@ ParserResult<Stmt> Parser::parseStmtWhile(LabeledStmtInfo LabelInfo) {
|
|||||||
/// stmt-repeat:
|
/// stmt-repeat:
|
||||||
/// (identifier ':')? 'repeat' stmt-brace 'while' expr
|
/// (identifier ':')? 'repeat' stmt-brace 'while' expr
|
||||||
ParserResult<Stmt> Parser::parseStmtRepeat(LabeledStmtInfo labelInfo) {
|
ParserResult<Stmt> Parser::parseStmtRepeat(LabeledStmtInfo labelInfo) {
|
||||||
SourceLoc repeatLoc = consumeLoc(tok::kw_repeat);
|
SourceLoc repeatLoc = consumeToken(tok::kw_repeat);
|
||||||
|
|
||||||
ParserStatus status;
|
ParserStatus status;
|
||||||
|
|
||||||
@@ -1924,7 +1924,7 @@ ParserResult<Stmt> Parser::parseStmtRepeat(LabeledStmtInfo labelInfo) {
|
|||||||
/// (identifier ':')? 'do' stmt-brace
|
/// (identifier ':')? 'do' stmt-brace
|
||||||
/// (identifier ':')? 'do' stmt-brace stmt-catch+
|
/// (identifier ':')? 'do' stmt-brace stmt-catch+
|
||||||
ParserResult<Stmt> Parser::parseStmtDo(LabeledStmtInfo labelInfo) {
|
ParserResult<Stmt> Parser::parseStmtDo(LabeledStmtInfo labelInfo) {
|
||||||
SourceLoc doLoc = consumeLoc(tok::kw_do);
|
SourceLoc doLoc = consumeToken(tok::kw_do);
|
||||||
|
|
||||||
ParserStatus status;
|
ParserStatus status;
|
||||||
|
|
||||||
@@ -2005,7 +2005,7 @@ ParserResult<CatchStmt> Parser::parseStmtCatch() {
|
|||||||
// A catch block has its own scope for variables bound out of the pattern.
|
// A catch block has its own scope for variables bound out of the pattern.
|
||||||
Scope S(this, ScopeKind::CatchVars);
|
Scope S(this, ScopeKind::CatchVars);
|
||||||
|
|
||||||
SourceLoc catchLoc = consumeLoc(tok::kw_catch);
|
SourceLoc catchLoc = consumeToken(tok::kw_catch);
|
||||||
|
|
||||||
SmallVector<VarDecl*, 4> boundDecls;
|
SmallVector<VarDecl*, 4> boundDecls;
|
||||||
|
|
||||||
@@ -2032,7 +2032,7 @@ ParserResult<CatchStmt> Parser::parseStmtCatch() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ParserResult<Stmt> Parser::parseStmtFor(LabeledStmtInfo LabelInfo) {
|
ParserResult<Stmt> Parser::parseStmtFor(LabeledStmtInfo LabelInfo) {
|
||||||
SourceLoc ForLoc = consumeLoc(tok::kw_for);
|
SourceLoc ForLoc = consumeToken(tok::kw_for);
|
||||||
|
|
||||||
// The c-style-for loop and foreach-style-for loop are conflated together into
|
// The c-style-for loop and foreach-style-for loop are conflated together into
|
||||||
// a single keyword, so we have to do some lookahead to resolve what is going
|
// a single keyword, so we have to do some lookahead to resolve what is going
|
||||||
@@ -2145,7 +2145,7 @@ ParserResult<Stmt> Parser::parseStmtForCStyle(SourceLoc ForLoc,
|
|||||||
Scope S(this, ScopeKind::ForVars);
|
Scope S(this, ScopeKind::ForVars);
|
||||||
|
|
||||||
if (Tok.is(tok::l_paren)) {
|
if (Tok.is(tok::l_paren)) {
|
||||||
LPLoc = consumeLoc();
|
LPLoc = consumeToken();
|
||||||
LPLocConsumed = true;
|
LPLocConsumed = true;
|
||||||
}
|
}
|
||||||
// Parse the first part, either a var, let, expr, or stmt-assign.
|
// Parse the first part, either a var, let, expr, or stmt-assign.
|
||||||
@@ -2180,7 +2180,7 @@ ParserResult<Stmt> Parser::parseStmtForCStyle(SourceLoc ForLoc,
|
|||||||
|
|
||||||
// Parse additional expressions.
|
// Parse additional expressions.
|
||||||
while (Tok.is(tok::comma)) {
|
while (Tok.is(tok::comma)) {
|
||||||
consumeLoc(tok::comma);
|
consumeToken(tok::comma);
|
||||||
|
|
||||||
First = parseExpr(diag::expected_expr);
|
First = parseExpr(diag::expected_expr);
|
||||||
Status |= First;
|
Status |= First;
|
||||||
@@ -2303,7 +2303,7 @@ ParserResult<Stmt> Parser::parseStmtForCStyle(SourceLoc ForLoc,
|
|||||||
|
|
||||||
// Parse additional expressions.
|
// Parse additional expressions.
|
||||||
while (Tok.is(tok::comma)) {
|
while (Tok.is(tok::comma)) {
|
||||||
consumeLoc(tok::comma);
|
consumeToken(tok::comma);
|
||||||
|
|
||||||
Third = parseExprBasic(diag::expected_expr);
|
Third = parseExprBasic(diag::expected_expr);
|
||||||
Status |= Third;
|
Status |= Third;
|
||||||
@@ -2428,7 +2428,7 @@ ParserResult<Stmt> Parser::parseStmtForEach(SourceLoc ForLoc,
|
|||||||
/// stmt-switch:
|
/// stmt-switch:
|
||||||
/// (identifier ':')? 'switch' expr-basic '{' stmt-case+ '}'
|
/// (identifier ':')? 'switch' expr-basic '{' stmt-case+ '}'
|
||||||
ParserResult<Stmt> Parser::parseStmtSwitch(LabeledStmtInfo LabelInfo) {
|
ParserResult<Stmt> Parser::parseStmtSwitch(LabeledStmtInfo LabelInfo) {
|
||||||
SourceLoc SwitchLoc = consumeLoc(tok::kw_switch);
|
SourceLoc SwitchLoc = consumeToken(tok::kw_switch);
|
||||||
|
|
||||||
ParserStatus Status;
|
ParserStatus Status;
|
||||||
ParserResult<Expr> SubjectExpr;
|
ParserResult<Expr> SubjectExpr;
|
||||||
@@ -2451,7 +2451,7 @@ ParserResult<Stmt> Parser::parseStmtSwitch(LabeledStmtInfo LabelInfo) {
|
|||||||
diagnose(Tok, diag::expected_lbrace_after_switch);
|
diagnose(Tok, diag::expected_lbrace_after_switch);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
SourceLoc lBraceLoc = consumeLoc(tok::l_brace);
|
SourceLoc lBraceLoc = consumeToken(tok::l_brace);
|
||||||
SourceLoc rBraceLoc;
|
SourceLoc rBraceLoc;
|
||||||
|
|
||||||
// Reject an empty 'switch'.
|
// Reject an empty 'switch'.
|
||||||
@@ -2466,7 +2466,7 @@ ParserResult<Stmt> Parser::parseStmtSwitch(LabeledStmtInfo LabelInfo) {
|
|||||||
&& !Tok.is(tok::r_brace) && !Tok.is(tok::eof)) {
|
&& !Tok.is(tok::r_brace) && !Tok.is(tok::eof)) {
|
||||||
if (ErrorAtNotCoveredStmt) {
|
if (ErrorAtNotCoveredStmt) {
|
||||||
// Error recovery.
|
// Error recovery.
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!DiagnosedNotCoveredStmt) {
|
if (!DiagnosedNotCoveredStmt) {
|
||||||
@@ -2517,7 +2517,7 @@ static ParserStatus parseStmtCase(Parser &P, SourceLoc &CaseLoc,
|
|||||||
ParserStatus Status;
|
ParserStatus Status;
|
||||||
bool isFirst = true;
|
bool isFirst = true;
|
||||||
|
|
||||||
CaseLoc = P.consumeLoc(tok::kw_case);
|
CaseLoc = P.consumeToken(tok::kw_case);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
GuardedPattern PatternResult;
|
GuardedPattern PatternResult;
|
||||||
@@ -2535,7 +2535,7 @@ static ParserStatus parseStmtCase(Parser &P, SourceLoc &CaseLoc,
|
|||||||
P.diagnose(P.Tok, diag::expected_case_colon, "case");
|
P.diagnose(P.Tok, diag::expected_case_colon, "case");
|
||||||
Status.setIsParseError();
|
Status.setIsParseError();
|
||||||
} else
|
} else
|
||||||
P.consumeLoc(tok::colon);
|
P.consumeToken(tok::colon);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@@ -2546,7 +2546,7 @@ parseStmtCaseDefault(Parser &P, SourceLoc &CaseLoc,
|
|||||||
SourceLoc &ColonLoc) {
|
SourceLoc &ColonLoc) {
|
||||||
ParserStatus Status;
|
ParserStatus Status;
|
||||||
|
|
||||||
CaseLoc = P.consumeLoc(tok::kw_default);
|
CaseLoc = P.consumeToken(tok::kw_default);
|
||||||
|
|
||||||
// We don't allow 'where' guards on a 'default' block. For recovery
|
// We don't allow 'where' guards on a 'default' block. For recovery
|
||||||
// parse one if present.
|
// parse one if present.
|
||||||
@@ -2554,7 +2554,7 @@ parseStmtCaseDefault(Parser &P, SourceLoc &CaseLoc,
|
|||||||
ParserResult<Expr> Guard;
|
ParserResult<Expr> Guard;
|
||||||
if (P.Tok.is(tok::kw_where)) {
|
if (P.Tok.is(tok::kw_where)) {
|
||||||
P.diagnose(P.Tok, diag::default_with_where);
|
P.diagnose(P.Tok, diag::default_with_where);
|
||||||
WhereLoc = P.consumeLoc(tok::kw_where);
|
WhereLoc = P.consumeToken(tok::kw_where);
|
||||||
Guard = P.parseExpr(diag::expected_case_where_expr);
|
Guard = P.parseExpr(diag::expected_case_where_expr);
|
||||||
Status |= Guard;
|
Status |= Guard;
|
||||||
}
|
}
|
||||||
@@ -2564,7 +2564,7 @@ parseStmtCaseDefault(Parser &P, SourceLoc &CaseLoc,
|
|||||||
P.diagnose(P.Tok, diag::expected_case_colon, "default");
|
P.diagnose(P.Tok, diag::expected_case_colon, "default");
|
||||||
Status.setIsParseError();
|
Status.setIsParseError();
|
||||||
} else
|
} else
|
||||||
P.consumeLoc(tok::colon);
|
P.consumeToken(tok::colon);
|
||||||
|
|
||||||
// Create an implicit AnyPattern to represent the default match.
|
// Create an implicit AnyPattern to represent the default match.
|
||||||
auto Any = new (P.Context) AnyPattern(CaseLoc);
|
auto Any = new (P.Context) AnyPattern(CaseLoc);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ ParserResult<TypeRepr> Parser::parseTypeSimple(Diag<> MessageID,
|
|||||||
if (CodeCompletion)
|
if (CodeCompletion)
|
||||||
CodeCompletion->completeTypeSimpleBeginning();
|
CodeCompletion->completeTypeSimpleBeginning();
|
||||||
// Eat the code completion token because we handled it.
|
// Eat the code completion token because we handled it.
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
return makeParserCodeCompletionResult<TypeRepr>();
|
return makeParserCodeCompletionResult<TypeRepr>();
|
||||||
case tok::kw_super:
|
case tok::kw_super:
|
||||||
case tok::kw_self:
|
case tok::kw_self:
|
||||||
@@ -81,7 +81,7 @@ ParserResult<TypeRepr> Parser::parseTypeSimple(Diag<> MessageID,
|
|||||||
// safe to skip over.
|
// safe to skip over.
|
||||||
diagnose(Tok, MessageID);
|
diagnose(Tok, MessageID);
|
||||||
ty = makeParserErrorResult(new (Context) ErrorTypeRepr(Tok.getLoc()));
|
ty = makeParserErrorResult(new (Context) ErrorTypeRepr(Tok.getLoc()));
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
// FIXME: we could try to continue to parse.
|
// FIXME: we could try to continue to parse.
|
||||||
return ty;
|
return ty;
|
||||||
case tok::l_square:
|
case tok::l_square:
|
||||||
@@ -97,7 +97,7 @@ ParserResult<TypeRepr> Parser::parseTypeSimple(Diag<> MessageID,
|
|||||||
diagnose(Tok, MessageID);
|
diagnose(Tok, MessageID);
|
||||||
if (Tok.isKeyword() && !Tok.isAtStartOfLine()) {
|
if (Tok.isKeyword() && !Tok.isAtStartOfLine()) {
|
||||||
ty = makeParserErrorResult(new (Context) ErrorTypeRepr(Tok.getLoc()));
|
ty = makeParserErrorResult(new (Context) ErrorTypeRepr(Tok.getLoc()));
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return ty;
|
return ty;
|
||||||
}
|
}
|
||||||
checkForInputIncomplete();
|
checkForInputIncomplete();
|
||||||
@@ -108,15 +108,15 @@ ParserResult<TypeRepr> Parser::parseTypeSimple(Diag<> MessageID,
|
|||||||
while (ty.isNonNull()) {
|
while (ty.isNonNull()) {
|
||||||
if ((Tok.is(tok::period) || Tok.is(tok::period_prefix))) {
|
if ((Tok.is(tok::period) || Tok.is(tok::period_prefix))) {
|
||||||
if (peekToken().isContextualKeyword("Type")) {
|
if (peekToken().isContextualKeyword("Type")) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
SourceLoc metatypeLoc = consumeLoc(tok::identifier);
|
SourceLoc metatypeLoc = consumeToken(tok::identifier);
|
||||||
ty = makeParserResult(ty,
|
ty = makeParserResult(ty,
|
||||||
new (Context) MetatypeTypeRepr(ty.get(), metatypeLoc));
|
new (Context) MetatypeTypeRepr(ty.get(), metatypeLoc));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (peekToken().isContextualKeyword("Protocol")) {
|
if (peekToken().isContextualKeyword("Protocol")) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
SourceLoc protocolLoc = consumeLoc(tok::identifier);
|
SourceLoc protocolLoc = consumeToken(tok::identifier);
|
||||||
ty = makeParserResult(ty,
|
ty = makeParserResult(ty,
|
||||||
new (Context) ProtocolTypeRepr(ty.get(), protocolLoc));
|
new (Context) ProtocolTypeRepr(ty.get(), protocolLoc));
|
||||||
continue;
|
continue;
|
||||||
@@ -197,7 +197,7 @@ ParserResult<TypeRepr> Parser::parseType(Diag<> MessageID,
|
|||||||
|
|
||||||
beforeThrowsPos = getParserPosition();
|
beforeThrowsPos = getParserPosition();
|
||||||
rethrows = Tok.is(tok::kw_rethrows);
|
rethrows = Tok.is(tok::kw_rethrows);
|
||||||
throwsLoc = consumeLoc();
|
throwsLoc = consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle type-function if we have an arrow.
|
// Handle type-function if we have an arrow.
|
||||||
@@ -321,7 +321,7 @@ ParserResult<TypeRepr> Parser::parseTypeIdentifier() {
|
|||||||
if (CodeCompletion)
|
if (CodeCompletion)
|
||||||
CodeCompletion->completeTypeSimpleBeginning();
|
CodeCompletion->completeTypeSimpleBeginning();
|
||||||
// Eat the code completion token because we handled it.
|
// Eat the code completion token because we handled it.
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
return makeParserCodeCompletionResult<IdentTypeRepr>();
|
return makeParserCodeCompletionResult<IdentTypeRepr>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +330,7 @@ ParserResult<TypeRepr> Parser::parseTypeIdentifier() {
|
|||||||
// If there is a keyword at the start of a new line, we won't want to
|
// If there is a keyword at the start of a new line, we won't want to
|
||||||
// skip it as a recovery but rather keep it.
|
// skip it as a recovery but rather keep it.
|
||||||
if (Tok.isKeyword() && !Tok.isAtStartOfLine())
|
if (Tok.isKeyword() && !Tok.isAtStartOfLine())
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -379,7 +379,7 @@ ParserResult<TypeRepr> Parser::parseTypeIdentifier() {
|
|||||||
}
|
}
|
||||||
if (!peekToken().isContextualKeyword("Type")
|
if (!peekToken().isContextualKeyword("Type")
|
||||||
&& !peekToken().isContextualKeyword("Protocol")) {
|
&& !peekToken().isContextualKeyword("Protocol")) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (Tok.is(tok::code_complete)) {
|
} else if (Tok.is(tok::code_complete)) {
|
||||||
@@ -404,13 +404,13 @@ ParserResult<TypeRepr> Parser::parseTypeIdentifier() {
|
|||||||
if (Status.hasCodeCompletion() && CodeCompletion) {
|
if (Status.hasCodeCompletion() && CodeCompletion) {
|
||||||
if (Tok.isNot(tok::code_complete)) {
|
if (Tok.isNot(tok::code_complete)) {
|
||||||
// We have a dot.
|
// We have a dot.
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
CodeCompletion->completeTypeIdentifierWithDot(ITR);
|
CodeCompletion->completeTypeIdentifierWithDot(ITR);
|
||||||
} else {
|
} else {
|
||||||
CodeCompletion->completeTypeIdentifierWithoutDot(ITR);
|
CodeCompletion->completeTypeIdentifierWithoutDot(ITR);
|
||||||
}
|
}
|
||||||
// Eat the code completion token because we handled it.
|
// Eat the code completion token because we handled it.
|
||||||
consumeLoc(tok::code_complete);
|
consumeToken(tok::code_complete);
|
||||||
}
|
}
|
||||||
|
|
||||||
return makeParserResult(Status, ITR);
|
return makeParserResult(Status, ITR);
|
||||||
@@ -456,7 +456,7 @@ Parser::parseTypeSimpleOrComposition(Diag<> MessageID,
|
|||||||
addType(FirstType.get());
|
addType(FirstType.get());
|
||||||
|
|
||||||
while (Tok.isContextualPunctuator("&")) {
|
while (Tok.isContextualPunctuator("&")) {
|
||||||
consumeLoc(); // consume '&'
|
consumeToken(); // consume '&'
|
||||||
ParserResult<TypeRepr> ty =
|
ParserResult<TypeRepr> ty =
|
||||||
parseTypeSimple(diag::expected_identifier_for_type, HandleCodeCompletion);
|
parseTypeSimple(diag::expected_identifier_for_type, HandleCodeCompletion);
|
||||||
if (ty.hasCodeCompletion())
|
if (ty.hasCodeCompletion())
|
||||||
@@ -471,7 +471,7 @@ Parser::parseTypeSimpleOrComposition(Diag<> MessageID,
|
|||||||
|
|
||||||
ParserResult<CompositionTypeRepr> Parser::parseAnyType() {
|
ParserResult<CompositionTypeRepr> Parser::parseAnyType() {
|
||||||
return makeParserResult(CompositionTypeRepr
|
return makeParserResult(CompositionTypeRepr
|
||||||
::createEmptyComposition(Context, consumeLoc(tok::kw_Any)));
|
::createEmptyComposition(Context, consumeToken(tok::kw_Any)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// parseOldStyleProtocolComposition
|
/// parseOldStyleProtocolComposition
|
||||||
@@ -485,7 +485,7 @@ ParserResult<CompositionTypeRepr> Parser::parseAnyType() {
|
|||||||
ParserResult<TypeRepr> Parser::parseOldStyleProtocolComposition() {
|
ParserResult<TypeRepr> Parser::parseOldStyleProtocolComposition() {
|
||||||
assert(Tok.is(tok::kw_protocol) && startsWithLess(peekToken()));
|
assert(Tok.is(tok::kw_protocol) && startsWithLess(peekToken()));
|
||||||
|
|
||||||
SourceLoc ProtocolLoc = consumeLoc();
|
SourceLoc ProtocolLoc = consumeToken();
|
||||||
SourceLoc LAngleLoc = consumeStartingLess();
|
SourceLoc LAngleLoc = consumeStartingLess();
|
||||||
|
|
||||||
// Parse the type-composition-list.
|
// Parse the type-composition-list.
|
||||||
@@ -583,7 +583,7 @@ ParserResult<TypeRepr> Parser::parseOldStyleProtocolComposition() {
|
|||||||
/// type
|
/// type
|
||||||
ParserResult<TupleTypeRepr> Parser::parseTypeTupleBody() {
|
ParserResult<TupleTypeRepr> Parser::parseTypeTupleBody() {
|
||||||
Parser::StructureMarkerRAII ParsingTypeTuple(*this, Tok);
|
Parser::StructureMarkerRAII ParsingTypeTuple(*this, Tok);
|
||||||
SourceLoc RPLoc, LPLoc = consumeLoc(tok::l_paren);
|
SourceLoc RPLoc, LPLoc = consumeToken(tok::l_paren);
|
||||||
SourceLoc EllipsisLoc;
|
SourceLoc EllipsisLoc;
|
||||||
unsigned EllipsisIdx;
|
unsigned EllipsisIdx;
|
||||||
SmallVector<TypeRepr *, 8> ElementsR;
|
SmallVector<TypeRepr *, 8> ElementsR;
|
||||||
@@ -615,7 +615,7 @@ ParserResult<TupleTypeRepr> Parser::parseTypeTupleBody() {
|
|||||||
Identifier name;
|
Identifier name;
|
||||||
if (!Tok.is(tok::kw__))
|
if (!Tok.is(tok::kw__))
|
||||||
name = Context.getIdentifier(Tok.getText());
|
name = Context.getIdentifier(Tok.getText());
|
||||||
SourceLoc nameLoc = consumeLoc();
|
SourceLoc nameLoc = consumeToken();
|
||||||
|
|
||||||
// If there is a second name, consume it as well.
|
// If there is a second name, consume it as well.
|
||||||
Identifier secondName;
|
Identifier secondName;
|
||||||
@@ -623,7 +623,7 @@ ParserResult<TupleTypeRepr> Parser::parseTypeTupleBody() {
|
|||||||
if (Tok.canBeArgumentLabel()) {
|
if (Tok.canBeArgumentLabel()) {
|
||||||
if (!Tok.is(tok::kw__))
|
if (!Tok.is(tok::kw__))
|
||||||
secondName = Context.getIdentifier(Tok.getText());
|
secondName = Context.getIdentifier(Tok.getText());
|
||||||
secondNameLoc = consumeLoc();
|
secondNameLoc = consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Consume the ':'.
|
// Consume the ':'.
|
||||||
@@ -695,7 +695,7 @@ ParserResult<TupleTypeRepr> Parser::parseTypeTupleBody() {
|
|||||||
// Parse '= expr' here so we can complain about it directly, rather
|
// Parse '= expr' here so we can complain about it directly, rather
|
||||||
// than dying when we see it.
|
// than dying when we see it.
|
||||||
if (Tok.is(tok::equal)) {
|
if (Tok.is(tok::equal)) {
|
||||||
SourceLoc equalLoc = consumeLoc(tok::equal);
|
SourceLoc equalLoc = consumeToken(tok::equal);
|
||||||
auto init = parseExpr(diag::expected_init_value);
|
auto init = parseExpr(diag::expected_init_value);
|
||||||
auto inFlight = diagnose(equalLoc, diag::tuple_type_init);
|
auto inFlight = diagnose(equalLoc, diag::tuple_type_init);
|
||||||
if (init.isNonNull())
|
if (init.isNonNull())
|
||||||
@@ -707,9 +707,9 @@ ParserResult<TupleTypeRepr> Parser::parseTypeTupleBody() {
|
|||||||
diagnose(Tok, diag::multiple_ellipsis_in_tuple)
|
diagnose(Tok, diag::multiple_ellipsis_in_tuple)
|
||||||
.highlight(EllipsisLoc)
|
.highlight(EllipsisLoc)
|
||||||
.fixItRemove(Tok.getLoc());
|
.fixItRemove(Tok.getLoc());
|
||||||
(void)consumeLoc();
|
(void)consumeToken();
|
||||||
} else {
|
} else {
|
||||||
EllipsisLoc = consumeLoc();
|
EllipsisLoc = consumeToken();
|
||||||
EllipsisIdx = ElementsR.size() - 1;
|
EllipsisIdx = ElementsR.size() - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -797,7 +797,7 @@ ParserResult<TupleTypeRepr> Parser::parseTypeTupleBody() {
|
|||||||
ParserResult<TypeRepr> Parser::parseTypeArray(TypeRepr *Base) {
|
ParserResult<TypeRepr> Parser::parseTypeArray(TypeRepr *Base) {
|
||||||
assert(Tok.isFollowingLSquare());
|
assert(Tok.isFollowingLSquare());
|
||||||
Parser::StructureMarkerRAII ParsingArrayBound(*this, Tok);
|
Parser::StructureMarkerRAII ParsingArrayBound(*this, Tok);
|
||||||
SourceLoc lsquareLoc = consumeLoc();
|
SourceLoc lsquareLoc = consumeToken();
|
||||||
ArrayTypeRepr *ATR = nullptr;
|
ArrayTypeRepr *ATR = nullptr;
|
||||||
|
|
||||||
// Handle a postfix [] production, a common typo for a C-like array.
|
// Handle a postfix [] production, a common typo for a C-like array.
|
||||||
@@ -833,7 +833,7 @@ ParserResult<TypeRepr> Parser::parseTypeCollection() {
|
|||||||
// Parse the leading '['.
|
// Parse the leading '['.
|
||||||
assert(Tok.is(tok::l_square));
|
assert(Tok.is(tok::l_square));
|
||||||
Parser::StructureMarkerRAII parsingCollection(*this, Tok);
|
Parser::StructureMarkerRAII parsingCollection(*this, Tok);
|
||||||
SourceLoc lsquareLoc = consumeLoc();
|
SourceLoc lsquareLoc = consumeToken();
|
||||||
|
|
||||||
// Parse the element type.
|
// Parse the element type.
|
||||||
ParserResult<TypeRepr> firstTy = parseType(diag::expected_element_type);
|
ParserResult<TypeRepr> firstTy = parseType(diag::expected_element_type);
|
||||||
@@ -842,7 +842,7 @@ ParserResult<TypeRepr> Parser::parseTypeCollection() {
|
|||||||
SourceLoc colonLoc;
|
SourceLoc colonLoc;
|
||||||
ParserResult<TypeRepr> secondTy;
|
ParserResult<TypeRepr> secondTy;
|
||||||
if (Tok.is(tok::colon)) {
|
if (Tok.is(tok::colon)) {
|
||||||
colonLoc = consumeLoc();
|
colonLoc = consumeToken();
|
||||||
|
|
||||||
// Parse the second type.
|
// Parse the second type.
|
||||||
secondTy = parseType(diag::expected_dictionary_value_type);
|
secondTy = parseType(diag::expected_dictionary_value_type);
|
||||||
@@ -1016,19 +1016,19 @@ bool Parser::canParseType() {
|
|||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case tok::l_paren: {
|
case tok::l_paren: {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (!canParseTypeTupleBody())
|
if (!canParseTypeTupleBody())
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case tok::at_sign: {
|
case tok::at_sign: {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (!canParseTypeAttribute())
|
if (!canParseTypeAttribute())
|
||||||
return false;
|
return false;
|
||||||
return canParseType();
|
return canParseType();
|
||||||
}
|
}
|
||||||
case tok::l_square:
|
case tok::l_square:
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (!canParseType())
|
if (!canParseType())
|
||||||
return false;
|
return false;
|
||||||
if (consumeIf(tok::colon)) {
|
if (consumeIf(tok::colon)) {
|
||||||
@@ -1049,8 +1049,8 @@ bool Parser::canParseType() {
|
|||||||
if ((Tok.is(tok::period) || Tok.is(tok::period_prefix)) &&
|
if ((Tok.is(tok::period) || Tok.is(tok::period_prefix)) &&
|
||||||
(peekToken().isContextualKeyword("Type")
|
(peekToken().isContextualKeyword("Type")
|
||||||
|| peekToken().isContextualKeyword("Protocol"))) {
|
|| peekToken().isContextualKeyword("Protocol"))) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
consumeLoc(tok::identifier);
|
consumeToken(tok::identifier);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (isOptionalToken(Tok)) {
|
if (isOptionalToken(Tok)) {
|
||||||
@@ -1066,7 +1066,7 @@ bool Parser::canParseType() {
|
|||||||
|
|
||||||
// Handle type-function if we have an arrow or 'throws'/'rethrows' modifier.
|
// Handle type-function if we have an arrow or 'throws'/'rethrows' modifier.
|
||||||
if (Tok.isAny(tok::kw_throws, tok::kw_rethrows)) {
|
if (Tok.isAny(tok::kw_throws, tok::kw_rethrows)) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
// "throws" or "rethrows" isn't a valid type without being followed by
|
// "throws" or "rethrows" isn't a valid type without being followed by
|
||||||
// a return.
|
// a return.
|
||||||
if (!Tok.is(tok::arrow))
|
if (!Tok.is(tok::arrow))
|
||||||
@@ -1091,7 +1091,7 @@ bool Parser::canParseTypeIdentifierOrTypeComposition() {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (Tok.isContextualPunctuator("&")) {
|
if (Tok.isContextualPunctuator("&")) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@@ -1103,7 +1103,7 @@ bool Parser::canParseTypeIdentifier() {
|
|||||||
while (true) {
|
while (true) {
|
||||||
if (!Tok.isAny(tok::identifier, tok::kw_Self, tok::kw_Any))
|
if (!Tok.isAny(tok::identifier, tok::kw_Self, tok::kw_Any))
|
||||||
return false;
|
return false;
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
if (startsWithLess(Tok)) {
|
if (startsWithLess(Tok)) {
|
||||||
if (!canParseGenericArguments())
|
if (!canParseGenericArguments())
|
||||||
@@ -1115,7 +1115,7 @@ bool Parser::canParseTypeIdentifier() {
|
|||||||
if ((Tok.is(tok::period) || Tok.is(tok::period_prefix)) &&
|
if ((Tok.is(tok::period) || Tok.is(tok::period_prefix)) &&
|
||||||
!peekToken().isContextualKeyword("Type") &&
|
!peekToken().isContextualKeyword("Type") &&
|
||||||
!peekToken().isContextualKeyword("Protocol")) {
|
!peekToken().isContextualKeyword("Protocol")) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1124,7 +1124,7 @@ bool Parser::canParseTypeIdentifier() {
|
|||||||
|
|
||||||
|
|
||||||
bool Parser::canParseOldStyleProtocolComposition() {
|
bool Parser::canParseOldStyleProtocolComposition() {
|
||||||
consumeLoc(tok::kw_protocol);
|
consumeToken(tok::kw_protocol);
|
||||||
|
|
||||||
// Check for the starting '<'.
|
// Check for the starting '<'.
|
||||||
if (!startsWithLess(Tok)) {
|
if (!startsWithLess(Tok)) {
|
||||||
@@ -1165,12 +1165,12 @@ bool Parser::canParseTypeTupleBody() {
|
|||||||
// by a type annotation.
|
// by a type annotation.
|
||||||
if (Tok.canBeArgumentLabel() &&
|
if (Tok.canBeArgumentLabel() &&
|
||||||
(peekToken().is(tok::colon) || peekToken().canBeArgumentLabel())) {
|
(peekToken().is(tok::colon) || peekToken().canBeArgumentLabel())) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (Tok.canBeArgumentLabel()) {
|
if (Tok.canBeArgumentLabel()) {
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
if (!Tok.is(tok::colon)) return false;
|
if (!Tok.is(tok::colon)) return false;
|
||||||
}
|
}
|
||||||
consumeLoc(tok::colon);
|
consumeToken(tok::colon);
|
||||||
|
|
||||||
// Parse a type.
|
// Parse a type.
|
||||||
if (!canParseType())
|
if (!canParseType())
|
||||||
@@ -1195,7 +1195,7 @@ bool Parser::canParseTypeTupleBody() {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (Tok.isEllipsis())
|
if (Tok.isEllipsis())
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
|
|
||||||
} while (consumeIf(tok::comma));
|
} while (consumeIf(tok::comma));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -349,21 +349,17 @@ const syntax::Token &Parser::peekToken() {
|
|||||||
return L->peekNextToken();
|
return L->peekNextToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
syntax::Token Parser::consumeToken() {
|
SourceLoc Parser::consumeToken() {
|
||||||
auto CurrentTok = Tok;
|
auto CurrentLoc = Tok.getLoc();
|
||||||
assert(CurrentTok.isNot(tok::eof) && "Lexing past eof!");
|
assert(Tok.isNot(tok::eof) && "Lexing past eof!");
|
||||||
|
|
||||||
if (IsParsingInterfaceTokens && !CurrentTok.getText().empty()) {
|
if (IsParsingInterfaceTokens && !Tok.getText().empty()) {
|
||||||
SF.recordInterfaceToken(Tok.getText());
|
SF.recordInterfaceToken(Tok.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
PreviousLoc = CurrentTok.getLoc();
|
PreviousLoc = CurrentLoc;
|
||||||
Tok = L->lex();
|
Tok = L->lex();
|
||||||
return CurrentTok;
|
return CurrentLoc;
|
||||||
}
|
|
||||||
|
|
||||||
SourceLoc Parser::consumeLoc() {
|
|
||||||
return consumeToken().getLoc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceLoc Parser::getEndOfPreviousLoc() {
|
SourceLoc Parser::getEndOfPreviousLoc() {
|
||||||
@@ -384,7 +380,7 @@ SourceLoc Parser::consumeStartingCharacterOfCurrentToken() {
|
|||||||
|
|
||||||
// Current token can be either one-character token we want to consume...
|
// Current token can be either one-character token we want to consume...
|
||||||
if (Tok.getWidth() == 1) {
|
if (Tok.getWidth() == 1) {
|
||||||
return consumeLoc();
|
return consumeToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SplitOperatorText = Tok.getText().substr(0, 1);
|
auto SplitOperatorText = Tok.getText().substr(0, 1);
|
||||||
@@ -417,24 +413,24 @@ SourceLoc Parser::consumeStartingGreater() {
|
|||||||
void Parser::skipSingle() {
|
void Parser::skipSingle() {
|
||||||
switch (Tok.getKind()) {
|
switch (Tok.getKind()) {
|
||||||
case tok::l_paren:
|
case tok::l_paren:
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
skipUntil(tok::r_paren);
|
skipUntil(tok::r_paren);
|
||||||
consumeIf(tok::r_paren);
|
consumeIf(tok::r_paren);
|
||||||
break;
|
break;
|
||||||
case tok::l_brace:
|
case tok::l_brace:
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
skipUntil(tok::r_brace);
|
skipUntil(tok::r_brace);
|
||||||
consumeIf(tok::r_brace);
|
consumeIf(tok::r_brace);
|
||||||
break;
|
break;
|
||||||
case tok::l_square:
|
case tok::l_square:
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
skipUntil(tok::r_square);
|
skipUntil(tok::r_square);
|
||||||
consumeIf(tok::r_square);
|
consumeIf(tok::r_square);
|
||||||
break;
|
break;
|
||||||
case tok::pound_if:
|
case tok::pound_if:
|
||||||
case tok::pound_else:
|
case tok::pound_else:
|
||||||
case tok::pound_elseif:
|
case tok::pound_elseif:
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
// skipUntil also implicitly stops at tok::pound_endif.
|
// skipUntil also implicitly stops at tok::pound_endif.
|
||||||
skipUntil(tok::pound_else, tok::pound_elseif);
|
skipUntil(tok::pound_else, tok::pound_elseif);
|
||||||
|
|
||||||
@@ -445,7 +441,7 @@ void Parser::skipSingle() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -605,7 +601,7 @@ bool Parser::parseSpecificIdentifier(StringRef expected, SourceLoc &loc,
|
|||||||
diagnose(Tok, D);
|
diagnose(Tok, D);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
loc = consumeLoc(tok::identifier);
|
loc = consumeToken(tok::identifier);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,7 +613,7 @@ bool Parser::parseAnyIdentifier(Identifier &Result, SourceLoc &Loc,
|
|||||||
if (Tok.is(tok::identifier) || Tok.isAnyOperator()) {
|
if (Tok.is(tok::identifier) || Tok.isAnyOperator()) {
|
||||||
Result = Context.getIdentifier(Tok.getText());
|
Result = Context.getIdentifier(Tok.getText());
|
||||||
Loc = Tok.getLoc();
|
Loc = Tok.getLoc();
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -626,7 +622,7 @@ bool Parser::parseAnyIdentifier(Identifier &Result, SourceLoc &Loc,
|
|||||||
if (Tok.is(tok::exclaim_postfix)) {
|
if (Tok.is(tok::exclaim_postfix)) {
|
||||||
Result = Context.getIdentifier(Tok.getText());
|
Result = Context.getIdentifier(Tok.getText());
|
||||||
Loc = Tok.getLoc();
|
Loc = Tok.getLoc();
|
||||||
consumeLoc(tok::exclaim_postfix);
|
consumeToken(tok::exclaim_postfix);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,7 +645,7 @@ bool Parser::parseAnyIdentifier(Identifier &Result, SourceLoc &Loc,
|
|||||||
/// If the input is malformed, this emits the specified error diagnostic.
|
/// If the input is malformed, this emits the specified error diagnostic.
|
||||||
bool Parser::parseToken(tok K, SourceLoc &TokLoc, const Diagnostic &D) {
|
bool Parser::parseToken(tok K, SourceLoc &TokLoc, const Diagnostic &D) {
|
||||||
if (Tok.is(K)) {
|
if (Tok.is(K)) {
|
||||||
TokLoc = consumeLoc(K);
|
TokLoc = consumeToken(K);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -687,7 +683,7 @@ Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
|
|||||||
assert(SeparatorK == tok::comma || SeparatorK == tok::semi);
|
assert(SeparatorK == tok::comma || SeparatorK == tok::semi);
|
||||||
|
|
||||||
if (Tok.is(RightK)) {
|
if (Tok.is(RightK)) {
|
||||||
RightLoc = consumeLoc(RightK);
|
RightLoc = consumeToken(RightK);
|
||||||
return makeParserSuccess();
|
return makeParserSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,7 +693,7 @@ Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
|
|||||||
diagnose(Tok, diag::unexpected_separator,
|
diagnose(Tok, diag::unexpected_separator,
|
||||||
SeparatorK == tok::comma ? "," : ";")
|
SeparatorK == tok::comma ? "," : ";")
|
||||||
.fixItRemove(SourceRange(Tok.getLoc()));
|
.fixItRemove(SourceRange(Tok.getLoc()));
|
||||||
consumeLoc();
|
consumeToken();
|
||||||
}
|
}
|
||||||
auto StartLoc = Tok.getLoc();
|
auto StartLoc = Tok.getLoc();
|
||||||
Status |= callback();
|
Status |= callback();
|
||||||
@@ -748,7 +744,7 @@ Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
|
|||||||
|
|
||||||
if (Status.isError()) {
|
if (Status.isError()) {
|
||||||
// If we've already got errors, don't emit missing RightK diagnostics.
|
// If we've already got errors, don't emit missing RightK diagnostics.
|
||||||
RightLoc = Tok.is(RightK) ? consumeLoc() : PreviousLoc;
|
RightLoc = Tok.is(RightK) ? consumeToken() : PreviousLoc;
|
||||||
} else if (parseMatchingToken(RightK, RightLoc, ErrorDiag, LeftLoc)) {
|
} else if (parseMatchingToken(RightK, RightLoc, ErrorDiag, LeftLoc)) {
|
||||||
Status.setIsParseError();
|
Status.setIsParseError();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user