CommentCommands.td 14 KB

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