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