diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-07-09 22:53:07 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-07-09 22:53:07 +0000 |
commit | f7da726f09a6b7c5b9f5308e9690cb015398e671 (patch) | |
tree | 5ad8b5e569574f0626a77cc6be84b9c88a0e5e72 /lib/Parse/ParseExpr.cpp | |
parent | 9e0ed0bd5a3a7bac73973980ff32132a7724e674 (diff) |
Simplify the parser a bit by looking at the next token without consuming it (by Preprocessor::LookNext):
-Remove ParseExpressionWithLeadingIdentifier and ParseAssignmentExprWithLeadingIdentifier.
-Separate ParseLabeledStatement from ParseIdentifierStatement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53376 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index b1499c9fd6..17797ec488 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -228,69 +228,6 @@ Parser::ExprResult Parser::ParseConstantExpression() { return ParseRHSOfBinaryExpression(LHS, prec::Conditional); } -/// ParseExpressionWithLeadingIdentifier - This special purpose method is used -/// in contexts where we have already consumed an identifier (which we saved in -/// 'IdTok'), then discovered that the identifier was really the leading token -/// of part of an expression. For example, in "A[1]+B", we consumed "A" (which -/// is now in 'IdTok') and the current token is "[". -Parser::ExprResult Parser:: -ParseExpressionWithLeadingIdentifier(const Token &IdTok) { - // We know that 'IdTok' must correspond to this production: - // primary-expression: identifier - - // Let the actions module handle the identifier. - ExprResult Res = Actions.ActOnIdentifierExpr(CurScope, IdTok.getLocation(), - *IdTok.getIdentifierInfo(), - Tok.is(tok::l_paren)); - - // Because we have to parse an entire cast-expression before starting the - // ParseRHSOfBinaryExpression method (which parses any trailing binops), we - // need to handle the 'postfix-expression' rules. We do this by invoking - // ParsePostfixExpressionSuffix to consume any postfix-expression suffixes: - Res = ParsePostfixExpressionSuffix(Res); - if (Res.isInvalid) return Res; - - // At this point, the "A[1]" part of "A[1]+B" has been consumed. Once this is - // done, we know we don't have to do anything for cast-expression, because the - // only non-postfix-expression production starts with a '(' token, and we know - // we have an identifier. As such, we can invoke ParseRHSOfBinaryExpression - // to consume any trailing operators (e.g. "+" in this example) and connected - // chunks of the expression. - return ParseRHSOfBinaryExpression(Res, prec::Comma); -} - -/// ParseExpressionWithLeadingIdentifier - This special purpose method is used -/// in contexts where we have already consumed an identifier (which we saved in -/// 'IdTok'), then discovered that the identifier was really the leading token -/// of part of an assignment-expression. For example, in "A[1]+B", we consumed -/// "A" (which is now in 'IdTok') and the current token is "[". -Parser::ExprResult Parser:: -ParseAssignmentExprWithLeadingIdentifier(const Token &IdTok) { - // We know that 'IdTok' must correspond to this production: - // primary-expression: identifier - - // Let the actions module handle the identifier. - ExprResult Res = Actions.ActOnIdentifierExpr(CurScope, IdTok.getLocation(), - *IdTok.getIdentifierInfo(), - Tok.is(tok::l_paren)); - - // Because we have to parse an entire cast-expression before starting the - // ParseRHSOfBinaryExpression method (which parses any trailing binops), we - // need to handle the 'postfix-expression' rules. We do this by invoking - // ParsePostfixExpressionSuffix to consume any postfix-expression suffixes: - Res = ParsePostfixExpressionSuffix(Res); - if (Res.isInvalid) return Res; - - // At this point, the "A[1]" part of "A[1]+B" has been consumed. Once this is - // done, we know we don't have to do anything for cast-expression, because the - // only non-postfix-expression production starts with a '(' token, and we know - // we have an identifier. As such, we can invoke ParseRHSOfBinaryExpression - // to consume any trailing operators (e.g. "+" in this example) and connected - // chunks of the expression. - return ParseRHSOfBinaryExpression(Res, prec::Assignment); -} - - /// ParseRHSOfBinaryExpression - Parse a binary expression that starts with /// LHS and has a precedence of at least MinPrec. Parser::ExprResult |