dotnet.py 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. """
  2. pygments.lexers.dotnet
  3. ~~~~~~~~~~~~~~~~~~~~~~
  4. Lexers for .net languages.
  5. :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
  6. :license: BSD, see LICENSE for details.
  7. """
  8. import re
  9. from pygments.lexer import RegexLexer, DelegatingLexer, bygroups, include, \
  10. using, this, default, words
  11. from pygments.token import Punctuation, Text, Comment, Operator, Keyword, \
  12. Name, String, Number, Literal, Other, Whitespace
  13. from pygments.util import get_choice_opt
  14. from pygments import unistring as uni
  15. from pygments.lexers.html import XmlLexer
  16. __all__ = ['CSharpLexer', 'NemerleLexer', 'BooLexer', 'VbNetLexer',
  17. 'CSharpAspxLexer', 'VbNetAspxLexer', 'FSharpLexer', 'XppLexer']
  18. class CSharpLexer(RegexLexer):
  19. """
  20. For C# source code.
  21. Additional options accepted:
  22. `unicodelevel`
  23. Determines which Unicode characters this lexer allows for identifiers.
  24. The possible values are:
  25. * ``none`` -- only the ASCII letters and numbers are allowed. This
  26. is the fastest selection.
  27. * ``basic`` -- all Unicode characters from the specification except
  28. category ``Lo`` are allowed.
  29. * ``full`` -- all Unicode characters as specified in the C# specs
  30. are allowed. Note that this means a considerable slowdown since the
  31. ``Lo`` category has more than 40,000 characters in it!
  32. The default value is ``basic``.
  33. .. versionadded:: 0.8
  34. """
  35. name = 'C#'
  36. url = 'https://docs.microsoft.com/en-us/dotnet/csharp/'
  37. aliases = ['csharp', 'c#', 'cs']
  38. filenames = ['*.cs']
  39. mimetypes = ['text/x-csharp'] # inferred
  40. version_added = ''
  41. flags = re.MULTILINE | re.DOTALL
  42. # for the range of allowed unicode characters in identifiers, see
  43. # http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf
  44. levels = {
  45. 'none': r'@?[_a-zA-Z]\w*',
  46. 'basic': ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' +
  47. '[' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc',
  48. 'Cf', 'Mn', 'Mc') + ']*'),
  49. 'full': ('@?(?:_|[^' +
  50. uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])' +
  51. '[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl',
  52. 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'),
  53. }
  54. tokens = {}
  55. token_variants = True
  56. for levelname, cs_ident in levels.items():
  57. tokens[levelname] = {
  58. 'root': [
  59. include('numbers'),
  60. # method names
  61. (r'^([ \t]*)((?:' + cs_ident + r'(?:\[\])?\s+)+?)' # return type
  62. r'(' + cs_ident + ')' # method name
  63. r'(\s*)(\()', # signature start
  64. bygroups(Whitespace, using(this), Name.Function, Whitespace,
  65. Punctuation)),
  66. (r'^(\s*)(\[.*?\])', bygroups(Whitespace, Name.Attribute)),
  67. (r'[^\S\n]+', Whitespace),
  68. (r'(\\)(\n)', bygroups(Text, Whitespace)), # line continuation
  69. (r'//.*?\n', Comment.Single),
  70. (r'/[*].*?[*]/', Comment.Multiline),
  71. (r'\n', Whitespace),
  72. (words((
  73. '>>>=', '>>=', '<<=', '<=', '>=', '+=', '-=', '*=', '/=',
  74. '%=', '&=', '|=', '^=', '??=', '=>', '??', '?.', '!=', '==',
  75. '&&', '||', '>>>', '>>', '<<', '++', '--', '+', '-', '*',
  76. '/', '%', '&', '|', '^', '<', '>', '?', '!', '~', '=',
  77. )), Operator),
  78. (r'=~|!=|==|<<|>>|[-+/*%=<>&^|]', Operator),
  79. (r'[()\[\];:,.]', Punctuation),
  80. (r'[{}]', Punctuation),
  81. (r'\$*"{3,}.*?"{3,}', String),
  82. (r'(?:\$@|@\$)"(""|[^"])*"', String),
  83. (r'@"(""|[^"])*"', String),
  84. (r'\$?"(\\\\|\\[^\\]|[^"\\\n])*["\n]', String),
  85. (r"'\\.'|'[^\\]'", String.Char),
  86. (r"[0-9]+(\.[0-9]*)?([eE][+-][0-9]+)?"
  87. r"[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?", Number),
  88. (r'(#)([ \t]*)(if|endif|else|elif|define|undef|'
  89. r'line|error|warning|region|endregion|pragma)\b(.*?)(\n)',
  90. bygroups(Comment.Preproc, Whitespace, Comment.Preproc,
  91. Comment.Preproc, Whitespace)),
  92. (r'\b(extern)(\s+)(alias)\b', bygroups(Keyword, Whitespace,
  93. Keyword)),
  94. (words((
  95. 'abstract', 'as', 'async', 'await', 'base', 'break', 'by',
  96. 'case', 'catch', 'checked', 'const', 'continue', 'default',
  97. 'delegate', 'do', 'else', 'enum', 'event', 'explicit',
  98. 'extern', 'false', 'finally', 'fixed', 'for', 'foreach',
  99. 'goto', 'if', 'implicit', 'in', 'interface', 'internal',
  100. 'is', 'let', 'lock', 'new', 'null', 'on', 'operator',
  101. 'out', 'override', 'params', 'private', 'protected',
  102. 'public', 'readonly', 'ref', 'return', 'sealed', 'sizeof',
  103. 'stackalloc', 'static', 'switch', 'this', 'throw', 'true',
  104. 'try', 'typeof', 'unchecked', 'unsafe', 'virtual', 'void',
  105. 'while', 'get', 'set', 'new', 'partial', 'yield', 'add',
  106. 'remove', 'value', 'alias', 'ascending', 'descending',
  107. 'from', 'group', 'into', 'orderby', 'select', 'thenby',
  108. 'where', 'join', 'equals', 'record', 'allows',
  109. 'and', 'init', 'managed', 'nameof', 'nint', 'not',
  110. 'notnull', 'nuint', 'or', 'scoped', 'unmanaged', 'when',
  111. 'with'
  112. ), suffix=r'\b'), Keyword),
  113. # version 1: assumes that 'file' is the only contextual keyword
  114. # that is a class modifier
  115. (r'(file)(\s+)(record|class|abstract|enum|new|sealed|static)\b',
  116. bygroups(Keyword, Whitespace, Keyword)),
  117. (r'(global)(::)', bygroups(Keyword, Punctuation)),
  118. (r'(bool|byte|char|decimal|double|dynamic|float|int|long|object|'
  119. r'sbyte|short|string|uint|ulong|ushort|var)\b\??', Keyword.Type),
  120. (r'(class|struct|union)(\s+)', bygroups(Keyword, Whitespace), 'class'),
  121. (r'(namespace|using)(\s+)', bygroups(Keyword, Whitespace), 'namespace'),
  122. (cs_ident, Name),
  123. ],
  124. 'numbers_int': [
  125. (r"0[xX][0-9a-fA-F]+(([uU][lL]?)|[lL][uU]?)?", Number.Hex),
  126. (r"0[bB][01]+(([uU][lL]?)|[lL][uU]?)?", Number.Bin),
  127. (r"[0-9]+(([uU][lL]?)|[lL][uU]?)?", Number.Integer),
  128. ],
  129. 'numbers_float': [
  130. (r"([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fFdDmM]?)|"
  131. r"(\.[0-9]+([eE][+-]?[0-9]+)?[fFdDmM]?)|"
  132. r"([0-9]+([eE][+-]?[0-9]+)[fFdDmM]?)|"
  133. r"([0-9]+[fFdDmM])", Number.Float),
  134. ],
  135. 'numbers': [
  136. include('numbers_float'),
  137. include('numbers_int'),
  138. ],
  139. 'class': [
  140. (cs_ident, Name.Class, '#pop'),
  141. default('#pop'),
  142. ],
  143. 'namespace': [
  144. (r'(?=\()', Text, '#pop'), # using (resource)
  145. ('(' + cs_ident + r'|\.)+', Name.Namespace, '#pop'),
  146. ]
  147. }
  148. def __init__(self, **options):
  149. level = get_choice_opt(options, 'unicodelevel', list(self.tokens), 'basic')
  150. if level not in self._all_tokens:
  151. # compile the regexes now
  152. self._tokens = self.__class__.process_tokendef(level)
  153. else:
  154. self._tokens = self._all_tokens[level]
  155. RegexLexer.__init__(self, **options)
  156. class NemerleLexer(RegexLexer):
  157. """
  158. For Nemerle source code.
  159. Additional options accepted:
  160. `unicodelevel`
  161. Determines which Unicode characters this lexer allows for identifiers.
  162. The possible values are:
  163. * ``none`` -- only the ASCII letters and numbers are allowed. This
  164. is the fastest selection.
  165. * ``basic`` -- all Unicode characters from the specification except
  166. category ``Lo`` are allowed.
  167. * ``full`` -- all Unicode characters as specified in the C# specs
  168. are allowed. Note that this means a considerable slowdown since the
  169. ``Lo`` category has more than 40,000 characters in it!
  170. The default value is ``basic``.
  171. """
  172. name = 'Nemerle'
  173. url = 'http://nemerle.org'
  174. aliases = ['nemerle']
  175. filenames = ['*.n']
  176. mimetypes = ['text/x-nemerle'] # inferred
  177. version_added = '1.5'
  178. flags = re.MULTILINE | re.DOTALL
  179. # for the range of allowed unicode characters in identifiers, see
  180. # http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf
  181. levels = {
  182. 'none': r'@?[_a-zA-Z]\w*',
  183. 'basic': ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' +
  184. '[' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc',
  185. 'Cf', 'Mn', 'Mc') + ']*'),
  186. 'full': ('@?(?:_|[^' +
  187. uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])' +
  188. '[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl',
  189. 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'),
  190. }
  191. tokens = {}
  192. token_variants = True
  193. for levelname, cs_ident in levels.items():
  194. tokens[levelname] = {
  195. 'root': [
  196. # method names
  197. (r'^([ \t]*)((?:' + cs_ident + r'(?:\[\])?\s+)+?)' # return type
  198. r'(' + cs_ident + ')' # method name
  199. r'(\s*)(\()', # signature start
  200. bygroups(Whitespace, using(this), Name.Function, Whitespace, \
  201. Punctuation)),
  202. (r'^(\s*)(\[.*?\])', bygroups(Whitespace, Name.Attribute)),
  203. (r'[^\S\n]+', Whitespace),
  204. (r'(\\)(\n)', bygroups(Text, Whitespace)), # line continuation
  205. (r'//.*?\n', Comment.Single),
  206. (r'/[*].*?[*]/', Comment.Multiline),
  207. (r'\n', Whitespace),
  208. (r'(\$)(\s*)(")', bygroups(String, Whitespace, String),
  209. 'splice-string'),
  210. (r'(\$)(\s*)(<#)', bygroups(String, Whitespace, String),
  211. 'splice-string2'),
  212. (r'<#', String, 'recursive-string'),
  213. (r'(<\[)(\s*)(' + cs_ident + ':)?',
  214. bygroups(Keyword, Whitespace, Keyword)),
  215. (r'\]\>', Keyword),
  216. # quasiquotation only
  217. (r'\$' + cs_ident, Name),
  218. (r'(\$)(\()', bygroups(Name, Punctuation),
  219. 'splice-string-content'),
  220. (r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation),
  221. (r'[{}]', Punctuation),
  222. (r'@"(""|[^"])*"', String),
  223. (r'"(\\\\|\\[^\\]|[^"\\\n])*["\n]', String),
  224. (r"'\\.'|'[^\\]'", String.Char),
  225. (r"0[xX][0-9a-fA-F]+[Ll]?", Number),
  226. (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFLdD]?", Number),
  227. (r'(#)([ \t]*)(if|endif|else|elif|define|undef|'
  228. r'line|error|warning|region|endregion|pragma)\b',
  229. bygroups(Comment.Preproc, Whitespace, Comment.Preproc), 'preproc'),
  230. (r'\b(extern)(\s+)(alias)\b', bygroups(Keyword, Whitespace, Keyword)),
  231. (words(('abstract', 'and', 'as', 'base', 'catch', 'def', 'delegate',
  232. 'enum', 'event', 'extern', 'false',
  233. 'finally', 'fun', 'implements', 'interface',
  234. 'internal', 'is', 'macro', 'match',
  235. 'matches', 'module', 'mutable', 'new',
  236. 'null', 'out', 'override', 'params',
  237. 'partial', 'private', 'protected', 'public',
  238. 'ref', 'sealed', 'static', 'syntax', 'this',
  239. 'throw', 'true', 'try', 'type', 'typeof',
  240. 'virtual', 'volatile', 'when', 'where',
  241. 'with', 'assert', 'assert2', 'async',
  242. 'break', 'checked', 'continue', 'do',
  243. 'else', 'ensures', 'for', 'foreach', 'if',
  244. 'late', 'lock', 'new', 'nolate',
  245. 'otherwise', 'regexp', 'repeat', 'requires',
  246. 'return', 'surroundwith', 'unchecked',
  247. 'unless', 'using', 'while', 'yield'), suffix=r'\b'), Keyword),
  248. (r'(global)(::)', bygroups(Keyword, Punctuation)),
  249. (r'(bool|byte|char|decimal|double|float|int|long|object|sbyte|'
  250. r'short|string|uint|ulong|ushort|void|array|list)\b\??',
  251. Keyword.Type),
  252. (r'(:>?)(\s*)(' + cs_ident + r'\??)',
  253. bygroups(Punctuation, Whitespace, Keyword.Type)),
  254. (r'(class|struct|variant|module)(\s+)',
  255. bygroups(Keyword, Whitespace), 'class'),
  256. (r'(namespace|using)(\s+)', bygroups(Keyword, Whitespace),
  257. 'namespace'),
  258. (cs_ident, Name),
  259. ],
  260. 'class': [
  261. (cs_ident, Name.Class, '#pop')
  262. ],
  263. 'preproc': [
  264. (r'\w+', Comment.Preproc),
  265. (r'[ \t]+', Whitespace),
  266. (r'\n', Whitespace, '#pop')
  267. ],
  268. 'namespace': [
  269. (r'(?=\()', Text, '#pop'), # using (resource)
  270. ('(' + cs_ident + r'|\.)+', Name.Namespace, '#pop')
  271. ],
  272. 'splice-string': [
  273. (r'[^"$]', String),
  274. (r'\$' + cs_ident, Name),
  275. (r'(\$)(\()', bygroups(Name, Punctuation),
  276. 'splice-string-content'),
  277. (r'\\"', String),
  278. (r'"', String, '#pop')
  279. ],
  280. 'splice-string2': [
  281. (r'[^#<>$]', String),
  282. (r'\$' + cs_ident, Name),
  283. (r'(\$)(\()', bygroups(Name, Punctuation),
  284. 'splice-string-content'),
  285. (r'<#', String, '#push'),
  286. (r'#>', String, '#pop')
  287. ],
  288. 'recursive-string': [
  289. (r'[^#<>]', String),
  290. (r'<#', String, '#push'),
  291. (r'#>', String, '#pop')
  292. ],
  293. 'splice-string-content': [
  294. (r'if|match', Keyword),
  295. (r'[~!%^&*+=|\[\]:;,.<>/?-\\"$ ]', Punctuation),
  296. (cs_ident, Name),
  297. (r'\d+', Number),
  298. (r'\(', Punctuation, '#push'),
  299. (r'\)', Punctuation, '#pop')
  300. ]
  301. }
  302. def __init__(self, **options):
  303. level = get_choice_opt(options, 'unicodelevel', list(self.tokens),
  304. 'basic')
  305. if level not in self._all_tokens:
  306. # compile the regexes now
  307. self._tokens = self.__class__.process_tokendef(level)
  308. else:
  309. self._tokens = self._all_tokens[level]
  310. RegexLexer.__init__(self, **options)
  311. def analyse_text(text):
  312. """Nemerle is quite similar to Python, but @if is relatively uncommon
  313. elsewhere."""
  314. result = 0
  315. if '@if' in text:
  316. result += 0.1
  317. return result
  318. class BooLexer(RegexLexer):
  319. """
  320. For Boo source code.
  321. """
  322. name = 'Boo'
  323. url = 'https://github.com/boo-lang/boo'
  324. aliases = ['boo']
  325. filenames = ['*.boo']
  326. mimetypes = ['text/x-boo']
  327. version_added = ''
  328. tokens = {
  329. 'root': [
  330. (r'\s+', Whitespace),
  331. (r'(#|//).*$', Comment.Single),
  332. (r'/[*]', Comment.Multiline, 'comment'),
  333. (r'[]{}:(),.;[]', Punctuation),
  334. (r'(\\)(\n)', bygroups(Text, Whitespace)),
  335. (r'\\', Text),
  336. (r'(in|is|and|or|not)\b', Operator.Word),
  337. (r'/(\\\\|\\[^\\]|[^/\\\s])/', String.Regex),
  338. (r'@/(\\\\|\\[^\\]|[^/\\])*/', String.Regex),
  339. (r'=~|!=|==|<<|>>|[-+/*%=<>&^|]', Operator),
  340. (words(('as', 'abstract', 'callable', 'constructor', 'destructor',
  341. 'do', 'import', 'enum', 'event', 'final',
  342. 'get', 'interface', 'internal', 'of',
  343. 'override', 'partial', 'private',
  344. 'protected', 'public', 'return', 'set',
  345. 'static', 'struct', 'transient', 'virtual',
  346. 'yield', 'super', 'and', 'break', 'cast',
  347. 'continue', 'elif', 'else', 'ensure',
  348. 'except', 'for', 'given', 'goto', 'if',
  349. 'in', 'is', 'isa', 'not', 'or', 'otherwise',
  350. 'pass', 'raise', 'ref', 'try', 'unless',
  351. 'when', 'while', 'from'), suffix=r'\b'), Keyword),
  352. (r'def(?=\s+\(.*?\))', Keyword),
  353. (r'(def)(\s+)', bygroups(Keyword, Whitespace), 'funcname'),
  354. (r'(class)(\s+)', bygroups(Keyword, Whitespace), 'classname'),
  355. (r'(namespace)(\s+)', bygroups(Keyword, Whitespace), 'namespace'),
  356. (r'(?<!\.)(true|false|null|self|__eval__|__switch__|array|'
  357. r'assert|checked|enumerate|filter|getter|len|lock|map|'
  358. r'matrix|max|min|normalArrayIndexing|print|property|range|'
  359. r'rawArrayIndexing|required|typeof|unchecked|using|'
  360. r'yieldAll|zip)\b', Name.Builtin),
  361. (r'"""(\\\\|\\"|.*?)"""', String.Double),
  362. (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
  363. (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
  364. (r'[a-zA-Z_]\w*', Name),
  365. (r'(\d+\.\d*|\d*\.\d+)([fF][+-]?[0-9]+)?', Number.Float),
  366. (r'[0-9][0-9.]*(ms?|d|h|s)', Number),
  367. (r'0\d+', Number.Oct),
  368. (r'0x[a-fA-F0-9]+', Number.Hex),
  369. (r'\d+L', Number.Integer.Long),
  370. (r'\d+', Number.Integer),
  371. ],
  372. 'comment': [
  373. ('/[*]', Comment.Multiline, '#push'),
  374. ('[*]/', Comment.Multiline, '#pop'),
  375. ('[^/*]', Comment.Multiline),
  376. ('[*/]', Comment.Multiline)
  377. ],
  378. 'funcname': [
  379. (r'[a-zA-Z_]\w*', Name.Function, '#pop')
  380. ],
  381. 'classname': [
  382. (r'[a-zA-Z_]\w*', Name.Class, '#pop')
  383. ],
  384. 'namespace': [
  385. (r'[a-zA-Z_][\w.]*', Name.Namespace, '#pop')
  386. ]
  387. }
  388. class VbNetLexer(RegexLexer):
  389. """
  390. For Visual Basic.NET source code.
  391. Also LibreOffice Basic, OpenOffice Basic, and StarOffice Basic.
  392. """
  393. name = 'VB.net'
  394. url = 'https://docs.microsoft.com/en-us/dotnet/visual-basic/'
  395. aliases = ['vb.net', 'vbnet', 'lobas', 'oobas', 'sobas', 'visual-basic', 'visualbasic']
  396. filenames = ['*.vb', '*.bas']
  397. mimetypes = ['text/x-vbnet', 'text/x-vba'] # (?)
  398. version_added = ''
  399. uni_name = '[_' + uni.combine('Ll', 'Lt', 'Lm', 'Nl') + ']' + \
  400. '[' + uni.combine('Ll', 'Lt', 'Lm', 'Nl', 'Nd', 'Pc',
  401. 'Cf', 'Mn', 'Mc') + ']*'
  402. flags = re.MULTILINE | re.IGNORECASE
  403. tokens = {
  404. 'root': [
  405. (r'^\s*<.*?>', Name.Attribute),
  406. (r'\s+', Whitespace),
  407. (r'\n', Whitespace),
  408. (r'(rem\b.*?)(\n)', bygroups(Comment, Whitespace)),
  409. (r"('.*?)(\n)", bygroups(Comment, Whitespace)),
  410. (r'#If\s.*?\sThen|#ElseIf\s.*?\sThen|#Else|#End\s+If|#Const|'
  411. r'#ExternalSource.*?\n|#End\s+ExternalSource|'
  412. r'#Region.*?\n|#End\s+Region|#ExternalChecksum',
  413. Comment.Preproc),
  414. (r'[(){}!#,.:]', Punctuation),
  415. (r'(Option)(\s+)(Strict|Explicit|Compare)(\s+)'
  416. r'(On|Off|Binary|Text)',
  417. bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration,
  418. Whitespace, Keyword.Declaration)),
  419. (words((
  420. 'AddHandler', 'Alias', 'ByRef', 'ByVal', 'Call', 'Case',
  421. 'Catch', 'CBool', 'CByte', 'CChar', 'CDate', 'CDec', 'CDbl',
  422. 'CInt', 'CLng', 'CObj', 'Continue', 'CSByte', 'CShort', 'CSng',
  423. 'CStr', 'CType', 'CUInt', 'CULng', 'CUShort', 'Declare',
  424. 'Default', 'Delegate', 'DirectCast', 'Do', 'Each', 'Else',
  425. 'ElseIf', 'EndIf', 'Erase', 'Error', 'Event', 'Exit', 'False',
  426. 'Finally', 'For', 'Friend', 'Get', 'Global', 'GoSub', 'GoTo',
  427. 'Handles', 'If', 'Implements', 'Inherits', 'Interface', 'Let',
  428. 'Lib', 'Loop', 'Me', 'MustInherit', 'MustOverride', 'MyBase',
  429. 'MyClass', 'Narrowing', 'New', 'Next', 'Not', 'Nothing',
  430. 'NotInheritable', 'NotOverridable', 'Of', 'On', 'Operator',
  431. 'Option', 'Optional', 'Overloads', 'Overridable', 'Overrides',
  432. 'ParamArray', 'Partial', 'Private', 'Protected', 'Public',
  433. 'RaiseEvent', 'ReadOnly', 'ReDim', 'RemoveHandler', 'Resume',
  434. 'Return', 'Select', 'Set', 'Shadows', 'Shared', 'Single',
  435. 'Static', 'Step', 'Stop', 'SyncLock', 'Then', 'Throw', 'To',
  436. 'True', 'Try', 'TryCast', 'Wend', 'Using', 'When', 'While',
  437. 'Widening', 'With', 'WithEvents', 'WriteOnly'),
  438. prefix=r'(?<!\.)', suffix=r'\b'), Keyword),
  439. (r'(?<!\.)End\b', Keyword, 'end'),
  440. (r'(?<!\.)(Dim|Const)\b', Keyword, 'dim'),
  441. (r'(?<!\.)(Function|Sub|Property)(\s+)',
  442. bygroups(Keyword, Whitespace), 'funcname'),
  443. (r'(?<!\.)(Class|Structure|Enum)(\s+)',
  444. bygroups(Keyword, Whitespace), 'classname'),
  445. (r'(?<!\.)(Module|Namespace|Imports)(\s+)',
  446. bygroups(Keyword, Whitespace), 'namespace'),
  447. (r'(?<!\.)(Boolean|Byte|Char|Date|Decimal|Double|Integer|Long|'
  448. r'Object|SByte|Short|Single|String|Variant|UInteger|ULong|'
  449. r'UShort)\b', Keyword.Type),
  450. (r'(?<!\.)(AddressOf|And|AndAlso|As|GetType|In|Is|IsNot|Like|Mod|'
  451. r'Or|OrElse|TypeOf|Xor)\b', Operator.Word),
  452. (r'&=|[*]=|/=|\\=|\^=|\+=|-=|<<=|>>=|<<|>>|:=|'
  453. r'<=|>=|<>|[-&*/\\^+=<>\[\]]',
  454. Operator),
  455. ('"', String, 'string'),
  456. (r'(_)(\n)', bygroups(Text, Whitespace)), # Line continuation (must be before Name)
  457. (uni_name + '[%&@!#$]?', Name),
  458. ('#.*?#', Literal.Date),
  459. (r'(\d+\.\d*|\d*\.\d+)(F[+-]?[0-9]+)?', Number.Float),
  460. (r'\d+([SILDFR]|US|UI|UL)?', Number.Integer),
  461. (r'&H[0-9a-f]+([SILDFR]|US|UI|UL)?', Number.Integer),
  462. (r'&O[0-7]+([SILDFR]|US|UI|UL)?', Number.Integer),
  463. ],
  464. 'string': [
  465. (r'""', String),
  466. (r'"C?', String, '#pop'),
  467. (r'[^"]+', String),
  468. ],
  469. 'dim': [
  470. (uni_name, Name.Variable, '#pop'),
  471. default('#pop'), # any other syntax
  472. ],
  473. 'funcname': [
  474. (uni_name, Name.Function, '#pop'),
  475. ],
  476. 'classname': [
  477. (uni_name, Name.Class, '#pop'),
  478. ],
  479. 'namespace': [
  480. (uni_name, Name.Namespace),
  481. (r'\.', Name.Namespace),
  482. default('#pop'),
  483. ],
  484. 'end': [
  485. (r'\s+', Whitespace),
  486. (words(('Function', 'Sub', 'Property', 'Class', 'Structure', 'Enum',
  487. 'Module', 'Namespace'), suffix=r'\b'),
  488. Keyword, '#pop'),
  489. default('#pop'),
  490. ]
  491. }
  492. def analyse_text(text):
  493. if re.search(r'^\s*(#If|Module|Namespace)', text, re.MULTILINE):
  494. return 0.5
  495. class GenericAspxLexer(RegexLexer):
  496. """
  497. Lexer for ASP.NET pages.
  498. """
  499. name = 'aspx-gen'
  500. filenames = []
  501. mimetypes = []
  502. url = 'https://dotnet.microsoft.com/en-us/apps/aspnet'
  503. flags = re.DOTALL
  504. tokens = {
  505. 'root': [
  506. (r'(<%[@=#]?)(.*?)(%>)', bygroups(Name.Tag, Other, Name.Tag)),
  507. (r'(<script.*?>)(.*?)(</script>)', bygroups(using(XmlLexer),
  508. Other,
  509. using(XmlLexer))),
  510. (r'(.+?)(?=<)', using(XmlLexer)),
  511. (r'.+', using(XmlLexer)),
  512. ],
  513. }
  514. # TODO support multiple languages within the same source file
  515. class CSharpAspxLexer(DelegatingLexer):
  516. """
  517. Lexer for highlighting C# within ASP.NET pages.
  518. """
  519. name = 'aspx-cs'
  520. aliases = ['aspx-cs']
  521. filenames = ['*.aspx', '*.asax', '*.ascx', '*.ashx', '*.asmx', '*.axd']
  522. mimetypes = []
  523. url = 'https://dotnet.microsoft.com/en-us/apps/aspnet'
  524. version_added = ''
  525. def __init__(self, **options):
  526. super().__init__(CSharpLexer, GenericAspxLexer, **options)
  527. def analyse_text(text):
  528. if re.search(r'Page\s*Language="C#"', text, re.I) is not None:
  529. return 0.2
  530. elif re.search(r'script[^>]+language=["\']C#', text, re.I) is not None:
  531. return 0.15
  532. class VbNetAspxLexer(DelegatingLexer):
  533. """
  534. Lexer for highlighting Visual Basic.net within ASP.NET pages.
  535. """
  536. name = 'aspx-vb'
  537. aliases = ['aspx-vb']
  538. filenames = ['*.aspx', '*.asax', '*.ascx', '*.ashx', '*.asmx', '*.axd']
  539. mimetypes = []
  540. url = 'https://dotnet.microsoft.com/en-us/apps/aspnet'
  541. version_added = ''
  542. def __init__(self, **options):
  543. super().__init__(VbNetLexer, GenericAspxLexer, **options)
  544. def analyse_text(text):
  545. if re.search(r'Page\s*Language="Vb"', text, re.I) is not None:
  546. return 0.2
  547. elif re.search(r'script[^>]+language=["\']vb', text, re.I) is not None:
  548. return 0.15
  549. # Very close to functional.OcamlLexer
  550. class FSharpLexer(RegexLexer):
  551. """
  552. For the F# language (version 3.0).
  553. """
  554. name = 'F#'
  555. url = 'https://fsharp.org/'
  556. aliases = ['fsharp', 'f#']
  557. filenames = ['*.fs', '*.fsi', '*.fsx']
  558. mimetypes = ['text/x-fsharp']
  559. version_added = '1.5'
  560. keywords = [
  561. 'abstract', 'as', 'assert', 'base', 'begin', 'class', 'default',
  562. 'delegate', 'do!', 'do', 'done', 'downcast', 'downto', 'elif', 'else',
  563. 'end', 'exception', 'extern', 'false', 'finally', 'for', 'function',
  564. 'fun', 'global', 'if', 'inherit', 'inline', 'interface', 'internal',
  565. 'in', 'lazy', 'let!', 'let', 'match', 'member', 'module', 'mutable',
  566. 'namespace', 'new', 'null', 'of', 'open', 'override', 'private', 'public',
  567. 'rec', 'return!', 'return', 'select', 'static', 'struct', 'then', 'to',
  568. 'true', 'try', 'type', 'upcast', 'use!', 'use', 'val', 'void', 'when',
  569. 'while', 'with', 'yield!', 'yield',
  570. ]
  571. # Reserved words; cannot hurt to color them as keywords too.
  572. keywords += [
  573. 'atomic', 'break', 'checked', 'component', 'const', 'constraint',
  574. 'constructor', 'continue', 'eager', 'event', 'external', 'fixed',
  575. 'functor', 'include', 'method', 'mixin', 'object', 'parallel',
  576. 'process', 'protected', 'pure', 'sealed', 'tailcall', 'trait',
  577. 'virtual', 'volatile',
  578. ]
  579. keyopts = [
  580. '!=', '#', '&&', '&', r'\(', r'\)', r'\*', r'\+', ',', r'-\.',
  581. '->', '-', r'\.\.', r'\.', '::', ':=', ':>', ':', ';;', ';', '<-',
  582. r'<\]', '<', r'>\]', '>', r'\?\?', r'\?', r'\[<', r'\[\|', r'\[', r'\]',
  583. '_', '`', r'\{', r'\|\]', r'\|', r'\}', '~', '<@@', '<@', '=', '@>', '@@>',
  584. ]
  585. operators = r'[!$%&*+\./:<=>?@^|~-]'
  586. word_operators = ['and', 'or', 'not']
  587. prefix_syms = r'[!?~]'
  588. infix_syms = r'[=<>@^|&+\*/$%-]'
  589. primitives = [
  590. 'sbyte', 'byte', 'char', 'nativeint', 'unativeint', 'float32', 'single',
  591. 'float', 'double', 'int8', 'uint8', 'int16', 'uint16', 'int32',
  592. 'uint32', 'int64', 'uint64', 'decimal', 'unit', 'bool', 'string',
  593. 'list', 'exn', 'obj', 'enum',
  594. ]
  595. # See http://msdn.microsoft.com/en-us/library/dd233181.aspx and/or
  596. # http://fsharp.org/about/files/spec.pdf for reference. Good luck.
  597. tokens = {
  598. 'escape-sequence': [
  599. (r'\\[\\"\'ntbrafv]', String.Escape),
  600. (r'\\[0-9]{3}', String.Escape),
  601. (r'\\u[0-9a-fA-F]{4}', String.Escape),
  602. (r'\\U[0-9a-fA-F]{8}', String.Escape),
  603. ],
  604. 'root': [
  605. (r'\s+', Whitespace),
  606. (r'\(\)|\[\]', Name.Builtin.Pseudo),
  607. (r'\b(?<!\.)([A-Z][\w\']*)(?=\s*\.)',
  608. Name.Namespace, 'dotted'),
  609. (r'\b([A-Z][\w\']*)', Name),
  610. (r'(///.*?)(\n)', bygroups(String.Doc, Whitespace)),
  611. (r'(//.*?)(\n)', bygroups(Comment.Single, Whitespace)),
  612. (r'\(\*(?!\))', Comment, 'comment'),
  613. (r'@"', String, 'lstring'),
  614. (r'"""', String, 'tqs'),
  615. (r'"', String, 'string'),
  616. (r'\b(open|module)(\s+)([\w.]+)',
  617. bygroups(Keyword, Whitespace, Name.Namespace)),
  618. (r'\b(let!?)(\s+)(\w+)',
  619. bygroups(Keyword, Whitespace, Name.Variable)),
  620. (r'\b(type)(\s+)(\w+)',
  621. bygroups(Keyword, Whitespace, Name.Class)),
  622. (r'\b(member|override)(\s+)(\w+)(\.)(\w+)',
  623. bygroups(Keyword, Whitespace, Name, Punctuation, Name.Function)),
  624. (r'\b({})\b'.format('|'.join(keywords)), Keyword),
  625. (r'``([^`\n\r\t]|`[^`\n\r\t])+``', Name),
  626. (r'({})'.format('|'.join(keyopts)), Operator),
  627. (rf'({infix_syms}|{prefix_syms})?{operators}', Operator),
  628. (r'\b({})\b'.format('|'.join(word_operators)), Operator.Word),
  629. (r'\b({})\b'.format('|'.join(primitives)), Keyword.Type),
  630. (r'(#)([ \t]*)(if|endif|else|line|nowarn|light|\d+)\b(.*?)(\n)',
  631. bygroups(Comment.Preproc, Whitespace, Comment.Preproc,
  632. Comment.Preproc, Whitespace)),
  633. (r"[^\W\d][\w']*", Name),
  634. (r'\d[\d_]*[uU]?[yslLnQRZINGmM]?', Number.Integer),
  635. (r'0[xX][\da-fA-F][\da-fA-F_]*[uU]?[yslLn]?[fF]?', Number.Hex),
  636. (r'0[oO][0-7][0-7_]*[uU]?[yslLn]?', Number.Oct),
  637. (r'0[bB][01][01_]*[uU]?[yslLn]?', Number.Bin),
  638. (r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)[fFmM]?',
  639. Number.Float),
  640. (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'B?",
  641. String.Char),
  642. (r"'.'", String.Char),
  643. (r"'", Keyword), # a stray quote is another syntax element
  644. (r'@?"', String.Double, 'string'),
  645. (r'[~?][a-z][\w\']*:', Name.Variable),
  646. ],
  647. 'dotted': [
  648. (r'\s+', Whitespace),
  649. (r'\.', Punctuation),
  650. (r'[A-Z][\w\']*(?=\s*\.)', Name.Namespace),
  651. (r'[A-Z][\w\']*', Name, '#pop'),
  652. (r'[a-z_][\w\']*', Name, '#pop'),
  653. # e.g. dictionary index access
  654. default('#pop'),
  655. ],
  656. 'comment': [
  657. (r'[^(*)@"]+', Comment),
  658. (r'\(\*', Comment, '#push'),
  659. (r'\*\)', Comment, '#pop'),
  660. # comments cannot be closed within strings in comments
  661. (r'@"', String, 'lstring'),
  662. (r'"""', String, 'tqs'),
  663. (r'"', String, 'string'),
  664. (r'[(*)@]', Comment),
  665. ],
  666. 'string': [
  667. (r'[^\\"]+', String),
  668. include('escape-sequence'),
  669. (r'\\\n', String),
  670. (r'\n', String), # newlines are allowed in any string
  671. (r'"B?', String, '#pop'),
  672. ],
  673. 'lstring': [
  674. (r'[^"]+', String),
  675. (r'\n', String),
  676. (r'""', String),
  677. (r'"B?', String, '#pop'),
  678. ],
  679. 'tqs': [
  680. (r'[^"]+', String),
  681. (r'\n', String),
  682. (r'"""B?', String, '#pop'),
  683. (r'"', String),
  684. ],
  685. }
  686. def analyse_text(text):
  687. """F# doesn't have that many unique features -- |> and <| are weak
  688. indicators."""
  689. result = 0
  690. if '|>' in text:
  691. result += 0.05
  692. if '<|' in text:
  693. result += 0.05
  694. return result
  695. class XppLexer(RegexLexer):
  696. """
  697. For X++ source code. This is based loosely on the CSharpLexer
  698. """
  699. name = 'X++'
  700. url = 'https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/dev-ref/xpp-language-reference'
  701. aliases = ['xpp', 'x++']
  702. filenames = ['*.xpp']
  703. version_added = '2.15'
  704. flags = re.MULTILINE
  705. XPP_CHARS = ('@?(?:_|[^' +
  706. uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])' +
  707. '[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl',
  708. 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*')
  709. # Temporary, see
  710. # https://github.com/thatch/regexlint/pull/49
  711. XPP_CHARS = XPP_CHARS.replace('\x00', '\x01')
  712. OPERATORS = (
  713. '<=', '>=', '+=', '-=', '*=', '/=', '!=', '==',
  714. '&&', '||', '>>', '<<', '++', '--', '+', '-', '*',
  715. '/', '%', '&', '|', '^', '<', '>', '?', '!', '~', '=',
  716. )
  717. KEYWORDS = ('abstract','anytype','as','async','asc','at','avg','break','breakpoint','by','byref','case','catch',
  718. 'changecompany','client','container','continue','count','crosscompany','default','delegate',
  719. 'delete_from','desc','display','div','do','edit','else','element','eventhandler','exists','false','final',
  720. 'firstfast','firstonly','firstonly10','firstonly100','firstonly1000','flush','for','forceliterals',
  721. 'forcenestedloop','forceplaceholders','forceselectorder','forupdate','from','group','if','insert_recordset',
  722. 'interface','is','join','like','maxof','minof','mod','new','next','nofetch','notexists','null','optimisticlock','order',
  723. 'outer','pause','pessimisticlock','print','private','protected','public','repeatableread','retry','return',
  724. 'reverse','select','server','setting','static','sum','super','switch','tablelock','this','throw','true','try','ttsabort','ttsbegin',
  725. 'ttscommit','update_recordset','validtimestate','void','where','while','window')
  726. RUNTIME_FUNCTIONS = ('_duration','abs','acos','any2Date','any2Enum','any2Guid','any2Int','any2Int64','any2Real','any2Str','anytodate',
  727. 'anytoenum','anytoguid','anytoint','anytoint64','anytoreal','anytostr','asin','atan','beep','cTerm','char2Num','classIdGet',
  728. 'corrFlagGet','corrFlagSet','cos','cosh','curExt','curUserId','date2Num','date2Str','datetime2Str','dayName','dayOfMth',
  729. 'dayOfWk','dayOfYr','ddb','decRound','dg','dimOf','endMth','enum2str','exp','exp10','fV','fieldId2Name','fieldId2PName',
  730. 'fieldName2Id','frac','funcName','getCurrentPartition','getCurrentPartitionRecId','getPrefix','guid2Str','idg','indexId2Name',
  731. 'indexName2Id','int2Str','int642Str','intvMax','intvName','intvNo','intvNorm','log10','logN','match','max','min','mkDate','mthName',
  732. 'mthOfYr','newGuid','nextMth','nextQtr','nextYr','num2Char','num2Date','num2Str','pmt','power','prevMth','prevQtr','prevYr',
  733. 'prmIsDefault','pt','pv','rate','refPrintAll','round','runAs','sessionId','setPrefix','sin','sinh','sleep','sln','str2Date',
  734. 'str2Datetime','str2Enum','str2Guid','str2Int','str2Int64','str2Num','str2Time','strAlpha','strCmp','strColSeq','strDel',
  735. 'strFind','strFmt','strIns','strKeep','strLTrim','strLen','strLine','strLwr','strNFind','strPoke','strPrompt','strRTrim',
  736. 'strRem','strRep','strScan','strUpr','subStr','syd','systemDateGet','systemDateSet','tableId2Name',
  737. 'tableId2PName','tableName2Id','tan','tanh','term','time2Str','timeNow','today','trunc','typeOf','uint2Str','wkOfYr','year')
  738. COMPILE_FUNCTIONS = ('attributeStr','classNum','classStr','configurationKeyNum','configurationKeyStr','dataEntityDataSourceStr','delegateStr',
  739. 'dimensionHierarchyLevelStr','dimensionHierarchyStr','dimensionReferenceStr','dutyStr','enumCnt','enumLiteralStr','enumNum','enumStr',
  740. 'extendedTypeNum','extendedTypeStr','fieldNum','fieldPName','fieldStr','formControlStr','formDataFieldStr','formDataSourceStr',
  741. 'formMethodStr','formStr','identifierStr','indexNum','indexStr','licenseCodeNum','licenseCodeStr','literalStr','maxDate','maxInt',
  742. 'measureStr','measurementStr','menuItemActionStr','menuItemDisplayStr','menuItemOutputStr','menuStr','methodStr','minInt','privilegeStr',
  743. 'queryDatasourceStr','queryMethodStr','queryStr','reportStr','resourceStr','roleStr','ssrsReportStr','staticDelegateStr','staticMethodStr',
  744. 'tableCollectionStr','tableFieldGroupStr','tableMethodStr','tableNum','tablePName','tableStaticMethodStr','tableStr','tileStr','varStr',
  745. 'webActionItemStr','webDisplayContentItemStr','webFormStr','webMenuStr','webOutputContentItemStr','webReportStr','webSiteTempStr',
  746. 'webStaticFileStr','webUrlItemStr','webWebPartStr','webletItemStr','webpageDefStr','websiteDefStr','workflowApprovalStr',
  747. 'workflowCategoryStr','workflowTaskStr','workflowTypeStr')
  748. tokens = {}
  749. tokens = {
  750. 'root': [
  751. # method names
  752. (r'(\s*)\b(else|if)\b([^\n])', bygroups(Whitespace, Keyword, using(this))), # ensure that if is not treated like a function
  753. (r'^([ \t]*)((?:' + XPP_CHARS + r'(?:\[\])?\s+)+?)' # return type
  754. r'(' + XPP_CHARS + ')' # method name
  755. r'(\s*)(\()', # signature start
  756. bygroups(Whitespace, using(this), Name.Function, Whitespace,
  757. Punctuation)),
  758. (r'^(\s*)(\[)([^\n]*?)(\])', bygroups(Whitespace, Name.Attribute, Name.Variable.Class, Name.Attribute)),
  759. (r'[^\S\n]+', Whitespace),
  760. (r'(\\)(\n)', bygroups(Text, Whitespace)), # line continuation
  761. (r'//[^\n]*?\n', Comment.Single),
  762. (r'/[*][^\n]*?[*]/', Comment.Multiline),
  763. (r'\n', Whitespace),
  764. (words(OPERATORS), Operator),
  765. (r'=~|!=|==|<<|>>|[-+/*%=<>&^|]', Operator),
  766. (r'[()\[\];:,.#@]', Punctuation),
  767. (r'[{}]', Punctuation),
  768. (r'@"(""|[^"])*"', String),
  769. (r'\$?"(\\\\|\\[^\\]|[^"\\\n])*["\n]', String),
  770. (r"'\\.'|'[^\\]'", String.Char),
  771. (r"[0-9]+(\.[0-9]*)?([eE][+-][0-9]+)?"
  772. r"[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?", Number),
  773. (words(KEYWORDS, suffix=r'\b'), Keyword),
  774. (r'(boolean|int|int64|str|real|guid|date)\b\??', Keyword.Type),
  775. (r'(class|struct|extends|implements)(\s+)', bygroups(Keyword, Whitespace), 'class'),
  776. (r'('+XPP_CHARS+')(::)', bygroups(Name.Variable.Class, Punctuation)),
  777. (r'(\s*)(\w+)(\s+\w+(,|=)?[^\n]*;)', bygroups(Whitespace, Name.Variable.Class, using(this))), # declaration
  778. # x++ specific function to get field should highlight the classname
  779. (r'(fieldNum\()('+XPP_CHARS+r')(\s*,\s*)('+XPP_CHARS+r')(\s*\))',
  780. bygroups(using(this), Name.Variable.Class, using(this), Name.Property, using(this))),
  781. # x++ specific function to get table should highlight the classname
  782. (r'(tableNum\()('+XPP_CHARS+r')(\s*\))',
  783. bygroups(using(this), Name.Variable.Class, using(this))),
  784. (words(RUNTIME_FUNCTIONS, suffix=r'(?=\()'), Name.Function.Magic),
  785. (words(COMPILE_FUNCTIONS, suffix=r'(?=\()'), Name.Function.Magic),
  786. (XPP_CHARS, Name),
  787. ],
  788. 'class': [
  789. (XPP_CHARS, Name.Class, '#pop'),
  790. default('#pop'),
  791. ],
  792. 'namespace': [
  793. (r'(?=\()', Text, '#pop'), # using (resource)
  794. ('(' + XPP_CHARS + r'|\.)+', Name.Namespace, '#pop'),
  795. ]
  796. }