split ParseStringExpr into semantic/minimal actions

llvm-svn: 39147
This commit is contained in:
Chris Lattner 2006-11-08 06:03:59 +00:00
parent 87ca807e15
commit 3503cefbba
2 changed files with 30 additions and 12 deletions

View File

@ -932,6 +932,12 @@ Parser::ExprResult Parser::ParseStringLiteralExpression() {
ConsumeStringToken();
} while (isTokenStringLiteral());
// If using minimal actions, don't do any semantic analysis of the parsed
// string fragments.
if (MinimalActions)
return MinimalActions->ParseStringExpr(&StringToks[0], StringToks.size());
// Include space for the null terminator.
++SizeBound;
@ -1098,8 +1104,8 @@ Parser::ExprResult Parser::ParseStringLiteralExpression() {
StringTokLocs.push_back(StringToks[i].getLocation());
// Hand this off to the Actions.
return Actions.ParseStringExpr(&ResultBuf[0], ResultPtr-&ResultBuf[0],
AnyWide, &StringTokLocs[0],
StringTokLocs.size());
return SemaActions->ParseStringExpr(&ResultBuf[0], ResultPtr-&ResultBuf[0],
AnyWide, &StringTokLocs[0],
StringTokLocs.size());
}

View File

@ -26,6 +26,7 @@ namespace clang {
class Action;
// Lex.
class IdentifierInfo;
class LexerToken;
/// Action - As the parser reads the input file and recognizes the productions
/// of the grammar, it invokes methods on this class to turn the parsed input
@ -208,15 +209,6 @@ public:
return Val; // Default impl returns operand.
}
/// ParseStringExpr - The (null terminated) string data is specified with
/// StrData+StrLen. isWide is true if this is a wide string. The Toks/NumToks
/// array exposes the input tokens to provide location information.
virtual ExprResult ParseStringExpr(const char *StrData, unsigned StrLen,
bool isWide,
SourceLocation *TokLocs, unsigned NumToks){
return 0;
}
// Postfix Expressions.
virtual ExprResult ParsePostfixUnaryOp(SourceLocation OpLoc,
tok::TokenKind Kind, ExprTy *Input) {
@ -300,6 +292,17 @@ public:
virtual DeclTy *ParsedClassDeclaration(Scope *S,
IdentifierInfo **IdentList,
unsigned NumElts);
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks.
//===--------------------------------------------------------------------===//
/// ParseStringExpr - The specified tokens were lexed as pasted string
/// fragments (e.g. "foo" "bar" L"baz").
virtual ExprResult ParseStringExpr(const LexerToken *Toks, unsigned NumToks){
return 0;
}
};
/// SemanticAction - Clients the implement this interface expect Decl nodes to
@ -308,6 +311,15 @@ public:
class SemanticAction : public Action {
public:
/// ParseStringExpr - The (null terminated) string data is specified with
/// StrData+StrLen. isWide is true if this is a wide string. The Toks/NumToks
/// array exposes the input tokens to provide location information.
virtual ExprResult ParseStringExpr(const char *StrData, unsigned StrLen,
bool isWide,
SourceLocation *TokLocs, unsigned NumToks){
return 0;
}
};
} // end namespace clang