cpp.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!-- ==========================================================================\
  3. |
  4. | To learn how to make your own language parser, please check the following
  5. | link:
  6. | https://npp-user-manual.org/docs/function-list/
  7. |
  8. \=========================================================================== -->
  9. <NotepadPlus>
  10. <functionList>
  11. <!-- ========================================================= [ C++ ] -->
  12. <parser
  13. displayName="C++"
  14. id ="cplusplus_syntax"
  15. commentExpr="(?s:/\*.*?\*/)|(?m-s://.*?$)"
  16. >
  17. <classRange
  18. mainExpr="(?x) # use inline comments
  19. ^[\t\x20]* # leading whitespace
  20. (template\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  21. (class|struct) # class/struct definition keyword
  22. [\t\x20]+ # following whitespace
  23. ((\w+|\[\[[^\r\n]*\]\])[\t\x20]+)* # type attributes
  24. (
  25. \w+ # namespace identifier
  26. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  27. \s*::\s* # namespace separator
  28. )*
  29. \w+ # class/struct identifier
  30. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  31. (\s*final\s*)? # final specifier
  32. (
  33. \s*:\s* # inheritance separator
  34. ((private|protected|public|virtual)\s+)* # visibility/virtual specifier
  35. (
  36. \w+ # namespace identifier
  37. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  38. \s*::\s* # namespace separator
  39. )*
  40. \w+ # parent class/struct identifier
  41. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  42. (
  43. \s*,\s* # multiple inheritance separator
  44. ((private|protected|public|virtual)\s+)* # visibility/virtual specifier
  45. (
  46. \w+ # namespace identifier
  47. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  48. \s*::\s* # namespace separator
  49. )*
  50. \w+ # parent class/struct identifier
  51. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  52. )*
  53. )?
  54. \s* # trailing whitespace
  55. \{ # class/struct body
  56. "
  57. openSymbole ="\{"
  58. closeSymbole="\}"
  59. >
  60. <className>
  61. <nameExpr
  62. expr="(?x) # use inline comments
  63. (class|struct) # class/struct definition keyword
  64. [\t\x20]+ # following whitespace
  65. ((\w+|\[\[[^\r\n]*\]\])[\t\x20]+)* # type attributes
  66. (\w+\s*::\s*)* # namespace specifier
  67. \w+ # class/struct identifier
  68. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  69. (\s*final\s*)? # final specifier
  70. \s* # trailing whitespace
  71. (:\s*\w+|\{) # inheritance separator | class/struct body
  72. "
  73. />
  74. <nameExpr
  75. expr="(?x) # use inline comments
  76. (\w+\s*::\s*)* # namespace specifier
  77. \w+ # class/struct identifier
  78. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  79. (\s*final\s*)? # final specifier
  80. \s* # trailing whitespace
  81. (:\s*\w+|\{) # inheritance separator | class/struct body
  82. "
  83. />
  84. <nameExpr
  85. expr="(?x) # use inline comments
  86. (\w+\s*::\s*)* # namespace specifier
  87. \w+ # class/struct identifier
  88. "
  89. />
  90. </className>
  91. <function
  92. mainExpr="(?x) # use inline comments
  93. ^[\t\x20]* # leading whitespace
  94. (template\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  95. ((consteval|constexpr|explicit|friend|inline|static|virtual)\s+)* # left function definition keywords
  96. (
  97. ( # conversion operator definition
  98. (
  99. \w+ # namespace identifier
  100. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  101. \s*::\s* # namespace separator
  102. )*
  103. operator\s+ # operator keyword
  104. ((const|long|signed|unsigned|volatile)\s+)* # type definition keyword
  105. ( # operator type definition
  106. (
  107. \w+ # namespace identifier
  108. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  109. \s*::\s* # namespace separator
  110. )*
  111. \w+ # operator type identifier
  112. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  113. )*
  114. (\s*(\*|\*\*|&amp;)\s*)? # type pointer/reference
  115. )
  116. | (
  117. ((const|long|signed|unsigned|volatile)\s+)* # type definition keyword
  118. ( # return type definition
  119. (
  120. \w+ # namespace identifier
  121. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  122. \s*::\s* # namespace separator
  123. )*
  124. \w+ # return type identifier
  125. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  126. )
  127. ( # type pointer/reference
  128. \s+
  129. | (\*|\*\*|&amp;)\s+
  130. | \s+(\*|\*\*|&amp;)
  131. | \s+(\*|\*\*|&amp;)\s+
  132. )
  133. (
  134. \w+ # namespace identifier
  135. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  136. \s*::\s* # namespace separator
  137. )*
  138. (
  139. ( # function definition
  140. (?!(if|while|for|switch)\s*\() # exclude block/loop definition
  141. \w+ # function identifier
  142. )
  143. | ( # operator definition
  144. operator\(\) # parenthesis operator
  145. | operator # operator keyword
  146. [\[\]\*\=\+\-\~\|\^%!,&amp;&lt;&gt;]+ # operator symbol
  147. )
  148. )
  149. )
  150. )
  151. \s* # following whitespace
  152. \(
  153. [^\)\(]* # function parameters
  154. (\([^\)\(]*\)[^\)\(]*)* # functors as parameter
  155. \)
  156. (\s*(const|final|noexcept|override|volatile)\s*)* # right function definition keywords
  157. \s* # trailing whitespace
  158. \{ # function body
  159. "
  160. >
  161. <functionName>
  162. <funcNameExpr
  163. expr="(?x) # use inline comments
  164. (
  165. operator\(\) # parenthesis operator
  166. | operator # operator keyword
  167. [\w\t\x20\[\]\*\=\+\-\~\|\^%!,&amp;&lt;&gt;]+ # operator symbol | conversion operator
  168. | (?!(if|while|for|switch)\s*\() # exclude block/loop definition
  169. \w+ # function identifier
  170. )
  171. \s* # following whitespace
  172. \( # function parameters
  173. "
  174. />
  175. <funcNameExpr
  176. expr="(?x) # use inline comments
  177. (
  178. operator\(\) # parenthesis operator
  179. | operator # operator keyword
  180. [\w\t\x20\[\]\*\=\+\-\~\|\^%!,&amp;&lt;&gt;]+ # operator symbol | conversion operator
  181. | (?!(if|while|for|switch)\s*\() # exclude block/loop definition
  182. \w+ # function identifier
  183. )
  184. "
  185. />
  186. </functionName>
  187. </function>
  188. </classRange>
  189. <function
  190. mainExpr="(?x) # use inline comments
  191. ^[\t\x20]* # leading whitespace
  192. (template\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  193. ((consteval|constexpr|explicit|friend|inline|static|virtual)\s+)* # left function definition keywords
  194. (
  195. ( # conversion operator definition
  196. (
  197. \w+ # namespace identifier
  198. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  199. \s*::\s* # namespace separator
  200. )*
  201. operator\s+ # operator keyword
  202. ((const|long|signed|unsigned|volatile)\s+)* # type definition keyword
  203. ( # operator type definition
  204. (
  205. \w+ # namespace identifier
  206. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  207. \s*::\s* # namespace separator
  208. )*
  209. \w+ # operator type identifier
  210. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  211. )*
  212. (\s*(\*|\*\*|&amp;)\s*)? # type pointer/reference
  213. )
  214. | (
  215. ((const|long|signed|unsigned|volatile)\s+)* # type definition keyword
  216. ( # return type definition
  217. (
  218. \w+ # namespace identifier
  219. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  220. \s*::\s* # namespace separator
  221. )*
  222. \w+ # return type identifier
  223. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  224. )
  225. ( # type pointer/reference
  226. \s+
  227. | (\*|\*\*|&amp;)\s+
  228. | \s+(\*|\*\*|&amp;)
  229. | \s+(\*|\*\*|&amp;)\s+
  230. )
  231. (
  232. \w+ # namespace identifier
  233. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,&lt;&gt;]*\s*&gt;\s*)? # template parameters
  234. \s*::\s* # namespace separator
  235. )*
  236. (
  237. ( # function definition
  238. (?!(if|while|for|switch)\s*\() # exclude block/loop definition
  239. \w+ # function identifier
  240. )
  241. | ( # operator definition
  242. operator\(\) # operator parenthesis
  243. | operator # operator keyword
  244. [\[\]\*\=\+\-\~\|\^%!,&amp;&lt;&gt;]+ # operator symbol
  245. )
  246. )
  247. )
  248. )
  249. \s* # following whitespace
  250. \(
  251. [^\)\(]* # function parameters
  252. (\([^\)\(]*\)[^\)\(]*)* # functors as parameter
  253. \)
  254. (\s*(const|final|noexcept|override|volatile)\s*)* # right function definition keywords
  255. \s* # trailing whitespace
  256. \{ # function body
  257. "
  258. >
  259. <functionName>
  260. <nameExpr
  261. expr="(?x) # use inline comments
  262. (
  263. operator\(\) # parenthesis operator
  264. | operator # operator keyword
  265. [\w\t\x20\[\]\*\=\+\-\~\|\^%!,&amp;&lt;&gt;]+ # operator symbol | conversion operator
  266. | (?!(if|while|for|switch)\s*\() # exclude block/loop definition
  267. \w+ # function identifier
  268. )
  269. \s* # following whitespace
  270. \( # function parameters
  271. "
  272. />
  273. <nameExpr
  274. expr="(?x) # use inline comments
  275. (
  276. operator\(\) # parenthesis operator
  277. | operator # operator keyword
  278. [\w\t\x20\[\]\*\=\+\-\~\|\^%!,&amp;&lt;&gt;]+ # operator symbol | conversion operator
  279. | (?!(if|while|for|switch)\s*\() # exclude block/loop definition
  280. \w+ # function identifier
  281. )
  282. "
  283. />
  284. </functionName>
  285. <className>
  286. <nameExpr expr="(?x) # use inline comments
  287. \w+ # namespace identifier
  288. (?=
  289. (\s*&lt;\s*[\w\t\x20\(\)\=\.:,]*\s*&gt;\s*)? # template parameters
  290. \s*::\s* # namespace separator
  291. (
  292. operator\(\) # parenthesis operator
  293. | operator # operator keyword
  294. [\w\t\x20\[\]\*\=\+\-\~\|\^%!,&amp;&lt;&gt;]+ # operator symbol | conversion operator
  295. | \w+ # function identifier
  296. )
  297. \( # function parameters
  298. )
  299. " />
  300. </className>
  301. </function>
  302. </parser>
  303. </functionList>
  304. </NotepadPlus>