| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | #include "TableGenBackends.h" |
| 15 | #include "llvm/TableGen/Record.h" |
| 16 | #include "llvm/TableGen/StringMatcher.h" |
| 17 | #include "llvm/TableGen/TableGenBackend.h" |
| 18 | #include <vector> |
| 19 | |
| 20 | using namespace llvm; |
| 21 | |
| 22 | void clang::(RecordKeeper &Records, raw_ostream &OS) { |
| 23 | std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Tag"); |
| 24 | std::vector<StringMatcher::StringPair> Matches; |
| 25 | for (Record *Tag : Tags) { |
| 26 | Matches.emplace_back(Tag->getValueAsString("Spelling"), "return true;"); |
| 27 | } |
| 28 | |
| 29 | emitSourceFileHeader("HTML tag name matcher", OS); |
| 30 | |
| 31 | OS << "bool isHTMLTagName(StringRef Name) {\n"; |
| 32 | StringMatcher("Name", Matches, OS).Emit(); |
| 33 | OS << " return false;\n" |
| 34 | << "}\n\n"; |
| 35 | } |
| 36 | |
| 37 | void clang::(RecordKeeper &Records, |
| 38 | raw_ostream &OS) { |
| 39 | std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Tag"); |
| 40 | std::vector<StringMatcher::StringPair> MatchesEndTagOptional; |
| 41 | std::vector<StringMatcher::StringPair> MatchesEndTagForbidden; |
| 42 | for (Record *Tag : Tags) { |
| 43 | std::string Spelling = Tag->getValueAsString("Spelling"); |
| 44 | StringMatcher::StringPair Match(Spelling, "return true;"); |
| 45 | if (Tag->getValueAsBit("EndTagOptional")) |
| 46 | MatchesEndTagOptional.push_back(Match); |
| 47 | if (Tag->getValueAsBit("EndTagForbidden")) |
| 48 | MatchesEndTagForbidden.push_back(Match); |
| 49 | } |
| 50 | |
| 51 | emitSourceFileHeader("HTML tag properties", OS); |
| 52 | |
| 53 | OS << "bool isHTMLEndTagOptional(StringRef Name) {\n"; |
| 54 | StringMatcher("Name", MatchesEndTagOptional, OS).Emit(); |
| 55 | OS << " return false;\n" |
| 56 | << "}\n\n"; |
| 57 | |
| 58 | OS << "bool isHTMLEndTagForbidden(StringRef Name) {\n"; |
| 59 | StringMatcher("Name", MatchesEndTagForbidden, OS).Emit(); |
| 60 | OS << " return false;\n" |
| 61 | << "}\n\n"; |
| 62 | } |
| 63 | |
| 64 | |