summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rc/ResourceScriptParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-rc/ResourceScriptParser.cpp')
-rw-r--r--llvm/tools/llvm-rc/ResourceScriptParser.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/llvm/tools/llvm-rc/ResourceScriptParser.cpp b/llvm/tools/llvm-rc/ResourceScriptParser.cpp
index ee7de6b937a..211d9e7e954 100644
--- a/llvm/tools/llvm-rc/ResourceScriptParser.cpp
+++ b/llvm/tools/llvm-rc/ResourceScriptParser.cpp
@@ -80,7 +80,7 @@ RCParser::ParseType RCParser::parseSingleResource() {
else if (TypeToken->equalsLower("VERSIONINFO"))
Result = parseVersionInfoResource();
else
- return getExpectedError("resource type", /* IsAlreadyRead = */ true);
+ Result = parseUserDefinedResource(*TypeToken);
if (Result)
(*Result)->setName(*NameToken);
@@ -416,6 +416,31 @@ RCParser::ParseType RCParser::parseDialogResource(bool IsExtended) {
return std::move(Dialog);
}
+RCParser::ParseType RCParser::parseUserDefinedResource(IntOrString Type) {
+ if (isEof())
+ return getExpectedError("filename, '{' or BEGIN");
+
+ // Check if this is a file resource.
+ if (look().kind() == Kind::String)
+ return make_unique<UserDefinedResource>(Type, read().value());
+
+ RETURN_IF_ERROR(consumeType(Kind::BlockBegin));
+ std::vector<IntOrString> Data;
+
+ // Consume comma before each consecutive token except the first one.
+ bool ConsumeComma = false;
+ while (!consumeOptionalType(Kind::BlockEnd)) {
+ if (ConsumeComma)
+ RETURN_IF_ERROR(consumeType(Kind::Comma));
+ ConsumeComma = true;
+
+ ASSIGN_OR_RETURN(Item, readIntOrString());
+ Data.push_back(*Item);
+ }
+
+ return make_unique<UserDefinedResource>(Type, std::move(Data));
+}
+
RCParser::ParseType RCParser::parseVersionInfoResource() {
ASSIGN_OR_RETURN(FixedResult, parseVersionInfoFixed());
ASSIGN_OR_RETURN(BlockResult, parseVersionInfoBlockContents(StringRef()));
OpenPOWER on IntegriCloud