Add some utilities for parsing verbatim identifiers and AST types.

Swift SVN r18933
This commit is contained in:
John McCall
2014-06-16 17:35:42 +00:00
parent 1fed3121ad
commit 05b51f4fa7

View File

@@ -170,9 +170,12 @@ namespace {
return parseSILIdentifier(Result, L, Diagnostic(ID, Args...));
}
bool parseVerbatim(StringRef identifier);
/// @}
// Parsing logic.
bool parseASTType(CanType &result);
bool parseSILType(SILType &Result, GenericParamList *&genericParams,
bool IsFuncDecl = false);
bool parseSILType(SILType &Result) {
@@ -294,6 +297,20 @@ bool SILParser::parseSILIdentifier(Identifier &Result, SourceLoc &Loc,
return false;
}
bool SILParser::parseVerbatim(StringRef name) {
Identifier tok;
SourceLoc loc;
if (parseSILIdentifier(tok, loc, diag::expected_tok_in_sil_instr, name)) {
return true;
}
if (tok.str() != name) {
P.diagnose(loc, diag::expected_tok_in_sil_instr, name);
return true;
}
return false;
}
/// diagnoseProblems - After a function is fully parse, emit any diagnostics
/// for errors and return true if there were any.
bool SILParser::diagnoseProblems() {
@@ -730,6 +747,16 @@ bool SILParser::handleGenericParams(TypeLoc &T, ArchetypeBuilder *builder) {
return false;
}
bool SILParser::parseASTType(CanType &result) {
ParserResult<TypeRepr> parsedType = P.parseType();
if (parsedType.isNull()) return true;
TypeLoc loc = parsedType.get();
if (performTypeLocChecking(loc, false))
return true;
result = loc.getType()->getCanonicalType();
return false;
}
bool SILParser::parseSILTypeWithoutQualifiers(SILType &Result,
SILValueCategory category,
const TypeAttributes &attrs,