mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add some utilities for parsing verbatim identifiers and AST types.
Swift SVN r18933
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user