Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pygments/lexers/c_like.py: 83%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

147 statements  

1""" 

2 pygments.lexers.c_like 

3 ~~~~~~~~~~~~~~~~~~~~~~ 

4 

5 Lexers for other C-like languages. 

6 

7 :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. 

8 :license: BSD, see LICENSE for details. 

9""" 

10 

11import re 

12 

13from pygments.lexer import RegexLexer, include, bygroups, inherit, words, \ 

14 default 

15from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ 

16 Number, Punctuation, Whitespace 

17 

18from pygments.lexers.c_cpp import CLexer, CppLexer 

19from pygments.lexers import _mql_builtins 

20 

21__all__ = ['PikeLexer', 'NesCLexer', 'ClayLexer', 'ECLexer', 'ValaLexer', 

22 'CudaLexer', 'SwigLexer', 'MqlLexer', 'ArduinoLexer', 'CharmciLexer', 

23 'OmgIdlLexer', 'PromelaLexer'] 

24 

25 

26class PikeLexer(CppLexer): 

27 """ 

28 For `Pike <http://pike.lysator.liu.se/>`_ source code. 

29 """ 

30 name = 'Pike' 

31 aliases = ['pike'] 

32 filenames = ['*.pike', '*.pmod'] 

33 mimetypes = ['text/x-pike'] 

34 version_added = '2.0' 

35 

36 tokens = { 

37 'statements': [ 

38 (words(( 

39 'catch', 'new', 'private', 'protected', 'public', 'gauge', 

40 'throw', 'throws', 'class', 'interface', 'implement', 'abstract', 

41 'extends', 'from', 'this', 'super', 'constant', 'final', 'static', 

42 'import', 'use', 'extern', 'inline', 'proto', 'break', 'continue', 

43 'if', 'else', 'for', 'while', 'do', 'switch', 'case', 'as', 'in', 

44 'version', 'return', 'true', 'false', 'null', 

45 '__VERSION__', '__MAJOR__', '__MINOR__', '__BUILD__', '__REAL_VERSION__', 

46 '__REAL_MAJOR__', '__REAL_MINOR__', '__REAL_BUILD__', '__DATE__', '__TIME__', 

47 '__FILE__', '__DIR__', '__LINE__', '__AUTO_BIGNUM__', '__NT__', '__PIKE__', 

48 '__amigaos__', '_Pragma', 'static_assert', 'defined', 'sscanf'), suffix=r'\b'), 

49 Keyword), 

50 (r'(bool|int|long|float|short|double|char|string|object|void|mapping|' 

51 r'array|multiset|program|function|lambda|mixed|' 

52 r'[a-z_][a-z0-9_]*_t)\b', 

53 Keyword.Type), 

54 (r'(class)(\s+)', bygroups(Keyword, Whitespace), 'classname'), 

55 (r'[~!%^&*+=|?:<>/@-]', Operator), 

56 inherit, 

57 ], 

58 'classname': [ 

59 (r'[a-zA-Z_]\w*', Name.Class, '#pop'), 

60 # template specification 

61 (r'\s*(?=>)', Whitespace, '#pop'), 

62 ], 

63 } 

64 

65 

66class NesCLexer(CLexer): 

67 """ 

68 For `nesC <https://github.com/tinyos/nesc>`_ source code with preprocessor 

69 directives. 

70 """ 

71 name = 'nesC' 

72 aliases = ['nesc'] 

73 filenames = ['*.nc'] 

74 mimetypes = ['text/x-nescsrc'] 

75 version_added = '2.0' 

76 

77 tokens = { 

78 'statements': [ 

79 (words(( 

80 'abstract', 'as', 'async', 'atomic', 'call', 'command', 'component', 

81 'components', 'configuration', 'event', 'extends', 'generic', 

82 'implementation', 'includes', 'interface', 'module', 'new', 'norace', 

83 'post', 'provides', 'signal', 'task', 'uses'), suffix=r'\b'), 

84 Keyword), 

85 (words(('nx_struct', 'nx_union', 'nx_int8_t', 'nx_int16_t', 'nx_int32_t', 

86 'nx_int64_t', 'nx_uint8_t', 'nx_uint16_t', 'nx_uint32_t', 

87 'nx_uint64_t'), suffix=r'\b'), 

88 Keyword.Type), 

89 inherit, 

90 ], 

91 } 

92 

93 

94class ClayLexer(RegexLexer): 

95 """ 

96 For Clay source. 

97 """ 

98 name = 'Clay' 

99 filenames = ['*.clay'] 

100 aliases = ['clay'] 

101 mimetypes = ['text/x-clay'] 

102 url = 'http://claylabs.com/clay' 

103 version_added = '2.0' 

104 

105 tokens = { 

106 'root': [ 

107 (r'\s+', Whitespace), 

108 (r'//.*?$', Comment.Single), 

109 (r'/(\\\n)?[*][\s\S]*?[*](\\\n)?/', Comment.Multiline), 

110 (words(('public', 'private', 'import', 'as', 'record', 'variant', 

111 'instance', 'define', 'overload', 'default', 

112 'external', 'alias', 'rvalue', 'ref', 

113 'forward', 'inline', 'noinline', 

114 'forceinline', 'enum', 'var', 'and', 'or', 

115 'not', 'if', 'else', 'goto', 'return', 

116 'while', 'switch', 'case', 'break', 

117 'continue', 'for', 'in', 'true', 'false', 

118 'try', 'catch', 'throw', 'finally', 

119 'onerror', 'staticassert', 'eval', 'when', 

120 'newtype', '__FILE__', '__LINE__', 

121 '__COLUMN__', '__ARG__'), prefix=r'\b', suffix=r'\b'), Keyword), 

122 (r'[~!%^&*+=|:<>/-]', Operator), 

123 (r'[#(){}\[\],;.]', Punctuation), 

124 (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex), 

125 (r'\d+[LlUu]*', Number.Integer), 

126 (r'\b(true|false)\b', Name.Builtin), 

127 (r'(?i)[a-z_?][\w?]*', Name), 

128 (r'"""', String, 'tdqs'), 

129 (r'"', String, 'dqs'), 

130 ], 

131 'strings': [ 

132 (r'(?i)\\(x[0-9a-f]{2}|.)', String.Escape), 

133 (r'[^\\"]+', String), 

134 ], 

135 'nl': [ 

136 (r'\n', String), 

137 ], 

138 'dqs': [ 

139 (r'"', String, '#pop'), 

140 include('strings'), 

141 ], 

142 'tdqs': [ 

143 (r'"""', String, '#pop'), 

144 include('strings'), 

145 include('nl'), 

146 ], 

147 } 

148 

149 

150class ECLexer(CLexer): 

151 """ 

152 For eC source code with preprocessor directives. 

153 """ 

154 name = 'eC' 

155 aliases = ['ec'] 

156 filenames = ['*.ec', '*.eh'] 

157 mimetypes = ['text/x-echdr', 'text/x-ecsrc'] 

158 url = 'https://ec-lang.org' 

159 version_added = '1.5' 

160 

161 tokens = { 

162 'statements': [ 

163 (words(( 

164 'virtual', 'class', 'private', 'public', 'property', 'import', 

165 'delete', 'new', 'new0', 'renew', 'renew0', 'define', 'get', 

166 'set', 'remote', 'dllexport', 'dllimport', 'stdcall', 'subclass', 

167 '__on_register_module', 'namespace', 'using', 'typed_object', 

168 'any_object', 'incref', 'register', 'watch', 'stopwatching', 'firewatchers', 

169 'watchable', 'class_designer', 'class_fixed', 'class_no_expansion', 'isset', 

170 'class_default_property', 'property_category', 'class_data', 

171 'class_property', 'thisclass', 'dbtable', 'dbindex', 

172 'database_open', 'dbfield'), suffix=r'\b'), Keyword), 

173 (words(('uint', 'uint16', 'uint32', 'uint64', 'bool', 'byte', 

174 'unichar', 'int64'), suffix=r'\b'), 

175 Keyword.Type), 

176 (r'(class)(\s+)', bygroups(Keyword, Whitespace), 'classname'), 

177 (r'(null|value|this)\b', Name.Builtin), 

178 inherit, 

179 ] 

180 } 

181 

182 

183class ValaLexer(RegexLexer): 

184 """ 

185 For Vala source code with preprocessor directives. 

186 """ 

187 name = 'Vala' 

188 aliases = ['vala', 'vapi'] 

189 filenames = ['*.vala', '*.vapi'] 

190 mimetypes = ['text/x-vala'] 

191 url = 'https://vala.dev' 

192 version_added = '1.1' 

193 

194 tokens = { 

195 'whitespace': [ 

196 (r'^\s*#if\s+0', Comment.Preproc, 'if0'), 

197 (r'^\s*#(?:if|elif|else|endif)\b[^\n]*', Comment.Preproc), 

198 (r'\n', Whitespace), 

199 (r'\s+', Whitespace), 

200 (r'\\\n', Text), # line continuation 

201 (r'//(\n|[\s\S]*?[^\\]\n)', Comment.Single), 

202 (r'/(\\\n)?[*][\s\S]*?[*](\\\n)?/', Comment.Multiline), 

203 ], 

204 'statements': [ 

205 (r'(?s)""".*?"""', String), # verbatim strings 

206 (r'[L@]?"', String, 'string'), 

207 (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", 

208 String.Char), 

209 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float), 

210 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float), 

211 (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex), 

212 (r'0[0-7]+[Ll]?', Number.Oct), 

213 (r'\d+[Ll]?', Number.Integer), 

214 (r'[~!%^&*+=|?:<>/-]', Operator), 

215 (r'(\[)(Compact|Immutable|(?:Boolean|Simple)Type)(\])', 

216 bygroups(Punctuation, Name.Decorator, Punctuation)), 

217 # TODO: "correctly" parse complex code attributes 

218 (r'(\[)(CCode|(?:Integer|Floating)Type)', 

219 bygroups(Punctuation, Name.Decorator)), 

220 (r'[()\[\],.]', Punctuation), 

221 (words(( 

222 'as', 'base', 'break', 'case', 'catch', 'construct', 'continue', 

223 'default', 'delete', 'do', 'else', 'enum', 'finally', 'for', 

224 'foreach', 'get', 'if', 'in', 'is', 'lock', 'new', 'out', 'params', 

225 'return', 'set', 'sizeof', 'switch', 'this', 'throw', 'try', 

226 'typeof', 'while', 'yield'), suffix=r'\b'), 

227 Keyword), 

228 (words(( 

229 'abstract', 'const', 'delegate', 'dynamic', 'ensures', 'extern', 

230 'inline', 'internal', 'override', 'owned', 'private', 'protected', 

231 'public', 'ref', 'requires', 'signal', 'static', 'throws', 'unowned', 

232 'var', 'virtual', 'volatile', 'weak', 'yields'), suffix=r'\b'), 

233 Keyword.Declaration), 

234 (r'(namespace|using)(\s+)', bygroups(Keyword.Namespace, Whitespace), 

235 'namespace'), 

236 (r'(class|errordomain|interface|struct)(\s+)', 

237 bygroups(Keyword.Declaration, Whitespace), 'class'), 

238 (r'(\.)([a-zA-Z_]\w*)', 

239 bygroups(Operator, Name.Attribute)), 

240 # void is an actual keyword, others are in glib-2.0.vapi 

241 (words(( 

242 'void', 'bool', 'char', 'double', 'float', 'int', 'int8', 'int16', 

243 'int32', 'int64', 'long', 'short', 'size_t', 'ssize_t', 'string', 

244 'time_t', 'uchar', 'uint', 'uint8', 'uint16', 'uint32', 'uint64', 

245 'ulong', 'unichar', 'ushort'), suffix=r'\b'), 

246 Keyword.Type), 

247 (r'(true|false|null)\b', Name.Builtin), 

248 (r'[a-zA-Z_]\w*', Name), 

249 ], 

250 'root': [ 

251 include('whitespace'), 

252 default('statement'), 

253 ], 

254 'statement': [ 

255 include('whitespace'), 

256 include('statements'), 

257 ('[{}]', Punctuation), 

258 (';', Punctuation, '#pop'), 

259 ], 

260 'string': [ 

261 (r'"', String, '#pop'), 

262 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape), 

263 (r'[^\\"\n]+', String), # all other characters 

264 (r'\\\n', String), # line continuation 

265 (r'\\', String), # stray backslash 

266 ], 

267 'if0': [ 

268 (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'), 

269 (r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'), 

270 (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'), 

271 (r'.*?\n', Comment), 

272 ], 

273 'class': [ 

274 (r'[a-zA-Z_]\w*', Name.Class, '#pop') 

275 ], 

276 'namespace': [ 

277 (r'[a-zA-Z_][\w.]*', Name.Namespace, '#pop') 

278 ], 

279 } 

280 

281 

282class CudaLexer(CppLexer): 

283 """ 

284 For NVIDIA CUDA™ source. 

285 """ 

286 name = 'CUDA' 

287 filenames = ['*.cu', '*.cuh'] 

288 aliases = ['cuda', 'cu'] 

289 mimetypes = ['text/x-cuda'] 

290 url = 'https://developer.nvidia.com/category/zone/cuda-zone' 

291 version_added = '1.6' 

292 

293 function_qualifiers = {'__device__', '__global__', '__host__', 

294 '__noinline__', '__forceinline__'} 

295 variable_qualifiers = {'__device__', '__constant__', '__shared__', 

296 '__restrict__'} 

297 vector_types = {'char1', 'uchar1', 'char2', 'uchar2', 'char3', 'uchar3', 

298 'char4', 'uchar4', 'short1', 'ushort1', 'short2', 'ushort2', 

299 'short3', 'ushort3', 'short4', 'ushort4', 'int1', 'uint1', 

300 'int2', 'uint2', 'int3', 'uint3', 'int4', 'uint4', 'long1', 

301 'ulong1', 'long2', 'ulong2', 'long3', 'ulong3', 'long4', 

302 'ulong4', 'longlong1', 'ulonglong1', 'longlong2', 

303 'ulonglong2', 'float1', 'float2', 'float3', 'float4', 

304 'double1', 'double2', 'dim3'} 

305 variables = {'gridDim', 'blockIdx', 'blockDim', 'threadIdx', 'warpSize'} 

306 functions = {'__threadfence_block', '__threadfence', '__threadfence_system', 

307 '__syncthreads', '__syncthreads_count', '__syncthreads_and', 

308 '__syncthreads_or'} 

309 execution_confs = {'<<<', '>>>'} 

310 

311 def get_tokens_unprocessed(self, text, stack=('root',)): 

312 for index, token, value in CppLexer.get_tokens_unprocessed(self, text, stack): 

313 if token is Name: 

314 if value in self.variable_qualifiers: 

315 token = Keyword.Type 

316 elif value in self.vector_types: 

317 token = Keyword.Type 

318 elif value in self.variables: 

319 token = Name.Builtin 

320 elif value in self.execution_confs: 

321 token = Keyword.Pseudo 

322 elif value in self.function_qualifiers: 

323 token = Keyword.Reserved 

324 elif value in self.functions: 

325 token = Name.Function 

326 yield index, token, value 

327 

328 

329class SwigLexer(CppLexer): 

330 """ 

331 For `SWIG <http://www.swig.org/>`_ source code. 

332 """ 

333 name = 'SWIG' 

334 aliases = ['swig'] 

335 filenames = ['*.swg', '*.i'] 

336 mimetypes = ['text/swig'] 

337 version_added = '2.0' 

338 priority = 0.04 # Lower than C/C++ and Objective C/C++ 

339 

340 tokens = { 

341 'root': [ 

342 # Match it here so it won't be matched as a function in the rest of root 

343 (r'\$\**\&?\w+', Name), 

344 inherit 

345 ], 

346 'statements': [ 

347 # SWIG directives 

348 (r'(%[a-z_][a-z0-9_]*)', Name.Function), 

349 # Special variables 

350 (r'\$\**\&?\w+', Name), 

351 # Stringification / additional preprocessor directives 

352 (r'##*[a-zA-Z_]\w*', Comment.Preproc), 

353 inherit, 

354 ], 

355 } 

356 

357 # This is a far from complete set of SWIG directives 

358 swig_directives = { 

359 # Most common directives 

360 '%apply', '%define', '%director', '%enddef', '%exception', '%extend', 

361 '%feature', '%fragment', '%ignore', '%immutable', '%import', '%include', 

362 '%inline', '%insert', '%module', '%newobject', '%nspace', '%pragma', 

363 '%rename', '%shared_ptr', '%template', '%typecheck', '%typemap', 

364 # Less common directives 

365 '%arg', '%attribute', '%bang', '%begin', '%callback', '%catches', '%clear', 

366 '%constant', '%copyctor', '%csconst', '%csconstvalue', '%csenum', 

367 '%csmethodmodifiers', '%csnothrowexception', '%default', '%defaultctor', 

368 '%defaultdtor', '%defined', '%delete', '%delobject', '%descriptor', 

369 '%exceptionclass', '%exceptionvar', '%extend_smart_pointer', '%fragments', 

370 '%header', '%ifcplusplus', '%ignorewarn', '%implicit', '%implicitconv', 

371 '%init', '%javaconst', '%javaconstvalue', '%javaenum', '%javaexception', 

372 '%javamethodmodifiers', '%kwargs', '%luacode', '%mutable', '%naturalvar', 

373 '%nestedworkaround', '%perlcode', '%pythonabc', '%pythonappend', 

374 '%pythoncallback', '%pythoncode', '%pythondynamic', '%pythonmaybecall', 

375 '%pythonnondynamic', '%pythonprepend', '%refobject', '%shadow', '%sizeof', 

376 '%trackobjects', '%types', '%unrefobject', '%varargs', '%warn', 

377 '%warnfilter'} 

378 

379 def analyse_text(text): 

380 rv = 0 

381 # Search for SWIG directives, which are conventionally at the beginning of 

382 # a line. The probability of them being within a line is low, so let another 

383 # lexer win in this case. 

384 matches = re.findall(r'^\s*(%[a-z_][a-z0-9_]*)', text, re.M) 

385 for m in matches: 

386 if m in SwigLexer.swig_directives: 

387 rv = 0.98 

388 break 

389 else: 

390 rv = 0.91 # Fraction higher than MatlabLexer 

391 return rv 

392 

393 

394class MqlLexer(CppLexer): 

395 """ 

396 For `MQL4 <http://docs.mql4.com/>`_ and 

397 `MQL5 <http://www.mql5.com/en/docs>`_ source code. 

398 """ 

399 name = 'MQL' 

400 aliases = ['mql', 'mq4', 'mq5', 'mql4', 'mql5'] 

401 filenames = ['*.mq4', '*.mq5', '*.mqh'] 

402 mimetypes = ['text/x-mql'] 

403 version_added = '2.0' 

404 

405 tokens = { 

406 'statements': [ 

407 (words(_mql_builtins.keywords, suffix=r'\b'), Keyword), 

408 (words(_mql_builtins.c_types, suffix=r'\b'), Keyword.Type), 

409 (words(_mql_builtins.types, suffix=r'\b'), Name.Function), 

410 (words(_mql_builtins.constants, suffix=r'\b'), Name.Constant), 

411 (words(_mql_builtins.colors, prefix='(clr)?', suffix=r'\b'), 

412 Name.Constant), 

413 inherit, 

414 ], 

415 } 

416 

417 

418class ArduinoLexer(CppLexer): 

419 """ 

420 For `Arduino(tm) <https://arduino.cc/>`_ source. 

421 

422 This is an extension of the CppLexer, as the Arduino® Language is a superset 

423 of C++ 

424 """ 

425 

426 name = 'Arduino' 

427 aliases = ['arduino'] 

428 filenames = ['*.ino'] 

429 mimetypes = ['text/x-arduino'] 

430 version_added = '2.1' 

431 

432 # Language sketch main structure functions 

433 structure = {'setup', 'loop'} 

434 

435 # Language operators 

436 operators = {'not', 'or', 'and', 'xor'} 

437 

438 # Language 'variables' 

439 variables = { 

440 'DIGITAL_MESSAGE', 'FIRMATA_STRING', 'ANALOG_MESSAGE', 'REPORT_DIGITAL', 

441 'REPORT_ANALOG', 'INPUT_PULLUP', 'SET_PIN_MODE', 'INTERNAL2V56', 'SYSTEM_RESET', 

442 'LED_BUILTIN', 'INTERNAL1V1', 'SYSEX_START', 'INTERNAL', 'EXTERNAL', 'HIGH', 

443 'LOW', 'INPUT', 'OUTPUT', 'INPUT_PULLUP', 'LED_BUILTIN', 'true', 'false', 

444 'void', 'boolean', 'char', 'unsigned char', 'byte', 'int', 'unsigned int', 

445 'word', 'long', 'unsigned long', 'short', 'float', 'double', 'string', 'String', 

446 'array', 'static', 'volatile', 'const', 'boolean', 'byte', 'word', 'string', 

447 'String', 'array', 'int', 'float', 'private', 'char', 'virtual', 'operator', 

448 'sizeof', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int8_t', 'int16_t', 

449 'int32_t', 'int64_t', 'dynamic_cast', 'typedef', 'const_cast', 'const', 

450 'struct', 'static_cast', 'union', 'unsigned', 'long', 'volatile', 'static', 

451 'protected', 'bool', 'public', 'friend', 'auto', 'void', 'enum', 'extern', 

452 'class', 'short', 'reinterpret_cast', 'double', 'register', 'explicit', 

453 'signed', 'inline', 'delete', '_Bool', 'complex', '_Complex', '_Imaginary', 

454 'atomic_bool', 'atomic_char', 'atomic_schar', 'atomic_uchar', 'atomic_short', 

455 'atomic_ushort', 'atomic_int', 'atomic_uint', 'atomic_long', 'atomic_ulong', 

456 'atomic_llong', 'atomic_ullong', 'PROGMEM'} 

457 

458 # Language shipped functions and class ( ) 

459 functions = { 

460 'KeyboardController', 'MouseController', 'SoftwareSerial', 'EthernetServer', 

461 'EthernetClient', 'LiquidCrystal', 'RobotControl', 'GSMVoiceCall', 

462 'EthernetUDP', 'EsploraTFT', 'HttpClient', 'RobotMotor', 'WiFiClient', 

463 'GSMScanner', 'FileSystem', 'Scheduler', 'GSMServer', 'YunClient', 'YunServer', 

464 'IPAddress', 'GSMClient', 'GSMModem', 'Keyboard', 'Ethernet', 'Console', 

465 'GSMBand', 'Esplora', 'Stepper', 'Process', 'WiFiUDP', 'GSM_SMS', 'Mailbox', 

466 'USBHost', 'Firmata', 'PImage', 'Client', 'Server', 'GSMPIN', 'FileIO', 

467 'Bridge', 'Serial', 'EEPROM', 'Stream', 'Mouse', 'Audio', 'Servo', 'File', 

468 'Task', 'GPRS', 'WiFi', 'Wire', 'TFT', 'GSM', 'SPI', 'SD', 

469 'runShellCommandAsynchronously', 'analogWriteResolution', 

470 'retrieveCallingNumber', 'printFirmwareVersion', 'analogReadResolution', 

471 'sendDigitalPortPair', 'noListenOnLocalhost', 'readJoystickButton', 

472 'setFirmwareVersion', 'readJoystickSwitch', 'scrollDisplayRight', 

473 'getVoiceCallStatus', 'scrollDisplayLeft', 'writeMicroseconds', 

474 'delayMicroseconds', 'beginTransmission', 'getSignalStrength', 

475 'runAsynchronously', 'getAsynchronously', 'listenOnLocalhost', 

476 'getCurrentCarrier', 'readAccelerometer', 'messageAvailable', 

477 'sendDigitalPorts', 'lineFollowConfig', 'countryNameWrite', 'runShellCommand', 

478 'readStringUntil', 'rewindDirectory', 'readTemperature', 'setClockDivider', 

479 'readLightSensor', 'endTransmission', 'analogReference', 'detachInterrupt', 

480 'countryNameRead', 'attachInterrupt', 'encryptionType', 'readBytesUntil', 

481 'robotNameWrite', 'readMicrophone', 'robotNameRead', 'cityNameWrite', 

482 'userNameWrite', 'readJoystickY', 'readJoystickX', 'mouseReleased', 

483 'openNextFile', 'scanNetworks', 'noInterrupts', 'digitalWrite', 'beginSpeaker', 

484 'mousePressed', 'isActionDone', 'mouseDragged', 'displayLogos', 'noAutoscroll', 

485 'addParameter', 'remoteNumber', 'getModifiers', 'keyboardRead', 'userNameRead', 

486 'waitContinue', 'processInput', 'parseCommand', 'printVersion', 'readNetworks', 

487 'writeMessage', 'blinkVersion', 'cityNameRead', 'readMessage', 'setDataMode', 

488 'parsePacket', 'isListening', 'setBitOrder', 'beginPacket', 'isDirectory', 

489 'motorsWrite', 'drawCompass', 'digitalRead', 'clearScreen', 'serialEvent', 

490 'rightToLeft', 'setTextSize', 'leftToRight', 'requestFrom', 'keyReleased', 

491 'compassRead', 'analogWrite', 'interrupts', 'WiFiServer', 'disconnect', 

492 'playMelody', 'parseFloat', 'autoscroll', 'getPINUsed', 'setPINUsed', 

493 'setTimeout', 'sendAnalog', 'readSlider', 'analogRead', 'beginWrite', 

494 'createChar', 'motorsStop', 'keyPressed', 'tempoWrite', 'readButton', 

495 'subnetMask', 'debugPrint', 'macAddress', 'writeGreen', 'randomSeed', 

496 'attachGPRS', 'readString', 'sendString', 'remotePort', 'releaseAll', 

497 'mouseMoved', 'background', 'getXChange', 'getYChange', 'answerCall', 

498 'getResult', 'voiceCall', 'endPacket', 'constrain', 'getSocket', 'writeJSON', 

499 'getButton', 'available', 'connected', 'findUntil', 'readBytes', 'exitValue', 

500 'readGreen', 'writeBlue', 'startLoop', 'IPAddress', 'isPressed', 'sendSysex', 

501 'pauseMode', 'gatewayIP', 'setCursor', 'getOemKey', 'tuneWrite', 'noDisplay', 

502 'loadImage', 'switchPIN', 'onRequest', 'onReceive', 'changePIN', 'playFile', 

503 'noBuffer', 'parseInt', 'overflow', 'checkPIN', 'knobRead', 'beginTFT', 

504 'bitClear', 'updateIR', 'bitWrite', 'position', 'writeRGB', 'highByte', 

505 'writeRed', 'setSpeed', 'readBlue', 'noStroke', 'remoteIP', 'transfer', 

506 'shutdown', 'hangCall', 'beginSMS', 'endWrite', 'attached', 'maintain', 

507 'noCursor', 'checkReg', 'checkPUK', 'shiftOut', 'isValid', 'shiftIn', 'pulseIn', 

508 'connect', 'println', 'localIP', 'pinMode', 'getIMEI', 'display', 'noBlink', 

509 'process', 'getBand', 'running', 'beginSD', 'drawBMP', 'lowByte', 'setBand', 

510 'release', 'bitRead', 'prepare', 'pointTo', 'readRed', 'setMode', 'noFill', 

511 'remove', 'listen', 'stroke', 'detach', 'attach', 'noTone', 'exists', 'buffer', 

512 'height', 'bitSet', 'circle', 'config', 'cursor', 'random', 'IRread', 'setDNS', 

513 'endSMS', 'getKey', 'micros', 'millis', 'begin', 'print', 'write', 'ready', 

514 'flush', 'width', 'isPIN', 'blink', 'clear', 'press', 'mkdir', 'rmdir', 'close', 

515 'point', 'yield', 'image', 'BSSID', 'click', 'delay', 'read', 'text', 'move', 

516 'peek', 'beep', 'rect', 'line', 'open', 'seek', 'fill', 'size', 'turn', 'stop', 

517 'home', 'find', 'step', 'tone', 'sqrt', 'RSSI', 'SSID', 'end', 'bit', 'tan', 

518 'cos', 'sin', 'pow', 'map', 'abs', 'max', 'min', 'get', 'run', 'put', 

519 'isAlphaNumeric', 'isAlpha', 'isAscii', 'isWhitespace', 'isControl', 'isDigit', 

520 'isGraph', 'isLowerCase', 'isPrintable', 'isPunct', 'isSpace', 'isUpperCase', 

521 'isHexadecimalDigit'} 

522 

523 # do not highlight 

524 suppress_highlight = { 

525 'namespace', 'template', 'mutable', 'using', 'asm', 'typeid', 

526 'typename', 'this', 'alignof', 'constexpr', 'decltype', 'noexcept', 

527 'static_assert', 'thread_local', 'restrict'} 

528 

529 def get_tokens_unprocessed(self, text, stack=('root',)): 

530 for index, token, value in CppLexer.get_tokens_unprocessed(self, text, stack): 

531 if value in self.structure: 

532 yield index, Name.Builtin, value 

533 elif value in self.operators: 

534 yield index, Operator, value 

535 elif value in self.variables: 

536 yield index, Keyword.Reserved, value 

537 elif value in self.suppress_highlight: 

538 yield index, Name, value 

539 elif value in self.functions: 

540 yield index, Name.Function, value 

541 else: 

542 yield index, token, value 

543 

544 

545class CharmciLexer(CppLexer): 

546 """ 

547 For `Charm++ <https://charm.cs.illinois.edu>`_ interface files (.ci). 

548 """ 

549 

550 name = 'Charmci' 

551 aliases = ['charmci'] 

552 filenames = ['*.ci'] 

553 version_added = '2.4' 

554 

555 mimetypes = [] 

556 

557 tokens = { 

558 'keywords': [ 

559 (r'(module)(\s+)', bygroups(Keyword, Text), 'classname'), 

560 (words(('mainmodule', 'mainchare', 'chare', 'array', 'group', 

561 'nodegroup', 'message', 'conditional')), Keyword), 

562 (words(('entry', 'aggregate', 'threaded', 'sync', 'exclusive', 

563 'nokeep', 'notrace', 'immediate', 'expedited', 'inline', 

564 'local', 'python', 'accel', 'readwrite', 'writeonly', 

565 'accelblock', 'memcritical', 'packed', 'varsize', 

566 'initproc', 'initnode', 'initcall', 'stacksize', 

567 'createhere', 'createhome', 'reductiontarget', 'iget', 

568 'nocopy', 'mutable', 'migratable', 'readonly')), Keyword), 

569 inherit, 

570 ], 

571 } 

572 

573 

574class OmgIdlLexer(CLexer): 

575 """ 

576 Lexer for Object Management Group Interface Definition Language. 

577 """ 

578 

579 name = 'OMG Interface Definition Language' 

580 url = 'https://www.omg.org/spec/IDL/About-IDL/' 

581 aliases = ['omg-idl'] 

582 filenames = ['*.idl', '*.pidl'] 

583 mimetypes = [] 

584 version_added = '2.9' 

585 

586 scoped_name = r'((::)?\w+)+' 

587 

588 tokens = { 

589 'values': [ 

590 (words(('true', 'false'), prefix=r'(?i)', suffix=r'\b'), Number), 

591 (r'([Ll]?)(")', bygroups(String.Affix, String.Double), 'string'), 

592 (r'([Ll]?)(\')(\\[^\']+)(\')', 

593 bygroups(String.Affix, String.Char, String.Escape, String.Char)), 

594 (r'([Ll]?)(\')(\\\')(\')', 

595 bygroups(String.Affix, String.Char, String.Escape, String.Char)), 

596 (r'([Ll]?)(\'.\')', bygroups(String.Affix, String.Char)), 

597 (r'[+-]?\d+(\.\d*)?[Ee][+-]?\d+', Number.Float), 

598 (r'[+-]?(\d+\.\d*)|(\d*\.\d+)([Ee][+-]?\d+)?', Number.Float), 

599 (r'(?i)[+-]?0x[0-9a-f]+', Number.Hex), 

600 (r'[+-]?[1-9]\d*', Number.Integer), 

601 (r'[+-]?0[0-7]*', Number.Oct), 

602 (r'[\+\-\*\/%^&\|~]', Operator), 

603 (words(('<<', '>>')), Operator), 

604 (scoped_name, Name), 

605 (r'[{};:,<>\[\]]', Punctuation), 

606 ], 

607 'annotation_params': [ 

608 include('whitespace'), 

609 (r'\(', Punctuation, '#push'), 

610 include('values'), 

611 (r'=', Punctuation), 

612 (r'\)', Punctuation, '#pop'), 

613 ], 

614 'annotation_params_maybe': [ 

615 (r'\(', Punctuation, 'annotation_params'), 

616 include('whitespace'), 

617 default('#pop'), 

618 ], 

619 'annotation_appl': [ 

620 (r'@' + scoped_name, Name.Decorator, 'annotation_params_maybe'), 

621 ], 

622 'enum': [ 

623 include('whitespace'), 

624 (r'[{,]', Punctuation), 

625 (r'\w+', Name.Constant), 

626 include('annotation_appl'), 

627 (r'\}', Punctuation, '#pop'), 

628 ], 

629 'root': [ 

630 include('whitespace'), 

631 (words(( 

632 'typedef', 'const', 

633 'in', 'out', 'inout', 'local', 

634 ), prefix=r'(?i)', suffix=r'\b'), Keyword.Declaration), 

635 (words(( 

636 'void', 'any', 'native', 'bitfield', 

637 'unsigned', 'boolean', 'char', 'wchar', 'octet', 'short', 'long', 

638 'int8', 'uint8', 'int16', 'int32', 'int64', 'uint16', 'uint32', 'uint64', 

639 'float', 'double', 'fixed', 

640 'sequence', 'string', 'wstring', 'map', 

641 ), prefix=r'(?i)', suffix=r'\b'), Keyword.Type), 

642 (words(( 

643 '@annotation', 'struct', 'union', 'bitset', 'interface', 

644 'exception', 'valuetype', 'eventtype', 'component', 

645 ), prefix=r'(?i)', suffix=r'(\s+)(\w+)'), bygroups(Keyword, Whitespace, Name.Class)), 

646 (words(( 

647 'abstract', 'alias', 'attribute', 'case', 'connector', 

648 'consumes', 'context', 'custom', 'default', 'emits', 'factory', 

649 'finder', 'getraises', 'home', 'import', 'manages', 'mirrorport', 

650 'multiple', 'Object', 'oneway', 'primarykey', 'private', 'port', 

651 'porttype', 'provides', 'public', 'publishes', 'raises', 

652 'readonly', 'setraises', 'supports', 'switch', 'truncatable', 

653 'typeid', 'typename', 'typeprefix', 'uses', 'ValueBase', 

654 ), prefix=r'(?i)', suffix=r'\b'), Keyword), 

655 (r'(?i)(enum|bitmask)(\s+)(\w+)', 

656 bygroups(Keyword, Whitespace, Name.Class), 'enum'), 

657 (r'(?i)(module)(\s+)(\w+)', 

658 bygroups(Keyword.Namespace, Whitespace, Name.Namespace)), 

659 (r'(\w+)(\s*)(=)', bygroups(Name.Constant, Whitespace, Operator)), 

660 (r'[\(\)]', Punctuation), 

661 include('values'), 

662 include('annotation_appl'), 

663 ], 

664 } 

665 

666 

667class PromelaLexer(CLexer): 

668 """ 

669 For the Promela language used with SPIN. 

670 """ 

671 

672 name = 'Promela' 

673 aliases = ['promela'] 

674 filenames = ['*.pml', '*.prom', '*.prm', '*.promela', '*.pr', '*.pm'] 

675 mimetypes = ['text/x-promela'] 

676 url = 'https://spinroot.com/spin/whatispin.html' 

677 version_added = '2.18' 

678 

679 # Promela's language reference: 

680 # https://spinroot.com/spin/Man/promela.html 

681 # Promela's grammar definition: 

682 # https://spinroot.com/spin/Man/grammar.html 

683 

684 tokens = { 

685 'statements': [ 

686 (r'(\[\]|<>|/\\|\\/)|(U|W|V)\b', Operator), # LTL Operators 

687 (r'@', Punctuation), #remoterefs 

688 (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)), 

689 inherit 

690 ], 

691 'types': [ 

692 # Predefined (data types) 

693 (words(( 

694 'bit', 'bool', 'byte', 'pid', 'short', 'int', 'unsigned'), 

695 suffix=r'\b'), 

696 Keyword.Type), 

697 ], 

698 'keywords': [ 

699 # ControlFlow 

700 (words(( 

701 'atomic', 'break', 'd_step', 'do', 'od', 'for', 'in', 'goto', 

702 'if', 'fi', 'unless'), suffix=r'\b'), 

703 Keyword), 

704 # BasicStatements 

705 (words(( 

706 'assert', 'get_priority', 'printf', 'printm', 'set_priority'), 

707 suffix=r'\b'), 

708 Name.Function), 

709 # Embedded C Code 

710 (words(( 

711 'c_code', 'c_decl', 'c_expr', 'c_state', 'c_track'), 

712 suffix=r'\b'), 

713 Keyword), 

714 # Predefined (local/global variables) 

715 (words(( 

716 '_', '_last', '_nr_pr', '_pid', '_priority', 'else', 'np_', 

717 'STDIN'), suffix=r'\b'), 

718 Name.Builtin), 

719 # Predefined (functions) 

720 (words(( 

721 'empty', 'enabled', 'eval', 'full', 'len', 'nempty', 'nfull', 

722 'pc_value'), suffix=r'\b'), 

723 Name.Function), 

724 # Predefined (operators) 

725 (r'run\b', Operator.Word), 

726 # Declarators 

727 (words(( 

728 'active', 'chan', 'D_proctype', 'hidden', 'init', 'local', 

729 'mtype', 'never', 'notrace', 'proctype', 'show', 'trace', 

730 'typedef', 'xr', 'xs'), suffix=r'\b'), 

731 Keyword.Declaration), 

732 # Declarators (suffixes) 

733 (words(( 

734 'priority', 'provided'), suffix=r'\b'), 

735 Keyword), 

736 # MetaTerms (declarators) 

737 (words(( 

738 'inline', 'ltl', 'select'), suffix=r'\b'), 

739 Keyword.Declaration), 

740 # MetaTerms (keywords) 

741 (r'skip\b', Keyword), 

742 ], 

743 }