[llvm-rc] Add ACCELERATORS parsing ability. (parser, pt 3/8).

This improves the current llvm-rc parser by the ability of parsing
ACCELERATORS statement.

Moreover, some small improvements to the original parsing commit
were made.

Thanks for Nico Weber for his original work in this area.

Differential Revision: https://reviews.llvm.org/D36894

llvm-svn: 311946
diff --git a/llvm/tools/llvm-rc/ResourceScriptParser.h b/llvm/tools/llvm-rc/ResourceScriptParser.h
index b217a73..e286f83 100644
--- a/llvm/tools/llvm-rc/ResourceScriptParser.h
+++ b/llvm/tools/llvm-rc/ResourceScriptParser.h
@@ -77,10 +77,11 @@
 
   // The following methods try to read a single token, check if it has the
   // correct type and then parse it.
-  Expected<uint32_t> readInt();           // Parse an integer.
-  Expected<StringRef> readString();       // Parse a string.
-  Expected<StringRef> readIdentifier();   // Parse an identifier.
-  Expected<IntOrString> readTypeOrName(); // Parse an integer or an identifier.
+  Expected<uint32_t> readInt();            // Parse an integer.
+  Expected<StringRef> readString();        // Parse a string.
+  Expected<StringRef> readIdentifier();    // Parse an identifier.
+  Expected<IntOrString> readIntOrString(); // Parse an integer or a string.
+  Expected<IntOrString> readTypeOrName();  // Parse an integer or an identifier.
 
   // Advance the state by one, discarding the current token.
   // If the discarded token had an incorrect type, fail.
@@ -97,6 +98,13 @@
   Expected<SmallVector<uint32_t, 8>> readIntsWithCommas(size_t MinCount,
                                                         size_t MaxCount);
 
+  // Read an unknown number of flags preceded by commas. Each correct flag
+  // has an entry in FlagDesc array of length NumFlags. In case i-th
+  // flag (0-based) has been read, the i-th bit of the result is set.
+  // As long as parser has a comma to read, it expects to be fed with
+  // a correct flag afterwards.
+  Expected<uint32_t> parseFlags(ArrayRef<StringRef> FlagDesc);
+
   // Reads a set of optional statements. These can change the behavior of
   // a number of resource types (e.g. STRINGTABLE, MENU or DIALOG) if provided
   // before the main block with the contents of the resource.
@@ -118,6 +126,7 @@
 
   // Top-level resource parsers.
   ParseType parseLanguageResource();
+  ParseType parseAcceleratorsResource();
   ParseType parseCursorResource();
   ParseType parseIconResource();
   ParseType parseHTMLResource();