diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-08-16 20:03:01 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-08-16 20:03:01 +0000 |
commit | 0cd5b429fad6833dda23f0aced14a10907ac5539 (patch) | |
tree | 7182b69bf57ea76a62e3684b1070edd4e5aa03cf /lib/Parse/ParseExpr.cpp | |
parent | b348b810e788c6c16129d99b99408a06e4639e0c (diff) |
Put (argument)-expression-list parsing in a separate function so that it can be re-used.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54851 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 4b45cb73f6..16bd1cba04 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -607,24 +607,15 @@ Parser::ExprResult Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { } case tok::l_paren: { // p-e: p-e '(' argument-expression-list[opt] ')' - llvm::SmallVector<ExprTy*, 8> ArgExprs; - llvm::SmallVector<SourceLocation, 8> CommaLocs; + ExprListTy ArgExprs; + CommaLocsTy CommaLocs; Loc = ConsumeParen(); if (Tok.isNot(tok::r_paren)) { - while (1) { - ExprResult ArgExpr = ParseAssignmentExpression(); - if (ArgExpr.isInvalid) { - SkipUntil(tok::r_paren); - return ExprResult(true); - } else - ArgExprs.push_back(ArgExpr.Val); - - if (Tok.isNot(tok::comma)) - break; - // Move to the next argument, remember where the comma was. - CommaLocs.push_back(ConsumeToken()); + if (ParseExpressionList(ArgExprs, CommaLocs)) { + SkipUntil(tok::r_paren); + return ExprResult(true); } } @@ -1010,3 +1001,28 @@ Parser::ExprResult Parser::ParseStringLiteralExpression() { // Pass the set of string tokens, ready for concatenation, to the actions. return Actions.ActOnStringLiteral(&StringToks[0], StringToks.size()); } + +/// ParseExpressionList - Used for C/C++ (argument-)expression-list. +/// +/// argument-expression-list: +/// assignment-expression +/// argument-expression-list , assignment-expression +/// +/// [C++] expression-list: +/// [C++] assignment-expression +/// [C++] expression-list , assignment-expression +/// +bool Parser::ParseExpressionList(ExprListTy &Exprs, CommaLocsTy &CommaLocs) { + while (1) { + ExprResult Expr = ParseAssignmentExpression(); + if (Expr.isInvalid) + return true; + else + Exprs.push_back(Expr.Val); + + if (Tok.isNot(tok::comma)) + return false; + // Move to the next argument, remember where the comma was. + CommaLocs.push_back(ConsumeToken()); + } +} |