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

123 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-01 06:54 +0000

1""" 

2 pygments.lexers.c_like 

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

4 

5 Lexers for other C-like languages. 

6 

7 :copyright: Copyright 2006-2023 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'] 

24 

25 

26class PikeLexer(CppLexer): 

27 """ 

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

29 

30 .. versionadded:: 2.0 

31 """ 

32 name = 'Pike' 

33 aliases = ['pike'] 

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

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

36 

37 tokens = { 

38 'statements': [ 

39 (words(( 

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

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

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

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

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

45 'version', 'return', 'true', 'false', 'null', 

46 '__VERSION__', '__MAJOR__', '__MINOR__', '__BUILD__', '__REAL_VERSION__', 

47 '__REAL_MAJOR__', '__REAL_MINOR__', '__REAL_BUILD__', '__DATE__', '__TIME__', 

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

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

50 Keyword), 

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

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

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

54 Keyword.Type), 

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

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

57 inherit, 

58 ], 

59 'classname': [ 

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

61 # template specification 

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

63 ], 

64 } 

65 

66 

67class NesCLexer(CLexer): 

68 """ 

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

70 directives. 

71 

72 .. versionadded:: 2.0 

73 """ 

74 name = 'nesC' 

75 aliases = ['nesc'] 

76 filenames = ['*.nc'] 

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

78 

79 tokens = { 

80 'statements': [ 

81 (words(( 

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

83 'components', 'configuration', 'event', 'extends', 'generic', 

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

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

86 Keyword), 

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

88 'nx_int64_t', 'nx_uint8_t', 'nx_uint16_t', 'nx_uint32_t', 

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

90 Keyword.Type), 

91 inherit, 

92 ], 

93 } 

94 

95 

96class ClayLexer(RegexLexer): 

97 """ 

98 For `Clay <http://claylabs.com/clay/>`_ source. 

99 

100 .. versionadded:: 2.0 

101 """ 

102 name = 'Clay' 

103 filenames = ['*.clay'] 

104 aliases = ['clay'] 

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

106 tokens = { 

107 'root': [ 

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

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

110 (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline), 

111 (r'\b(public|private|import|as|record|variant|instance' 

112 r'|define|overload|default|external|alias' 

113 r'|rvalue|ref|forward|inline|noinline|forceinline' 

114 r'|enum|var|and|or|not|if|else|goto|return|while' 

115 r'|switch|case|break|continue|for|in|true|false|try|catch|throw' 

116 r'|finally|onerror|staticassert|eval|when|newtype' 

117 r'|__FILE__|__LINE__|__COLUMN__|__ARG__' 

118 r')\b', Keyword), 

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

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

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

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

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

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

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

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

127 ], 

128 'strings': [ 

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

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

131 ], 

132 'nl': [ 

133 (r'\n', String), 

134 ], 

135 'dqs': [ 

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

137 include('strings'), 

138 ], 

139 'tdqs': [ 

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

141 include('strings'), 

142 include('nl'), 

143 ], 

144 } 

145 

146 

147class ECLexer(CLexer): 

148 """ 

149 For eC source code with preprocessor directives. 

150 

151 .. versionadded:: 1.5 

152 """ 

153 name = 'eC' 

154 aliases = ['ec'] 

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

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

157 

158 tokens = { 

159 'statements': [ 

160 (words(( 

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

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

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

164 '__on_register_module', 'namespace', 'using', 'typed_object', 

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

166 'watchable', 'class_designer', 'class_fixed', 'class_no_expansion', 'isset', 

167 'class_default_property', 'property_category', 'class_data', 

168 'class_property', 'thisclass', 'dbtable', 'dbindex', 

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

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

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

172 Keyword.Type), 

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

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

175 inherit, 

176 ] 

177 } 

178 

179 

180class ValaLexer(RegexLexer): 

181 """ 

182 For Vala source code with preprocessor directives. 

183 

184 .. versionadded:: 1.1 

185 """ 

186 name = 'Vala' 

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

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

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

190 

191 tokens = { 

192 'whitespace': [ 

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

194 (r'\n', Whitespace), 

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

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

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

198 (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline), 

199 ], 

200 'statements': [ 

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

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

203 String.Char), 

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

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

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

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

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

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

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

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

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

213 # TODO: "correctly" parse complex code attributes 

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

215 bygroups(Punctuation, Name.Decorator)), 

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

217 (words(( 

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

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

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

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

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

223 Keyword), 

224 (words(( 

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

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

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

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

229 Keyword.Declaration), 

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

231 'namespace'), 

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

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

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

235 bygroups(Operator, Name.Attribute)), 

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

237 (words(( 

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

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

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

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

242 Keyword.Type), 

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

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

245 ], 

246 'root': [ 

247 include('whitespace'), 

248 default('statement'), 

249 ], 

250 'statement': [ 

251 include('whitespace'), 

252 include('statements'), 

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

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

255 ], 

256 'string': [ 

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

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

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

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

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

262 ], 

263 'if0': [ 

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

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

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

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

268 ], 

269 'class': [ 

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

271 ], 

272 'namespace': [ 

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

274 ], 

275 } 

276 

277 

278class CudaLexer(CLexer): 

279 """ 

280 For NVIDIA `CUDA™ <http://developer.nvidia.com/category/zone/cuda-zone>`_ 

281 source. 

282 

283 .. versionadded:: 1.6 

284 """ 

285 name = 'CUDA' 

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

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

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

289 

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

291 '__noinline__', '__forceinline__'} 

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

293 '__restrict__'} 

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

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

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

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

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

299 'ulong4', 'longlong1', 'ulonglong1', 'longlong2', 

300 'ulonglong2', 'float1', 'float2', 'float3', 'float4', 

301 'double1', 'double2', 'dim3'} 

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

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

304 '__syncthreads', '__syncthreads_count', '__syncthreads_and', 

305 '__syncthreads_or'} 

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

307 

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

309 for index, token, value in CLexer.get_tokens_unprocessed(self, text, stack): 

310 if token is Name: 

311 if value in self.variable_qualifiers: 

312 token = Keyword.Type 

313 elif value in self.vector_types: 

314 token = Keyword.Type 

315 elif value in self.variables: 

316 token = Name.Builtin 

317 elif value in self.execution_confs: 

318 token = Keyword.Pseudo 

319 elif value in self.function_qualifiers: 

320 token = Keyword.Reserved 

321 elif value in self.functions: 

322 token = Name.Function 

323 yield index, token, value 

324 

325 

326class SwigLexer(CppLexer): 

327 """ 

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

329 

330 .. versionadded:: 2.0 

331 """ 

332 name = 'SWIG' 

333 aliases = ['swig'] 

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

335 mimetypes = ['text/swig'] 

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

337 

338 tokens = { 

339 'root': [ 

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

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

342 inherit 

343 ], 

344 'statements': [ 

345 # SWIG directives 

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

347 # Special variables 

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

349 # Stringification / additional preprocessor directives 

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

351 inherit, 

352 ], 

353 } 

354 

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

356 swig_directives = { 

357 # Most common directives 

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

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

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

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

362 # Less common directives 

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

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

365 '%csmethodmodifiers', '%csnothrowexception', '%default', '%defaultctor', 

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

367 '%exceptionclass', '%exceptionvar', '%extend_smart_pointer', '%fragments', 

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

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

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

371 '%nestedworkaround', '%perlcode', '%pythonabc', '%pythonappend', 

372 '%pythoncallback', '%pythoncode', '%pythondynamic', '%pythonmaybecall', 

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

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

375 '%warnfilter'} 

376 

377 def analyse_text(text): 

378 rv = 0 

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

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

381 # lexer win in this case. 

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

383 for m in matches: 

384 if m in SwigLexer.swig_directives: 

385 rv = 0.98 

386 break 

387 else: 

388 rv = 0.91 # Fraction higher than MatlabLexer 

389 return rv 

390 

391 

392class MqlLexer(CppLexer): 

393 """ 

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

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

396 

397 .. versionadded:: 2.0 

398 """ 

399 name = 'MQL' 

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

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

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

403 

404 tokens = { 

405 'statements': [ 

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

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

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

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

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

411 Name.Constant), 

412 inherit, 

413 ], 

414 } 

415 

416 

417class ArduinoLexer(CppLexer): 

418 """ 

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

420 

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

422 of C++ 

423 

424 .. versionadded:: 2.1 

425 """ 

426 

427 name = 'Arduino' 

428 aliases = ['arduino'] 

429 filenames = ['*.ino'] 

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

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 .. versionadded:: 2.4 

550 """ 

551 

552 name = 'Charmci' 

553 aliases = ['charmci'] 

554 filenames = ['*.ci'] 

555 

556 mimetypes = [] 

557 

558 tokens = { 

559 'keywords': [ 

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

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

562 'nodegroup', 'message', 'conditional')), Keyword), 

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

564 'nokeep', 'notrace', 'immediate', 'expedited', 'inline', 

565 'local', 'python', 'accel', 'readwrite', 'writeonly', 

566 'accelblock', 'memcritical', 'packed', 'varsize', 

567 'initproc', 'initnode', 'initcall', 'stacksize', 

568 'createhere', 'createhome', 'reductiontarget', 'iget', 

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

570 inherit, 

571 ], 

572 } 

573 

574 

575class OmgIdlLexer(CLexer): 

576 """ 

577 Lexer for Object Management Group Interface Definition Language. 

578 

579 .. versionadded:: 2.9 

580 """ 

581 

582 name = 'OMG Interface Definition Language' 

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

584 aliases = ['omg-idl'] 

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

586 mimetypes = [] 

587 

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

589 

590 tokens = { 

591 'values': [ 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

606 (scoped_name, Name), 

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

608 ], 

609 'annotation_params': [ 

610 include('whitespace'), 

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

612 include('values'), 

613 (r'=', Punctuation), 

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

615 ], 

616 'annotation_params_maybe': [ 

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

618 include('whitespace'), 

619 default('#pop'), 

620 ], 

621 'annotation_appl': [ 

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

623 ], 

624 'enum': [ 

625 include('whitespace'), 

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

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

628 include('annotation_appl'), 

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

630 ], 

631 'root': [ 

632 include('whitespace'), 

633 (words(( 

634 'typedef', 'const', 

635 'in', 'out', 'inout', 'local', 

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

637 (words(( 

638 'void', 'any', 'native', 'bitfield', 

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

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

641 'float', 'double', 'fixed', 

642 'sequence', 'string', 'wstring', 'map', 

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

644 (words(( 

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

646 'exception', 'valuetype', 'eventtype', 'component', 

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

648 (words(( 

649 'abstract', 'alias', 'attribute', 'case', 'connector', 

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

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

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

653 'porttype', 'provides', 'public', 'publishes', 'raises', 

654 'readonly', 'setraises', 'supports', 'switch', 'truncatable', 

655 'typeid', 'typename', 'typeprefix', 'uses', 'ValueBase', 

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

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

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

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

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

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

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

663 include('values'), 

664 include('annotation_appl'), 

665 ], 

666 }