xref: /freebsd/contrib/llvm-project/clang/include/clang/AST/CommentCommands.td (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1//===----------------------------------------------------------------------===//
2// Define command classes.
3//===----------------------------------------------------------------------===//
4
5class 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;
18  bit IsThrowsCommand = 0;
19  bit IsDeprecatedCommand = 0;
20  bit IsHeaderfileCommand = 0;
21  bit IsParCommand = 0;
22
23  bit IsEmptyParagraphAllowed = 0;
24
25  bit IsVerbatimBlockCommand = 0;
26  bit IsVerbatimBlockEndCommand = 0;
27  bit IsVerbatimLineCommand = 0;
28  bit IsDeclarationCommand = 0;
29  bit IsFunctionDeclarationCommand = 0;
30  bit IsRecordLikeDetailCommand = 0;
31  bit IsRecordLikeDeclarationCommand = 0;
32}
33
34class InlineCommand<string name> : Command<name> {
35  let NumArgs = 1;
36  let IsInlineCommand = 1;
37}
38
39class BlockCommand<string name> : Command<name> {
40  let IsBlockCommand = 1;
41}
42
43class RecordLikeDetailCommand<string name> : BlockCommand<name> {
44  let IsRecordLikeDetailCommand = 1;
45}
46
47class VerbatimBlockCommand<string name> : Command<name> {
48  let EndCommandName = name;
49  let IsVerbatimBlockCommand = 1;
50}
51
52multiclass VerbatimBlockCommand<string name, string endCommandName> {
53  def Begin : Command<name> {
54    let EndCommandName = endCommandName;
55    let IsVerbatimBlockCommand = 1;
56  }
57
58  def End : Command<endCommandName> {
59    let IsVerbatimBlockEndCommand = 1;
60  }
61}
62
63class VerbatimLineCommand<string name> : Command<name> {
64  let IsVerbatimLineCommand = 1;
65}
66
67class PropertyCommand<string name> : Command<name> {
68  let NumArgs = 0;
69  let IsInlineCommand = 1;
70}
71
72class DeclarationVerbatimLineCommand<string name> :
73      VerbatimLineCommand<name> {
74  let IsDeclarationCommand = 1;
75}
76
77class FunctionDeclarationVerbatimLineCommand<string name> :
78      DeclarationVerbatimLineCommand<name> {
79  let IsFunctionDeclarationCommand = 1;
80}
81
82class RecordLikeDeclarationVerbatimLineCommand<string name> :
83      DeclarationVerbatimLineCommand<name> {
84  let IsRecordLikeDeclarationCommand = 1;
85}
86
87//===----------------------------------------------------------------------===//
88// InlineCommand
89//===----------------------------------------------------------------------===//
90
91def B      : InlineCommand<"b">;
92def C      : InlineCommand<"c">;
93def P      : InlineCommand<"p">;
94def A      : InlineCommand<"a">;
95def E      : InlineCommand<"e">;
96def N      : InlineCommand<"n"> { let NumArgs = 0; }
97def Em     : InlineCommand<"em">;
98def Emoji  : InlineCommand<"emoji">;
99
100def Anchor  : InlineCommand<"anchor">;
101def Ref     : InlineCommand<"ref">;
102def RefItem : InlineCommand<"refitem">;
103def Cite    : InlineCommand<"cite">;
104
105def CopyBrief   : InlineCommand<"copybrief">;
106def CopyDetails : InlineCommand<"copydetails">;
107def CopyDoc     : InlineCommand<"copydoc">;
108
109// Typically not used inline, but they take a single word.
110def Extends    : InlineCommand<"extends">;
111def Implements : InlineCommand<"implements">;
112def MemberOf   : InlineCommand<"memberof">;
113
114//===----------------------------------------------------------------------===//
115// BlockCommand
116//===----------------------------------------------------------------------===//
117
118def Brief : BlockCommand<"brief"> { let IsBriefCommand = 1; }
119def Short : BlockCommand<"short"> { let IsBriefCommand = 1; }
120
121// Opposite of \brief, it is the default in our implementation.
122def Details : BlockCommand<"details">;
123
124def Returns : BlockCommand<"returns"> { let IsReturnsCommand = 1; }
125def Return  : BlockCommand<"return"> { let IsReturnsCommand = 1; }
126def Result  : BlockCommand<"result"> { let IsReturnsCommand = 1; }
127
128def Param : BlockCommand<"param"> { let IsParamCommand = 1; }
129
130// Doxygen command for template parameter documentation.
131def Tparam : BlockCommand<"tparam"> { let IsTParamCommand = 1; }
132
133// HeaderDoc command for template parameter documentation.
134def Templatefield : BlockCommand<"templatefield"> { let IsTParamCommand = 1; }
135
136def Throws    : BlockCommand<"throws"> { let IsThrowsCommand = 1; let NumArgs = 1; }
137def Throw     : BlockCommand<"throw"> { let IsThrowsCommand = 1; let NumArgs = 1; }
138def Exception : BlockCommand<"exception"> { let IsThrowsCommand = 1; let NumArgs = 1;}
139
140def Deprecated : BlockCommand<"deprecated"> {
141  let IsEmptyParagraphAllowed = 1;
142  let IsDeprecatedCommand = 1;
143}
144
145def Headerfile : BlockCommand<"headerfile"> { let IsHeaderfileCommand = 1; }
146
147// We don't do any additional semantic analysis for the following
148// BlockCommands.  It might be a good idea to do something extra for them, but
149// for now we model them as plain BlockCommands.
150def Arg        : BlockCommand<"arg">;
151def Attention  : BlockCommand<"attention">;
152def Author     : BlockCommand<"author">;
153def Authors    : BlockCommand<"authors">;
154def Bug        : BlockCommand<"bug">;
155def Copyright  : BlockCommand<"copyright">;
156def Date       : BlockCommand<"date">;
157def Invariant  : BlockCommand<"invariant">;
158def Li         : BlockCommand<"li">;
159def Note       : BlockCommand<"note">;
160def Par        : BlockCommand<"par"> { let IsParCommand = 1; let NumArgs = 1; }
161def Post       : BlockCommand<"post">;
162def Pre        : BlockCommand<"pre">;
163def Remark     : BlockCommand<"remark">;
164def Remarks    : BlockCommand<"remarks">;
165def Retval     : BlockCommand<"retval"> { let NumArgs = 1; }
166def Sa         : BlockCommand<"sa">;
167def See        : BlockCommand<"see">;
168def Since      : BlockCommand<"since">;
169def Test       : BlockCommand<"test">;
170def Todo       : BlockCommand<"todo">;
171def Version    : BlockCommand<"version">;
172def Warning    : BlockCommand<"warning">;
173def XRefItem   : BlockCommand<"xrefitem"> { let NumArgs = 3; }
174// HeaderDoc commands
175def Abstract      : BlockCommand<"abstract"> { let IsBriefCommand = 1; }
176def ClassDesign   : RecordLikeDetailCommand<"classdesign">;
177def CoClass       : RecordLikeDetailCommand<"coclass">;
178def Dependency    : RecordLikeDetailCommand<"dependency">;
179def Discussion    : BlockCommand<"discussion">;
180def Helper        : RecordLikeDetailCommand<"helper">;
181def HelperClass   : RecordLikeDetailCommand<"helperclass">;
182def Helps         : RecordLikeDetailCommand<"helps">;
183def InstanceSize  : RecordLikeDetailCommand<"instancesize">;
184def Ownership     : RecordLikeDetailCommand<"ownership">;
185def Performance   : RecordLikeDetailCommand<"performance">;
186def Security      : RecordLikeDetailCommand<"security">;
187def SeeAlso       : BlockCommand<"seealso">;
188def SuperClass    : RecordLikeDetailCommand<"superclass">;
189
190//===----------------------------------------------------------------------===//
191// VerbatimBlockCommand
192//===----------------------------------------------------------------------===//
193
194defm Code      : VerbatimBlockCommand<"code", "endcode">;
195defm Verbatim  : VerbatimBlockCommand<"verbatim", "endverbatim">;
196
197defm DocbookOnly : VerbatimBlockCommand<"docbookonly", "enddocbookonly">;
198defm Htmlonly  : VerbatimBlockCommand<"htmlonly", "endhtmlonly">;
199defm Latexonly : VerbatimBlockCommand<"latexonly", "endlatexonly">;
200defm Xmlonly   : VerbatimBlockCommand<"xmlonly", "endxmlonly">;
201defm Manonly   : VerbatimBlockCommand<"manonly", "endmanonly">;
202defm Rtfonly   : VerbatimBlockCommand<"rtfonly", "endrtfonly">;
203
204defm Dot : VerbatimBlockCommand<"dot", "enddot">;
205defm Msc : VerbatimBlockCommand<"msc", "endmsc">;
206defm Uml : VerbatimBlockCommand<"startuml", "enduml">;
207
208// Actually not verbatim blocks, we should also parse commands within them.
209defm Internal   : VerbatimBlockCommand<"internal", "endinternal">;
210// TODO: conflicts with HeaderDoc link, /link.
211//defm Link       : VerbatimBlockCommand<"link", "endlink">;
212defm ParBlock   : VerbatimBlockCommand<"parblock", "endparblock">;
213defm SecRefList : VerbatimBlockCommand<"secreflist", "endsecreflist">;
214
215// These three commands have special support in CommentLexer to recognize their
216// names.
217def  FDollar  : VerbatimBlockCommand<"f$">; // Inline LaTeX formula
218defm FParen   : VerbatimBlockCommand<"f(", "f)">; // Inline LaTeX text
219defm FBracket : VerbatimBlockCommand<"f[", "f]">; // Displayed LaTeX formula
220defm FBrace   : VerbatimBlockCommand<"f{", "f}">; // LaTeX environment
221
222// HeaderDoc commands
223defm Textblock    : VerbatimBlockCommand<"textblock", "/textblock">;
224defm Link         : VerbatimBlockCommand<"link", "/link">;
225
226//===----------------------------------------------------------------------===//
227// VerbatimLineCommand
228//===----------------------------------------------------------------------===//
229
230def Defgroup   : VerbatimLineCommand<"defgroup">;
231def Ingroup    : VerbatimLineCommand<"ingroup">;
232def Addtogroup : VerbatimLineCommand<"addtogroup">;
233def Weakgroup  : VerbatimLineCommand<"weakgroup">;
234def Name       : VerbatimLineCommand<"name">;
235
236// These actually take a single word, but it's optional.
237// And they're used on a separate line typically, not inline.
238def Dir  : VerbatimLineCommand<"dir">;
239def File : VerbatimLineCommand<"file">;
240
241def Section       : VerbatimLineCommand<"section">;
242def Subsection    : VerbatimLineCommand<"subsection">;
243def Subsubsection : VerbatimLineCommand<"subsubsection">;
244def Paragraph     : VerbatimLineCommand<"paragraph">;
245def TableOfContents : VerbatimLineCommand<"tableofcontents">;
246
247def Page     : VerbatimLineCommand<"page">;
248def Mainpage : VerbatimLineCommand<"mainpage">;
249def Subpage  : VerbatimLineCommand<"subpage">;
250
251def Relates     : VerbatimLineCommand<"relates">;
252def Related     : VerbatimLineCommand<"related">;
253def RelatesAlso : VerbatimLineCommand<"relatesalso">;
254def RelatedAlso : VerbatimLineCommand<"relatedalso">;
255
256def AddIndex : VerbatimLineCommand<"addindex">;
257
258// These take a single argument mostly, but since they include a file they'll
259// typically be on their own line.
260def DocbookInclude : VerbatimLineCommand<"docbookinclude">;
261def DontInclude    : VerbatimLineCommand<"dontinclude">;
262def Example        : VerbatimLineCommand<"example">;
263def HtmlInclude    : VerbatimLineCommand<"htmlinclude">;
264def Include        : VerbatimLineCommand<"include">;
265def ManInclude     : VerbatimLineCommand<"maninclude">;
266def LatexInclude   : VerbatimLineCommand<"latexinclude">;
267def RtfInclude     : VerbatimLineCommand<"rtfinclude">;
268def Snippet        : VerbatimLineCommand<"snippet">;
269def VerbInclude    : VerbatimLineCommand<"verbinclude">;
270def XmlInclude     : VerbatimLineCommand<"xmlinclude">;
271
272def Image   : VerbatimLineCommand<"image">;
273def DotFile : VerbatimLineCommand<"dotfile">;
274def MscFile : VerbatimLineCommand<"mscfile">;
275def DiaFile : VerbatimLineCommand<"diafile">;
276
277def Line     : VerbatimLineCommand<"line">;
278def Skip     : VerbatimLineCommand<"skip">;
279def SkipLine : VerbatimLineCommand<"skipline">;
280def Until    : VerbatimLineCommand<"until">;
281
282def NoOp : VerbatimLineCommand<"noop">;
283
284// We might also build proper support for if/ifnot/else/elseif/endif.
285def If     : VerbatimLineCommand<"if">;
286def IfNot  : VerbatimLineCommand<"ifnot">;
287def Else   : VerbatimLineCommand<"else">;
288def ElseIf : VerbatimLineCommand<"elseif">;
289def Endif  : VerbatimLineCommand<"endif">;
290
291// Not treated as VerbatimBlockCommand because it spans multiple comments.
292def Cond    : VerbatimLineCommand<"cond">;
293def EndCond : VerbatimLineCommand<"endcond">;
294
295//===----------------------------------------------------------------------===//
296// PropertyCommand
297//===----------------------------------------------------------------------===//
298
299def CallGraph       : PropertyCommand<"callgraph">;
300def HideCallGraph   : PropertyCommand<"hidecallgraph">;
301def CallerGraph     : PropertyCommand<"callergraph">;
302def HideCallerGraph : PropertyCommand<"hidecallergraph">;
303def ShowInitializer : PropertyCommand<"showinitializer">;
304def HideInitializer : PropertyCommand<"hideinitializer">;
305def ShowRefBy       : PropertyCommand<"showrefby">;
306def HideRefBy       : PropertyCommand<"hiderefby">;
307def ShowRefs        : PropertyCommand<"showrefs">;
308def HideRefs        : PropertyCommand<"hiderefs">;
309
310def Private   : PropertyCommand<"private">;
311def Protected : PropertyCommand<"protected">;
312def Public    : PropertyCommand<"public">;
313def Pure      : PropertyCommand<"pure">;
314def Static    : PropertyCommand<"static">;
315
316def NoSubgrouping    : PropertyCommand<"nosubgrouping">;
317def PrivateSection   : PropertyCommand<"privatesection">;
318def ProtectedSection : PropertyCommand<"protectedsection">;
319def PublicSection    : PropertyCommand<"publicsection">;
320
321//===----------------------------------------------------------------------===//
322// DeclarationVerbatimLineCommand
323//===----------------------------------------------------------------------===//
324
325// Doxygen commands.
326def Concept   : DeclarationVerbatimLineCommand<"concept">;
327def Def       : DeclarationVerbatimLineCommand<"def">;
328def Fn        : DeclarationVerbatimLineCommand<"fn">;
329def IDLExcept : DeclarationVerbatimLineCommand<"idlexcept">;
330def Namespace : DeclarationVerbatimLineCommand<"namespace">;
331def Overload  : DeclarationVerbatimLineCommand<"overload">;
332def Property  : DeclarationVerbatimLineCommand<"property">;
333def Typedef   : DeclarationVerbatimLineCommand<"typedef">;
334def Var       : DeclarationVerbatimLineCommand<"var">;
335
336// HeaderDoc commands.
337def Class     : RecordLikeDeclarationVerbatimLineCommand<"class">;
338def Interface : RecordLikeDeclarationVerbatimLineCommand<"interface">;
339def Protocol  : RecordLikeDeclarationVerbatimLineCommand<"protocol">;
340def Struct    : RecordLikeDeclarationVerbatimLineCommand<"struct">;
341def Union     : RecordLikeDeclarationVerbatimLineCommand<"union">;
342def Category  : DeclarationVerbatimLineCommand<"category">;
343def Template  : DeclarationVerbatimLineCommand<"template">;
344def Function  : FunctionDeclarationVerbatimLineCommand<"function">;
345def FunctionGroup  : FunctionDeclarationVerbatimLineCommand<"functiongroup">;
346def Method    : FunctionDeclarationVerbatimLineCommand<"method">;
347def MethodGroup    : FunctionDeclarationVerbatimLineCommand<"methodgroup">;
348def Callback  : FunctionDeclarationVerbatimLineCommand<"callback">;
349def Const     : DeclarationVerbatimLineCommand<"const">;
350def Constant  : DeclarationVerbatimLineCommand<"constant">;
351def Enum      : DeclarationVerbatimLineCommand<"enum">;
352