simplify Parser::isStartOfStmt: just use the current token instead of having

all of the clients pass in the current token.  NFC.


Swift SVN r16601
This commit is contained in:
Chris Lattner
2014-04-21 04:01:03 +00:00
parent d35a2f5c94
commit b204be71cd
4 changed files with 8 additions and 11 deletions

View File

@@ -1021,7 +1021,7 @@ public:
//===--------------------------------------------------------------------===//
// Statement Parsing
bool isStartOfStmt(const Token &Tok);
bool isStartOfStmt();
ParserResult<Stmt> parseStmt();
ParserStatus parseExprOrStmt(ASTNode &Result);
ParserResult<Stmt> parseStmtReturn();

View File

@@ -46,8 +46,7 @@ static DefaultArgumentKind getDefaultArgKind(ExprHandle *init) {
static void recoverFromBadSelectorArgument(Parser &P) {
while (P.Tok.isNot(tok::eof) && P.Tok.isNot(tok::r_paren) &&
P.Tok.isNot(tok::l_brace) && P.Tok.isNot(tok::r_brace) &&
!P.isStartOfStmt(P.Tok) &&
!P.isStartOfDecl()) {
!P.isStartOfStmt() && !P.isStartOfDecl()) {
P.skipSingle();
}
P.consumeIf(tok::r_paren);

View File

@@ -27,10 +27,9 @@
using namespace swift;
/// isStartOfStmt - Return true if the specified token starts
/// a statement.
/// isStartOfStmt - Return true if the current token starts a statement.
///
bool Parser::isStartOfStmt(const Token &Tok) {
bool Parser::isStartOfStmt() {
switch (Tok.getKind()) {
default: return false;
case tok::kw_return:
@@ -57,7 +56,7 @@ ParserStatus Parser::parseExprOrStmt(ASTNode &Result) {
return makeParserError();
}
if (isStartOfStmt(Tok)) {
if (isStartOfStmt()) {
ParserResult<Stmt> Res = parseStmt();
if (Res.isNonNull())
Result = Res.get();
@@ -532,7 +531,7 @@ ParserResult<Stmt> Parser::parseStmtReturn() {
// enclosing stmt-brace to get it by eagerly eating it unless the return is
// followed by a '}', ';', statement or decl start keyword sequence.
if (Tok.isNot(tok::r_brace) && Tok.isNot(tok::semi) &&
!isStartOfStmt(Tok) && !isStartOfDecl()) {
!isStartOfStmt() && !isStartOfDecl()) {
SourceLoc ExprLoc;
if (Tok.isNot(tok::eof))
ExprLoc = Tok.getLoc();

View File

@@ -377,7 +377,7 @@ void Parser::skipUntilGreaterInTypeList() {
// 'Self' can appear in types, skip it.
if (Tok.is(tok::kw_Self))
break;
if (isStartOfStmt(Tok) || isStartOfDecl())
if (isStartOfStmt() || isStartOfDecl())
return;
break;
@@ -399,8 +399,7 @@ void Parser::skipUntilDeclRBrace() {
void Parser::skipUntilDeclStmtRBrace(tok T1) {
while (Tok.isNot(T1) && Tok.isNot(tok::eof) && Tok.isNot(tok::r_brace) &&
!isStartOfStmt(Tok) &&
!isStartOfDecl()) {
!isStartOfStmt() && !isStartOfDecl()) {
skipSingle();
}
}