diff options
author | David Greene <greened@obbligato.org> | 2011-10-19 13:04:20 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2011-10-19 13:04:20 +0000 |
commit | f3744a0cf9f622e0879a80c1fdcb0f6072e5a6c3 (patch) | |
tree | 632cd0c6b6e7b717091cf32b44d223a90fc65bab /lib/TableGen/TGParser.h | |
parent | e338565757bfcfe9d762751c976684f66954fb45 (diff) |
Make ID Parsing More Flexible
Add a mode control to value and ID parsers. The two modes are:
- Parse a value. Expect the parsed ID to map to an existing object.
- Parse a name. Expect the parsed ID to not map to any existing object.
The first is used when parsing an identifier to be looked up, for
example a record field or template argument. The second is used for
parsing declarations. Paste functionality implies that declarations
can contain arbitrary expressions so we need to be able to call into
the general value parser to parse declarations with paste operators.
So we need a way to parse a value-like thing without expecting that
the result will map to some existing object. This parse mode provides
that.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142519 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/TableGen/TGParser.h')
-rw-r--r-- | lib/TableGen/TGParser.h | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/TableGen/TGParser.h b/lib/TableGen/TGParser.h index da52da2f79..18aeae22e2 100644 --- a/lib/TableGen/TGParser.h +++ b/lib/TableGen/TGParser.h @@ -53,6 +53,17 @@ class TGParser { // Record tracker RecordKeeper &Records; + + // A "named boolean" indicating how to parse identifiers. Usually + // identifiers map to some existing object but in special cases + // (e.g. parsing def names) no such object exists yet because we are + // in the middle of creating in. For those situations, allow the + // parser to ignore missing object errors. + enum IDParseMode { + ParseValueMode, // We are parsing a value we expect to look up. + ParseNameMode // We are parsing a name of an object that does not yet exist. + }; + public: TGParser(SourceMgr &SrcMgr, RecordKeeper &records) : Lex(SrcMgr), CurMultiClass(0), Records(records) {} @@ -118,10 +129,13 @@ private: // Parser methods. SubClassReference ParseSubClassReference(Record *CurRec, bool isDefm); SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC); - Init *ParseIDValue(Record *CurRec); - Init *ParseIDValue(Record *CurRec, const std::string &Name, SMLoc NameLoc); - Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = 0); - Init *ParseValue(Record *CurRec, RecTy *ItemType = 0); + Init *ParseIDValue(Record *CurRec, IDParseMode Mode = ParseValueMode); + Init *ParseIDValue(Record *CurRec, const std::string &Name, SMLoc NameLoc, + IDParseMode Mode = ParseValueMode); + Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = 0, + IDParseMode Mode = ParseValueMode); + Init *ParseValue(Record *CurRec, RecTy *ItemType = 0, + IDParseMode Mode = ParseValueMode); std::vector<Init*> ParseValueList(Record *CurRec, Record *ArgsRec = 0, RecTy *EltTy = 0); std::vector<std::pair<llvm::Init*, std::string> > ParseDagArgList(Record *); bool ParseOptionalRangeList(std::vector<unsigned> &Ranges); |