1# -*- coding: utf-8 -*-
2"""
3    pygments.lexers.c_like
4    ~~~~~~~~~~~~~~~~~~~~~~
5
6    Lexers for other C-like languages.
7
8    :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9    :license: BSD, see LICENSE for details.
10"""
11
12import re
13
14from pygments.lexer import RegexLexer, include, bygroups, inherit, words, \
15    default
16from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
17    Number, Punctuation
18
19from pygments.lexers.c_cpp import CLexer, CppLexer
20from pygments.lexers import _mql_builtins
21
22__all__ = ['PikeLexer', 'NesCLexer', 'ClayLexer', 'ECLexer', 'ValaLexer',
23           'CudaLexer', 'SwigLexer', 'MqlLexer', 'ArduinoLexer', 'CharmciLexer']
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', 'extends', 'from',
42                'this', 'super', 'constant', 'final', 'static', 'import', 'use', 'extern',
43                'inline', 'proto', 'break', 'continue', 'if', 'else', 'for',
44                'while', 'do', 'switch', 'case', 'as', 'in', '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, Text), 'classname'),
55            (r'[~!%^&*+=|?:<>/@-]', Operator),
56            inherit,
57        ],
58        'classname': [
59            (r'[a-zA-Z_]\w*', Name.Class, '#pop'),
60            # template specification
61            (r'\s*(?=>)', Text, '#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    .. versionadded:: 2.0
72    """
73    name = 'nesC'
74    aliases = ['nesc']
75    filenames = ['*.nc']
76    mimetypes = ['text/x-nescsrc']
77
78    tokens = {
79        'statements': [
80            (words((
81                'abstract', 'as', 'async', 'atomic', 'call', 'command', 'component',
82                'components', 'configuration', 'event', 'extends', 'generic',
83                'implementation', 'includes', 'interface', 'module', 'new', 'norace',
84                'post', 'provides', 'signal', 'task', 'uses'), suffix=r'\b'),
85             Keyword),
86            (words(('nx_struct', 'nx_union', 'nx_int8_t', 'nx_int16_t', 'nx_int32_t',
87                    'nx_int64_t', 'nx_uint8_t', 'nx_uint16_t', 'nx_uint32_t',
88                    'nx_uint64_t'), suffix=r'\b'),
89             Keyword.Type),
90            inherit,
91        ],
92    }
93
94
95class ClayLexer(RegexLexer):
96    """
97    For `Clay <http://claylabs.com/clay/>`_ source.
98
99    .. versionadded:: 2.0
100    """
101    name = 'Clay'
102    filenames = ['*.clay']
103    aliases = ['clay']
104    mimetypes = ['text/x-clay']
105    tokens = {
106        'root': [
107            (r'\s', Text),
108            (r'//.*?$', Comment.Single),
109            (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
110            (r'\b(public|private|import|as|record|variant|instance'
111             r'|define|overload|default|external|alias'
112             r'|rvalue|ref|forward|inline|noinline|forceinline'
113             r'|enum|var|and|or|not|if|else|goto|return|while'
114             r'|switch|case|break|continue|for|in|true|false|try|catch|throw'
115             r'|finally|onerror|staticassert|eval|when|newtype'
116             r'|__FILE__|__LINE__|__COLUMN__|__ARG__'
117             r')\b', Keyword),
118            (r'[~!%^&*+=|:<>/-]', Operator),
119            (r'[#(){}\[\],;.]', Punctuation),
120            (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
121            (r'\d+[LlUu]*', Number.Integer),
122            (r'\b(true|false)\b', Name.Builtin),
123            (r'(?i)[a-z_?][\w?]*', Name),
124            (r'"""', String, 'tdqs'),
125            (r'"', String, 'dqs'),
126        ],
127        'strings': [
128            (r'(?i)\\(x[0-9a-f]{2}|.)', String.Escape),
129            (r'.', String),
130        ],
131        'nl': [
132            (r'\n', String),
133        ],
134        'dqs': [
135            (r'"', String, '#pop'),
136            include('strings'),
137        ],
138        'tdqs': [
139            (r'"""', String, '#pop'),
140            include('strings'),
141            include('nl'),
142        ],
143    }
144
145
146class ECLexer(CLexer):
147    """
148    For eC source code with preprocessor directives.
149
150    .. versionadded:: 1.5
151    """
152    name = 'eC'
153    aliases = ['ec']
154    filenames = ['*.ec', '*.eh']
155    mimetypes = ['text/x-echdr', 'text/x-ecsrc']
156
157    tokens = {
158        'statements': [
159            (words((
160                'virtual', 'class', 'private', 'public', 'property', 'import',
161                'delete', 'new', 'new0', 'renew', 'renew0', 'define', 'get',
162                'set', 'remote', 'dllexport', 'dllimport', 'stdcall', 'subclass',
163                '__on_register_module', 'namespace', 'using', 'typed_object',
164                'any_object', 'incref', 'register', 'watch', 'stopwatching', 'firewatchers',
165                'watchable', 'class_designer', 'class_fixed', 'class_no_expansion', 'isset',
166                'class_default_property', 'property_category', 'class_data',
167                'class_property', 'thisclass', 'dbtable', 'dbindex',
168                'database_open', 'dbfield'), suffix=r'\b'), Keyword),
169            (words(('uint', 'uint16', 'uint32', 'uint64', 'bool', 'byte',
170                    'unichar', 'int64'), suffix=r'\b'),
171             Keyword.Type),
172            (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
173            (r'(null|value|this)\b', Name.Builtin),
174            inherit,
175        ]
176    }
177
178
179class ValaLexer(RegexLexer):
180    """
181    For Vala source code with preprocessor directives.
182
183    .. versionadded:: 1.1
184    """
185    name = 'Vala'
186    aliases = ['vala', 'vapi']
187    filenames = ['*.vala', '*.vapi']
188    mimetypes = ['text/x-vala']
189
190    tokens = {
191        'whitespace': [
192            (r'^\s*#if\s+0', Comment.Preproc, 'if0'),
193            (r'\n', Text),
194            (r'\s+', Text),
195            (r'\\\n', Text),  # line continuation
196            (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
197            (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
198        ],
199        'statements': [
200            (r'[L@]?"', String, 'string'),
201            (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
202             String.Char),
203            (r'(?s)""".*?"""', String),  # verbatim strings
204            (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
205            (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
206            (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
207            (r'0[0-7]+[Ll]?', Number.Oct),
208            (r'\d+[Ll]?', Number.Integer),
209            (r'[~!%^&*+=|?:<>/-]', Operator),
210            (r'(\[)(Compact|Immutable|(?:Boolean|Simple)Type)(\])',
211             bygroups(Punctuation, Name.Decorator, Punctuation)),
212            # TODO: "correctly" parse complex code attributes
213            (r'(\[)(CCode|(?:Integer|Floating)Type)',
214             bygroups(Punctuation, Name.Decorator)),
215            (r'[()\[\],.]', Punctuation),
216            (words((
217                'as', 'base', 'break', 'case', 'catch', 'construct', 'continue',
218                'default', 'delete', 'do', 'else', 'enum', 'finally', 'for',
219                'foreach', 'get', 'if', 'in', 'is', 'lock', 'new', 'out', 'params',
220                'return', 'set', 'sizeof', 'switch', 'this', 'throw', 'try',
221                'typeof', 'while', 'yield'), suffix=r'\b'),
222             Keyword),
223            (words((
224                'abstract', 'const', 'delegate', 'dynamic', 'ensures', 'extern',
225                'inline', 'internal', 'override', 'owned', 'private', 'protected',
226                'public', 'ref', 'requires', 'signal', 'static', 'throws', 'unowned',
227                'var', 'virtual', 'volatile', 'weak', 'yields'), suffix=r'\b'),
228             Keyword.Declaration),
229            (r'(namespace|using)(\s+)', bygroups(Keyword.Namespace, Text),
230             'namespace'),
231            (r'(class|errordomain|interface|struct)(\s+)',
232             bygroups(Keyword.Declaration, Text), 'class'),
233            (r'(\.)([a-zA-Z_]\w*)',
234             bygroups(Operator, Name.Attribute)),
235            # void is an actual keyword, others are in glib-2.0.vapi
236            (words((
237                'void', 'bool', 'char', 'double', 'float', 'int', 'int8', 'int16',
238                'int32', 'int64', 'long', 'short', 'size_t', 'ssize_t', 'string',
239                'time_t', 'uchar', 'uint', 'uint8', 'uint16', 'uint32', 'uint64',
240                'ulong', 'unichar', 'ushort'), suffix=r'\b'),
241             Keyword.Type),
242            (r'(true|false|null)\b', Name.Builtin),
243            (r'[a-zA-Z_]\w*', Name),
244        ],
245        'root': [
246            include('whitespace'),
247            default('statement'),
248        ],
249        'statement': [
250            include('whitespace'),
251            include('statements'),
252            ('[{}]', Punctuation),
253            (';', Punctuation, '#pop'),
254        ],
255        'string': [
256            (r'"', String, '#pop'),
257            (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
258            (r'[^\\"\n]+', String),  # all other characters
259            (r'\\\n', String),  # line continuation
260            (r'\\', String),  # stray backslash
261        ],
262        'if0': [
263            (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
264            (r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'),
265            (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
266            (r'.*?\n', Comment),
267        ],
268        'class': [
269            (r'[a-zA-Z_]\w*', Name.Class, '#pop')
270        ],
271        'namespace': [
272            (r'[a-zA-Z_][\w.]*', Name.Namespace, '#pop')
273        ],
274    }
275
276
277class CudaLexer(CLexer):
278    """
279    For NVIDIA `CUDA™ <http://developer.nvidia.com/category/zone/cuda-zone>`_
280    source.
281
282    .. versionadded:: 1.6
283    """
284    name = 'CUDA'
285    filenames = ['*.cu', '*.cuh']
286    aliases = ['cuda', 'cu']
287    mimetypes = ['text/x-cuda']
288
289    function_qualifiers = {'__device__', '__global__', '__host__',
290                           '__noinline__', '__forceinline__'}
291    variable_qualifiers = {'__device__', '__constant__', '__shared__',
292                           '__restrict__'}
293    vector_types = {'char1', 'uchar1', 'char2', 'uchar2', 'char3', 'uchar3',
294                    'char4', 'uchar4', 'short1', 'ushort1', 'short2', 'ushort2',
295                    'short3', 'ushort3', 'short4', 'ushort4', 'int1', 'uint1',
296                    'int2', 'uint2', 'int3', 'uint3', 'int4', 'uint4', 'long1',
297                    'ulong1', 'long2', 'ulong2', 'long3', 'ulong3', 'long4',
298                    'ulong4', 'longlong1', 'ulonglong1', 'longlong2',
299                    'ulonglong2', 'float1', 'float2', 'float3', 'float4',
300                    'double1', 'double2', 'dim3'}
301    variables = {'gridDim', 'blockIdx', 'blockDim', 'threadIdx', 'warpSize'}
302    functions = {'__threadfence_block', '__threadfence', '__threadfence_system',
303                 '__syncthreads', '__syncthreads_count', '__syncthreads_and',
304                 '__syncthreads_or'}
305    execution_confs = {'<<<', '>>>'}
306
307    def get_tokens_unprocessed(self, text):
308        for index, token, value in CLexer.get_tokens_unprocessed(self, text):
309            if token is Name:
310                if value in self.variable_qualifiers:
311                    token = Keyword.Type
312                elif value in self.vector_types:
313                    token = Keyword.Type
314                elif value in self.variables:
315                    token = Name.Builtin
316                elif value in self.execution_confs:
317                    token = Keyword.Pseudo
318                elif value in self.function_qualifiers:
319                    token = Keyword.Reserved
320                elif value in self.functions:
321                    token = Name.Function
322            yield index, token, value
323
324
325class SwigLexer(CppLexer):
326    """
327    For `SWIG <http://www.swig.org/>`_ source code.
328
329    .. versionadded:: 2.0
330    """
331    name = 'SWIG'
332    aliases = ['swig']
333    filenames = ['*.swg', '*.i']
334    mimetypes = ['text/swig']
335    priority = 0.04  # Lower than C/C++ and Objective C/C++
336
337    tokens = {
338        'statements': [
339            # SWIG directives
340            (r'(%[a-z_][a-z0-9_]*)', Name.Function),
341            # Special variables
342            (r'\$\**\&?\w+', Name),
343            # Stringification / additional preprocessor directives
344            (r'##*[a-zA-Z_]\w*', Comment.Preproc),
345            inherit,
346        ],
347    }
348
349    # This is a far from complete set of SWIG directives
350    swig_directives = {
351        # Most common directives
352        '%apply', '%define', '%director', '%enddef', '%exception', '%extend',
353        '%feature', '%fragment', '%ignore', '%immutable', '%import', '%include',
354        '%inline', '%insert', '%module', '%newobject', '%nspace', '%pragma',
355        '%rename', '%shared_ptr', '%template', '%typecheck', '%typemap',
356        # Less common directives
357        '%arg', '%attribute', '%bang', '%begin', '%callback', '%catches', '%clear',
358        '%constant', '%copyctor', '%csconst', '%csconstvalue', '%csenum',
359        '%csmethodmodifiers', '%csnothrowexception', '%default', '%defaultctor',
360        '%defaultdtor', '%defined', '%delete', '%delobject', '%descriptor',
361        '%exceptionclass', '%exceptionvar', '%extend_smart_pointer', '%fragments',
362        '%header', '%ifcplusplus', '%ignorewarn', '%implicit', '%implicitconv',
363        '%init', '%javaconst', '%javaconstvalue', '%javaenum', '%javaexception',
364        '%javamethodmodifiers', '%kwargs', '%luacode', '%mutable', '%naturalvar',
365        '%nestedworkaround', '%perlcode', '%pythonabc', '%pythonappend',
366        '%pythoncallback', '%pythoncode', '%pythondynamic', '%pythonmaybecall',
367        '%pythonnondynamic', '%pythonprepend', '%refobject', '%shadow', '%sizeof',
368        '%trackobjects', '%types', '%unrefobject', '%varargs', '%warn',
369        '%warnfilter'}
370
371    def analyse_text(text):
372        rv = 0
373        # Search for SWIG directives, which are conventionally at the beginning of
374        # a line. The probability of them being within a line is low, so let another
375        # lexer win in this case.
376        matches = re.findall(r'^\s*(%[a-z_][a-z0-9_]*)', text, re.M)
377        for m in matches:
378            if m in SwigLexer.swig_directives:
379                rv = 0.98
380                break
381            else:
382                rv = 0.91  # Fraction higher than MatlabLexer
383        return rv
384
385
386class MqlLexer(CppLexer):
387    """
388    For `MQL4 <http://docs.mql4.com/>`_ and
389    `MQL5 <http://www.mql5.com/en/docs>`_ source code.
390
391    .. versionadded:: 2.0
392    """
393    name = 'MQL'
394    aliases = ['mql', 'mq4', 'mq5', 'mql4', 'mql5']
395    filenames = ['*.mq4', '*.mq5', '*.mqh']
396    mimetypes = ['text/x-mql']
397
398    tokens = {
399        'statements': [
400            (words(_mql_builtins.keywords, suffix=r'\b'), Keyword),
401            (words(_mql_builtins.c_types, suffix=r'\b'), Keyword.Type),
402            (words(_mql_builtins.types, suffix=r'\b'), Name.Function),
403            (words(_mql_builtins.constants, suffix=r'\b'), Name.Constant),
404            (words(_mql_builtins.colors, prefix='(clr)?', suffix=r'\b'),
405             Name.Constant),
406            inherit,
407        ],
408    }
409
410
411class ArduinoLexer(CppLexer):
412    """
413    For `Arduino(tm) <https://arduino.cc/>`_ source.
414
415    This is an extension of the CppLexer, as the Arduino® Language is a superset
416    of C++
417
418    .. versionadded:: 2.1
419    """
420
421    name = 'Arduino'
422    aliases = ['arduino']
423    filenames = ['*.ino']
424    mimetypes = ['text/x-arduino']
425
426    # Language sketch main structure functions
427    structure = {'setup', 'loop'}
428
429    # Language operators
430    operators = {'not', 'or', 'and', 'xor'}
431
432    # Language 'variables'
433    variables = {
434        'DIGITAL_MESSAGE', 'FIRMATA_STRING', 'ANALOG_MESSAGE', 'REPORT_DIGITAL',
435        'REPORT_ANALOG', 'INPUT_PULLUP', 'SET_PIN_MODE', 'INTERNAL2V56', 'SYSTEM_RESET',
436        'LED_BUILTIN', 'INTERNAL1V1', 'SYSEX_START', 'INTERNAL', 'EXTERNAL', 'HIGH',
437        'LOW', 'INPUT', 'OUTPUT', 'INPUT_PULLUP', 'LED_BUILTIN', 'true', 'false',
438        'void', 'boolean', 'char', 'unsigned char', 'byte', 'int', 'unsigned int',
439        'word', 'long', 'unsigned long', 'short', 'float', 'double', 'string', 'String',
440        'array', 'static', 'volatile', 'const', 'boolean', 'byte', 'word', 'string',
441        'String', 'array', 'int', 'float', 'private', 'char', 'virtual', 'operator',
442        'sizeof', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int8_t', 'int16_t',
443        'int32_t', 'int64_t', 'dynamic_cast', 'typedef', 'const_cast', 'const',
444        'struct', 'static_cast', 'union', 'unsigned', 'long', 'volatile', 'static',
445        'protected', 'bool', 'public', 'friend', 'auto', 'void', 'enum', 'extern',
446        'class', 'short', 'reinterpret_cast', 'double', 'register', 'explicit',
447        'signed', 'inline', 'delete', '_Bool', 'complex', '_Complex', '_Imaginary',
448        'atomic_bool', 'atomic_char', 'atomic_schar', 'atomic_uchar', 'atomic_short',
449        'atomic_ushort', 'atomic_int', 'atomic_uint', 'atomic_long', 'atomic_ulong',
450        'atomic_llong', 'atomic_ullong', 'PROGMEM'}
451
452    # Language shipped functions and class ( )
453    functions = {
454        'KeyboardController', 'MouseController', 'SoftwareSerial', 'EthernetServer',
455        'EthernetClient', 'LiquidCrystal', 'RobotControl', 'GSMVoiceCall',
456        'EthernetUDP', 'EsploraTFT', 'HttpClient', 'RobotMotor', 'WiFiClient',
457        'GSMScanner', 'FileSystem', 'Scheduler', 'GSMServer', 'YunClient', 'YunServer',
458        'IPAddress', 'GSMClient', 'GSMModem', 'Keyboard', 'Ethernet', 'Console',
459        'GSMBand', 'Esplora', 'Stepper', 'Process', 'WiFiUDP', 'GSM_SMS', 'Mailbox',
460        'USBHost', 'Firmata', 'PImage', 'Client', 'Server', 'GSMPIN', 'FileIO',
461        'Bridge', 'Serial', 'EEPROM', 'Stream', 'Mouse', 'Audio', 'Servo', 'File',
462        'Task', 'GPRS', 'WiFi', 'Wire', 'TFT', 'GSM', 'SPI', 'SD',
463        'runShellCommandAsynchronously', 'analogWriteResolution',
464        'retrieveCallingNumber', 'printFirmwareVersion', 'analogReadResolution',
465        'sendDigitalPortPair', 'noListenOnLocalhost', 'readJoystickButton',
466        'setFirmwareVersion', 'readJoystickSwitch', 'scrollDisplayRight',
467        'getVoiceCallStatus', 'scrollDisplayLeft', 'writeMicroseconds',
468        'delayMicroseconds', 'beginTransmission', 'getSignalStrength',
469        'runAsynchronously', 'getAsynchronously', 'listenOnLocalhost',
470        'getCurrentCarrier', 'readAccelerometer', 'messageAvailable',
471        'sendDigitalPorts', 'lineFollowConfig', 'countryNameWrite', 'runShellCommand',
472        'readStringUntil', 'rewindDirectory', 'readTemperature', 'setClockDivider',
473        'readLightSensor', 'endTransmission', 'analogReference', 'detachInterrupt',
474        'countryNameRead', 'attachInterrupt', 'encryptionType', 'readBytesUntil',
475        'robotNameWrite', 'readMicrophone', 'robotNameRead', 'cityNameWrite',
476        'userNameWrite', 'readJoystickY', 'readJoystickX', 'mouseReleased',
477        'openNextFile', 'scanNetworks', 'noInterrupts', 'digitalWrite', 'beginSpeaker',
478        'mousePressed', 'isActionDone', 'mouseDragged', 'displayLogos', 'noAutoscroll',
479        'addParameter', 'remoteNumber', 'getModifiers', 'keyboardRead', 'userNameRead',
480        'waitContinue', 'processInput', 'parseCommand', 'printVersion', 'readNetworks',
481        'writeMessage', 'blinkVersion', 'cityNameRead', 'readMessage', 'setDataMode',
482        'parsePacket', 'isListening', 'setBitOrder', 'beginPacket', 'isDirectory',
483        'motorsWrite', 'drawCompass', 'digitalRead', 'clearScreen', 'serialEvent',
484        'rightToLeft', 'setTextSize', 'leftToRight', 'requestFrom', 'keyReleased',
485        'compassRead', 'analogWrite', 'interrupts', 'WiFiServer', 'disconnect',
486        'playMelody', 'parseFloat', 'autoscroll', 'getPINUsed', 'setPINUsed',
487        'setTimeout', 'sendAnalog', 'readSlider', 'analogRead', 'beginWrite',
488        'createChar', 'motorsStop', 'keyPressed', 'tempoWrite', 'readButton',
489        'subnetMask', 'debugPrint', 'macAddress', 'writeGreen', 'randomSeed',
490        'attachGPRS', 'readString', 'sendString', 'remotePort', 'releaseAll',
491        'mouseMoved', 'background', 'getXChange', 'getYChange', 'answerCall',
492        'getResult', 'voiceCall', 'endPacket', 'constrain', 'getSocket', 'writeJSON',
493        'getButton', 'available', 'connected', 'findUntil', 'readBytes', 'exitValue',
494        'readGreen', 'writeBlue', 'startLoop', 'IPAddress', 'isPressed', 'sendSysex',
495        'pauseMode', 'gatewayIP', 'setCursor', 'getOemKey', 'tuneWrite', 'noDisplay',
496        'loadImage', 'switchPIN', 'onRequest', 'onReceive', 'changePIN', 'playFile',
497        'noBuffer', 'parseInt', 'overflow', 'checkPIN', 'knobRead', 'beginTFT',
498        'bitClear', 'updateIR', 'bitWrite', 'position', 'writeRGB', 'highByte',
499        'writeRed', 'setSpeed', 'readBlue', 'noStroke', 'remoteIP', 'transfer',
500        'shutdown', 'hangCall', 'beginSMS', 'endWrite', 'attached', 'maintain',
501        'noCursor', 'checkReg', 'checkPUK', 'shiftOut', 'isValid', 'shiftIn', 'pulseIn',
502        'connect', 'println', 'localIP', 'pinMode', 'getIMEI', 'display', 'noBlink',
503        'process', 'getBand', 'running', 'beginSD', 'drawBMP', 'lowByte', 'setBand',
504        'release', 'bitRead', 'prepare', 'pointTo', 'readRed', 'setMode', 'noFill',
505        'remove', 'listen', 'stroke', 'detach', 'attach', 'noTone', 'exists', 'buffer',
506        'height', 'bitSet', 'circle', 'config', 'cursor', 'random', 'IRread', 'setDNS',
507        'endSMS', 'getKey', 'micros', 'millis', 'begin', 'print', 'write', 'ready',
508        'flush', 'width', 'isPIN', 'blink', 'clear', 'press', 'mkdir', 'rmdir', 'close',
509        'point', 'yield', 'image', 'BSSID', 'click', 'delay', 'read', 'text', 'move',
510        'peek', 'beep', 'rect', 'line', 'open', 'seek', 'fill', 'size', 'turn', 'stop',
511        'home', 'find', 'step', 'tone', 'sqrt', 'RSSI', 'SSID', 'end', 'bit', 'tan',
512        'cos', 'sin', 'pow', 'map', 'abs', 'max', 'min', 'get', 'run', 'put',
513        'isAlphaNumeric', 'isAlpha', 'isAscii', 'isWhitespace', 'isControl', 'isDigit',
514        'isGraph', 'isLowerCase', 'isPrintable', 'isPunct', 'isSpace', 'isUpperCase',
515        'isHexadecimalDigit'}
516
517    # do not highlight
518    suppress_highlight = {
519        'namespace', 'template', 'mutable', 'using', 'asm', 'typeid',
520        'typename', 'this', 'alignof', 'constexpr', 'decltype', 'noexcept',
521        'static_assert', 'thread_local', 'restrict'}
522
523    def get_tokens_unprocessed(self, text):
524        for index, token, value in CppLexer.get_tokens_unprocessed(self, text):
525            if value in self.structure:
526                yield index, Name.Builtin, value
527            elif value in self.operators:
528                yield index, Operator, value
529            elif value in self.variables:
530                yield index, Keyword.Reserved, value
531            elif value in self.suppress_highlight:
532                yield index, Name, value
533            elif value in self.functions:
534                yield index, Name.Function, value
535            else:
536                yield index, token, value
537
538
539class CharmciLexer(CppLexer):
540    """
541    For `Charm++ <https://charm.cs.illinois.edu>`_ interface files (.ci).
542
543    .. versionadded:: 2.4
544    """
545
546    name = 'Charmci'
547    aliases = ['charmci']
548    filenames = ['*.ci']
549
550    mimetypes = []
551
552    tokens = {
553        'statements': [
554            (r'(module)(\s+)', bygroups(Keyword, Text), 'classname'),
555            (words(('mainmodule', 'mainchare', 'chare', 'array', 'group',
556                    'nodegroup', 'message', 'conditional')), Keyword),
557            (words(('entry', 'aggregate', 'threaded', 'sync', 'exclusive',
558                    'nokeep', 'notrace', 'immediate', 'expedited', 'inline',
559                    'local', 'python', 'accel', 'readwrite', 'writeonly',
560                    'accelblock', 'memcritical', 'packed', 'varsize',
561                    'initproc', 'initnode', 'initcall', 'stacksize',
562                    'createhere', 'createhome', 'reductiontarget', 'iget',
563                    'nocopy', 'mutable', 'migratable', 'readonly')), Keyword),
564            inherit,
565        ],
566    }
567