Dmitri Gribenko | e1ebedf | 2013-01-31 23:31:14 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // Define command classes. |
| 3 | //===----------------------------------------------------------------------===// |
| 4 | |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 5 | class Command<string name> { |
| 6 | string Name = name; |
| 7 | string EndCommandName = ""; |
| 8 | |
| 9 | int NumArgs = 0; |
| 10 | |
| 11 | bit IsInlineCommand = 0; |
| 12 | |
| 13 | bit IsBlockCommand = 0; |
| 14 | bit IsBriefCommand = 0; |
| 15 | bit IsReturnsCommand = 0; |
| 16 | bit IsParamCommand = 0; |
| 17 | bit IsTParamCommand = 0; |
Dmitri Gribenko | f6785e3 | 2013-11-12 22:16:08 +0000 | [diff] [blame] | 18 | bit IsThrowsCommand = 0; |
Dmitri Gribenko | 0bd9838 | 2012-09-22 21:47:50 +0000 | [diff] [blame] | 19 | bit IsDeprecatedCommand = 0; |
Fariborz Jahanian | f843a58 | 2013-01-31 23:12:39 +0000 | [diff] [blame] | 20 | bit IsHeaderfileCommand = 0; |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 21 | |
Dmitri Gribenko | abcf0dc | 2012-09-13 20:36:01 +0000 | [diff] [blame] | 22 | bit IsEmptyParagraphAllowed = 0; |
| 23 | |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 24 | bit IsVerbatimBlockCommand = 0; |
| 25 | bit IsVerbatimBlockEndCommand = 0; |
| 26 | bit IsVerbatimLineCommand = 0; |
| 27 | bit IsDeclarationCommand = 0; |
Fariborz Jahanian | 2a268f2 | 2013-03-05 01:05:07 +0000 | [diff] [blame] | 28 | bit IsFunctionDeclarationCommand = 0; |
Fariborz Jahanian | b421b56 | 2013-03-08 23:59:23 +0000 | [diff] [blame] | 29 | bit IsRecordLikeDetailCommand = 0; |
| 30 | bit IsRecordLikeDeclarationCommand = 0; |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | class InlineCommand<string name> : Command<name> { |
| 34 | let IsInlineCommand = 1; |
| 35 | } |
| 36 | |
| 37 | class BlockCommand<string name> : Command<name> { |
| 38 | let IsBlockCommand = 1; |
| 39 | } |
| 40 | |
Fariborz Jahanian | b421b56 | 2013-03-08 23:59:23 +0000 | [diff] [blame] | 41 | class RecordLikeDetailCommand<string name> : BlockCommand<name> { |
| 42 | let IsRecordLikeDetailCommand = 1; |
| 43 | } |
| 44 | |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 45 | class VerbatimBlockCommand<string name> : Command<name> { |
| 46 | let EndCommandName = name; |
| 47 | let IsVerbatimBlockCommand = 1; |
| 48 | } |
| 49 | |
| 50 | multiclass VerbatimBlockCommand<string name, string endCommandName> { |
| 51 | def Begin : Command<name> { |
| 52 | let EndCommandName = endCommandName; |
| 53 | let IsVerbatimBlockCommand = 1; |
| 54 | } |
| 55 | |
| 56 | def End : Command<endCommandName> { |
| 57 | let IsVerbatimBlockEndCommand = 1; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | class VerbatimLineCommand<string name> : Command<name> { |
| 62 | let IsVerbatimLineCommand = 1; |
| 63 | } |
| 64 | |
| 65 | class DeclarationVerbatimLineCommand<string name> : |
| 66 | VerbatimLineCommand<name> { |
| 67 | let IsDeclarationCommand = 1; |
| 68 | } |
| 69 | |
Fariborz Jahanian | 2a268f2 | 2013-03-05 01:05:07 +0000 | [diff] [blame] | 70 | class FunctionDeclarationVerbatimLineCommand<string name> : |
Dmitri Gribenko | d09615f | 2013-04-15 02:31:50 +0000 | [diff] [blame] | 71 | DeclarationVerbatimLineCommand<name> { |
Fariborz Jahanian | 2a268f2 | 2013-03-05 01:05:07 +0000 | [diff] [blame] | 72 | let IsFunctionDeclarationCommand = 1; |
| 73 | } |
| 74 | |
Fariborz Jahanian | b421b56 | 2013-03-08 23:59:23 +0000 | [diff] [blame] | 75 | class RecordLikeDeclarationVerbatimLineCommand<string name> : |
Dmitri Gribenko | d09615f | 2013-04-15 02:31:50 +0000 | [diff] [blame] | 76 | DeclarationVerbatimLineCommand<name> { |
Fariborz Jahanian | b421b56 | 2013-03-08 23:59:23 +0000 | [diff] [blame] | 77 | let IsRecordLikeDeclarationCommand = 1; |
Fariborz Jahanian | 28c1cd2 | 2013-03-07 23:33:11 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Dmitri Gribenko | e1ebedf | 2013-01-31 23:31:14 +0000 | [diff] [blame] | 80 | //===----------------------------------------------------------------------===// |
| 81 | // InlineCommand |
| 82 | //===----------------------------------------------------------------------===// |
| 83 | |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 84 | def B : InlineCommand<"b">; |
| 85 | def C : InlineCommand<"c">; |
| 86 | def P : InlineCommand<"p">; |
| 87 | def A : InlineCommand<"a">; |
| 88 | def E : InlineCommand<"e">; |
| 89 | def Em : InlineCommand<"em">; |
| 90 | |
Dmitri Gribenko | e1ebedf | 2013-01-31 23:31:14 +0000 | [diff] [blame] | 91 | //===----------------------------------------------------------------------===// |
| 92 | // BlockCommand |
| 93 | //===----------------------------------------------------------------------===// |
| 94 | |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 95 | def Brief : BlockCommand<"brief"> { let IsBriefCommand = 1; } |
| 96 | def Short : BlockCommand<"short"> { let IsBriefCommand = 1; } |
| 97 | |
Dmitri Gribenko | af01bed | 2013-02-01 20:23:57 +0000 | [diff] [blame] | 98 | // Opposite of \brief, it is the default in our implementation. |
| 99 | def Details : BlockCommand<"details">; |
| 100 | |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 101 | def Returns : BlockCommand<"returns"> { let IsReturnsCommand = 1; } |
| 102 | def Return : BlockCommand<"return"> { let IsReturnsCommand = 1; } |
| 103 | def Result : BlockCommand<"result"> { let IsReturnsCommand = 1; } |
| 104 | |
| 105 | def Param : BlockCommand<"param"> { let IsParamCommand = 1; } |
| 106 | |
Dmitri Gribenko | e1ebedf | 2013-01-31 23:31:14 +0000 | [diff] [blame] | 107 | // Doxygen command for template parameter documentation. |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 108 | def Tparam : BlockCommand<"tparam"> { let IsTParamCommand = 1; } |
| 109 | |
Dmitri Gribenko | e1ebedf | 2013-01-31 23:31:14 +0000 | [diff] [blame] | 110 | // HeaderDoc command for template parameter documentation. |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 111 | def Templatefield : BlockCommand<"templatefield"> { let IsTParamCommand = 1; } |
| 112 | |
Dmitri Gribenko | f6785e3 | 2013-11-12 22:16:08 +0000 | [diff] [blame] | 113 | def Throws : BlockCommand<"throws"> { let IsThrowsCommand = 1; } |
| 114 | def Throw : BlockCommand<"throw"> { let IsThrowsCommand = 1; } |
| 115 | def Exception : BlockCommand<"exception"> { let IsThrowsCommand = 1; } |
| 116 | |
Dmitri Gribenko | 0bd9838 | 2012-09-22 21:47:50 +0000 | [diff] [blame] | 117 | def Deprecated : BlockCommand<"deprecated"> { |
| 118 | let IsEmptyParagraphAllowed = 1; |
| 119 | let IsDeprecatedCommand = 1; |
| 120 | } |
Dmitri Gribenko | e1ebedf | 2013-01-31 23:31:14 +0000 | [diff] [blame] | 121 | |
Fariborz Jahanian | f843a58 | 2013-01-31 23:12:39 +0000 | [diff] [blame] | 122 | def Headerfile : BlockCommand<"headerfile"> { let IsHeaderfileCommand = 1; } |
Dmitri Gribenko | e1ebedf | 2013-01-31 23:31:14 +0000 | [diff] [blame] | 123 | |
| 124 | // We don't do any additional semantic analysis for the following |
| 125 | // BlockCommands. It might be a good idea to do something extra for them, but |
| 126 | // for now we model them as plain BlockCommands. |
Fariborz Jahanian | 75dbdfa | 2013-04-10 23:10:42 +0000 | [diff] [blame] | 127 | def Arg : BlockCommand<"arg">; |
Fariborz Jahanian | 9db0fe9 | 2013-02-26 22:12:16 +0000 | [diff] [blame] | 128 | def Attention : BlockCommand<"attention">; |
Dmitri Gribenko | 0841a07 | 2012-09-12 17:02:40 +0000 | [diff] [blame] | 129 | def Author : BlockCommand<"author">; |
| 130 | def Authors : BlockCommand<"authors">; |
| 131 | def Bug : BlockCommand<"bug">; |
| 132 | def Copyright : BlockCommand<"copyright">; |
| 133 | def Date : BlockCommand<"date">; |
Dmitri Gribenko | 388a594 | 2012-09-14 15:37:29 +0000 | [diff] [blame] | 134 | def Invariant : BlockCommand<"invariant">; |
Fariborz Jahanian | 75dbdfa | 2013-04-10 23:10:42 +0000 | [diff] [blame] | 135 | def Li : BlockCommand<"li">; |
Dmitri Gribenko | 0841a07 | 2012-09-12 17:02:40 +0000 | [diff] [blame] | 136 | def Note : BlockCommand<"note">; |
Fariborz Jahanian | 4d6bc18 | 2013-04-18 16:45:57 +0000 | [diff] [blame] | 137 | def Par : BlockCommand<"par">; |
Dmitri Gribenko | 0841a07 | 2012-09-12 17:02:40 +0000 | [diff] [blame] | 138 | def Post : BlockCommand<"post">; |
| 139 | def Pre : BlockCommand<"pre">; |
| 140 | def Remark : BlockCommand<"remark">; |
| 141 | def Remarks : BlockCommand<"remarks">; |
Stephan Bergmann | 3c19a89 | 2019-08-20 08:36:21 +0000 | [diff] [blame] | 142 | def Retval : BlockCommand<"retval">; |
Dmitri Gribenko | 0841a07 | 2012-09-12 17:02:40 +0000 | [diff] [blame] | 143 | def Sa : BlockCommand<"sa">; |
| 144 | def See : BlockCommand<"see">; |
| 145 | def Since : BlockCommand<"since">; |
| 146 | def Todo : BlockCommand<"todo">; |
| 147 | def Version : BlockCommand<"version">; |
| 148 | def Warning : BlockCommand<"warning">; |
Fariborz Jahanian | b421b56 | 2013-03-08 23:59:23 +0000 | [diff] [blame] | 149 | // HeaderDoc commands |
Dmitri Gribenko | 122064b | 2013-11-19 19:18:54 +0000 | [diff] [blame] | 150 | def Abstract : BlockCommand<"abstract"> { let IsBriefCommand = 1; } |
Fariborz Jahanian | b421b56 | 2013-03-08 23:59:23 +0000 | [diff] [blame] | 151 | def ClassDesign : RecordLikeDetailCommand<"classdesign">; |
| 152 | def CoClass : RecordLikeDetailCommand<"coclass">; |
| 153 | def Dependency : RecordLikeDetailCommand<"dependency">; |
Fariborz Jahanian | 5238e40 | 2013-04-05 19:40:53 +0000 | [diff] [blame] | 154 | def Discussion : BlockCommand<"discussion">; |
Fariborz Jahanian | b421b56 | 2013-03-08 23:59:23 +0000 | [diff] [blame] | 155 | def Helper : RecordLikeDetailCommand<"helper">; |
| 156 | def HelperClass : RecordLikeDetailCommand<"helperclass">; |
| 157 | def Helps : RecordLikeDetailCommand<"helps">; |
| 158 | def InstanceSize : RecordLikeDetailCommand<"instancesize">; |
| 159 | def Ownership : RecordLikeDetailCommand<"ownership">; |
| 160 | def Performance : RecordLikeDetailCommand<"performance">; |
| 161 | def Security : RecordLikeDetailCommand<"security">; |
Fariborz Jahanian | 1bd077b | 2013-04-08 19:14:15 +0000 | [diff] [blame] | 162 | def SeeAlso : BlockCommand<"seealso">; |
Fariborz Jahanian | b421b56 | 2013-03-08 23:59:23 +0000 | [diff] [blame] | 163 | def SuperClass : RecordLikeDetailCommand<"superclass">; |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 164 | |
Dmitri Gribenko | e1ebedf | 2013-01-31 23:31:14 +0000 | [diff] [blame] | 165 | //===----------------------------------------------------------------------===// |
| 166 | // VerbatimBlockCommand |
| 167 | //===----------------------------------------------------------------------===// |
| 168 | |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 169 | defm Code : VerbatimBlockCommand<"code", "endcode">; |
| 170 | defm Verbatim : VerbatimBlockCommand<"verbatim", "endverbatim">; |
| 171 | defm Htmlonly : VerbatimBlockCommand<"htmlonly", "endhtmlonly">; |
| 172 | defm Latexonly : VerbatimBlockCommand<"latexonly", "endlatexonly">; |
| 173 | defm Xmlonly : VerbatimBlockCommand<"xmlonly", "endxmlonly">; |
| 174 | defm Manonly : VerbatimBlockCommand<"manonly", "endmanonly">; |
| 175 | defm Rtfonly : VerbatimBlockCommand<"rtfonly", "endrtfonly">; |
| 176 | |
| 177 | defm Dot : VerbatimBlockCommand<"dot", "enddot">; |
| 178 | defm Msc : VerbatimBlockCommand<"msc", "endmsc">; |
| 179 | |
Dmitri Gribenko | e1ebedf | 2013-01-31 23:31:14 +0000 | [diff] [blame] | 180 | // These three commands have special support in CommentLexer to recognize their |
| 181 | // names. |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 182 | def FDollar : VerbatimBlockCommand<"f$">; // Inline LaTeX formula |
| 183 | defm FBracket : VerbatimBlockCommand<"f[", "f]">; // Displayed LaTeX formula |
| 184 | defm FBrace : VerbatimBlockCommand<"f{", "f}">; // LaTeX environment |
| 185 | |
Fariborz Jahanian | 5238e40 | 2013-04-05 19:40:53 +0000 | [diff] [blame] | 186 | // HeaderDoc commands |
| 187 | defm Textblock : VerbatimBlockCommand<"textblock", "/textblock">; |
Fariborz Jahanian | cac9ee0 | 2013-04-08 18:53:25 +0000 | [diff] [blame] | 188 | defm Link : VerbatimBlockCommand<"link", "/link">; |
Fariborz Jahanian | 5238e40 | 2013-04-05 19:40:53 +0000 | [diff] [blame] | 189 | |
Dmitri Gribenko | e1ebedf | 2013-01-31 23:31:14 +0000 | [diff] [blame] | 190 | //===----------------------------------------------------------------------===// |
| 191 | // VerbatimLineCommand |
| 192 | //===----------------------------------------------------------------------===// |
| 193 | |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 194 | def Defgroup : VerbatimLineCommand<"defgroup">; |
| 195 | def Ingroup : VerbatimLineCommand<"ingroup">; |
| 196 | def Addtogroup : VerbatimLineCommand<"addtogroup">; |
| 197 | def Weakgroup : VerbatimLineCommand<"weakgroup">; |
| 198 | def Name : VerbatimLineCommand<"name">; |
| 199 | |
| 200 | def Section : VerbatimLineCommand<"section">; |
| 201 | def Subsection : VerbatimLineCommand<"subsection">; |
| 202 | def Subsubsection : VerbatimLineCommand<"subsubsection">; |
| 203 | def Paragraph : VerbatimLineCommand<"paragraph">; |
| 204 | |
| 205 | def Mainpage : VerbatimLineCommand<"mainpage">; |
| 206 | def Subpage : VerbatimLineCommand<"subpage">; |
| 207 | def Ref : VerbatimLineCommand<"ref">; |
| 208 | |
Dmitri Gribenko | 6969e43 | 2013-06-23 23:33:14 +0000 | [diff] [blame] | 209 | def Relates : VerbatimLineCommand<"relates">; |
| 210 | def Related : VerbatimLineCommand<"related">; |
| 211 | def RelatesAlso : VerbatimLineCommand<"relatesalso">; |
| 212 | def RelatedAlso : VerbatimLineCommand<"relatedalso">; |
| 213 | |
Dmitri Gribenko | e1ebedf | 2013-01-31 23:31:14 +0000 | [diff] [blame] | 214 | //===----------------------------------------------------------------------===// |
| 215 | // DeclarationVerbatimLineCommand |
| 216 | //===----------------------------------------------------------------------===// |
| 217 | |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 218 | // Doxygen commands. |
Dmitri Gribenko | c31fbe3 | 2013-11-09 03:50:37 +0000 | [diff] [blame] | 219 | def Def : DeclarationVerbatimLineCommand<"def">; |
Dmitri Gribenko | 19ec962 | 2012-09-15 21:33:50 +0000 | [diff] [blame] | 220 | def Fn : DeclarationVerbatimLineCommand<"fn">; |
| 221 | def Namespace : DeclarationVerbatimLineCommand<"namespace">; |
| 222 | def Overload : DeclarationVerbatimLineCommand<"overload">; |
| 223 | def Property : DeclarationVerbatimLineCommand<"property">; |
| 224 | def Typedef : DeclarationVerbatimLineCommand<"typedef">; |
| 225 | def Var : DeclarationVerbatimLineCommand<"var">; |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 226 | |
| 227 | // HeaderDoc commands. |
Fariborz Jahanian | b421b56 | 2013-03-08 23:59:23 +0000 | [diff] [blame] | 228 | def Class : RecordLikeDeclarationVerbatimLineCommand<"class">; |
| 229 | def Interface : RecordLikeDeclarationVerbatimLineCommand<"interface">; |
| 230 | def Protocol : RecordLikeDeclarationVerbatimLineCommand<"protocol">; |
| 231 | def Struct : RecordLikeDeclarationVerbatimLineCommand<"struct">; |
| 232 | def Union : RecordLikeDeclarationVerbatimLineCommand<"union">; |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 233 | def Category : DeclarationVerbatimLineCommand<"category">; |
| 234 | def Template : DeclarationVerbatimLineCommand<"template">; |
Fariborz Jahanian | 2a268f2 | 2013-03-05 01:05:07 +0000 | [diff] [blame] | 235 | def Function : FunctionDeclarationVerbatimLineCommand<"function">; |
Fariborz Jahanian | 2aa5cf4 | 2013-03-18 23:45:52 +0000 | [diff] [blame] | 236 | def FunctionGroup : FunctionDeclarationVerbatimLineCommand<"functiongroup">; |
Fariborz Jahanian | bca9788 | 2013-03-05 19:40:47 +0000 | [diff] [blame] | 237 | def Method : FunctionDeclarationVerbatimLineCommand<"method">; |
Fariborz Jahanian | 2aa5cf4 | 2013-03-18 23:45:52 +0000 | [diff] [blame] | 238 | def MethodGroup : FunctionDeclarationVerbatimLineCommand<"methodgroup">; |
Fariborz Jahanian | bca9788 | 2013-03-05 19:40:47 +0000 | [diff] [blame] | 239 | def Callback : FunctionDeclarationVerbatimLineCommand<"callback">; |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 240 | def Const : DeclarationVerbatimLineCommand<"const">; |
| 241 | def Constant : DeclarationVerbatimLineCommand<"constant">; |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 242 | def Enum : DeclarationVerbatimLineCommand<"enum">; |