ThirdParty/Pygments/pygments/lexers/c_like.py

changeset 5713
6762afd9f963
parent 4697
c2e9bf425554
child 6651
e8f3b5568b21
equal deleted inserted replaced
5712:f0d08bdeacf4 5713:6762afd9f963
3 pygments.lexers.c_like 3 pygments.lexers.c_like
4 ~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for other C-like languages. 6 Lexers for other C-like languages.
7 7
8 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
425 name = 'Arduino' 425 name = 'Arduino'
426 aliases = ['arduino'] 426 aliases = ['arduino']
427 filenames = ['*.ino'] 427 filenames = ['*.ino']
428 mimetypes = ['text/x-arduino'] 428 mimetypes = ['text/x-arduino']
429 429
430 # Language constants
431 constants = set(('DIGITAL_MESSAGE', 'FIRMATA_STRING', 'ANALOG_MESSAGE',
432 'REPORT_DIGITAL', 'REPORT_ANALOG', 'INPUT_PULLUP',
433 'SET_PIN_MODE', 'INTERNAL2V56', 'SYSTEM_RESET', 'LED_BUILTIN',
434 'INTERNAL1V1', 'SYSEX_START', 'INTERNAL', 'EXTERNAL',
435 'DEFAULT', 'OUTPUT', 'INPUT', 'HIGH', 'LOW'))
436
437 # Language sketch main structure functions 430 # Language sketch main structure functions
438 structure = set(('setup', 'loop')) 431 structure = set(('setup', 'loop'))
439 432
440 # Language variable types 433 # Language operators
441 storage = set(('boolean', 'const', 'byte', 'word', 'string', 'String', 'array')) 434 operators = set(('not', 'or', 'and', 'xor'))
435
436 # Language 'variables'
437 variables = set((
438 'DIGITAL_MESSAGE', 'FIRMATA_STRING', 'ANALOG_MESSAGE', 'REPORT_DIGITAL',
439 'REPORT_ANALOG', 'INPUT_PULLUP', 'SET_PIN_MODE', 'INTERNAL2V56', 'SYSTEM_RESET',
440 'LED_BUILTIN', 'INTERNAL1V1', 'SYSEX_START', 'INTERNAL', 'EXTERNAL', 'HIGH',
441 'LOW', 'INPUT', 'OUTPUT', 'INPUT_PULLUP', 'LED_BUILTIN', 'true', 'false',
442 'void', 'boolean', 'char', 'unsigned char', 'byte', 'int', 'unsigned int',
443 'word', 'long', 'unsigned long', 'short', 'float', 'double', 'string', 'String',
444 'array', 'static', 'volatile', 'const', 'boolean', 'byte', 'word', 'string',
445 'String', 'array', 'int', 'float', 'private', 'char', 'virtual', 'operator',
446 'sizeof', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int8_t', 'int16_t',
447 'int32_t', 'int64_t', 'dynamic_cast', 'typedef', 'const_cast', 'const',
448 'struct', 'static_cast', 'union', 'unsigned', 'long', 'volatile', 'static',
449 'protected', 'bool', 'public', 'friend', 'auto', 'void', 'enum', 'extern',
450 'class', 'short', 'reinterpret_cast', 'double', 'register', 'explicit',
451 'signed', 'inline', 'delete', '_Bool', 'complex', '_Complex', '_Imaginary',
452 'atomic_bool', 'atomic_char', 'atomic_schar', 'atomic_uchar', 'atomic_short',
453 'atomic_ushort', 'atomic_int', 'atomic_uint', 'atomic_long', 'atomic_ulong',
454 'atomic_llong', 'atomic_ullong', 'PROGMEM'))
442 455
443 # Language shipped functions and class ( ) 456 # Language shipped functions and class ( )
444 functions = set(('KeyboardController', 'MouseController', 'SoftwareSerial', 457 functions = set((
445 'EthernetServer', 'EthernetClient', 'LiquidCrystal', 458 'KeyboardController', 'MouseController', 'SoftwareSerial', 'EthernetServer',
446 'RobotControl', 'GSMVoiceCall', 'EthernetUDP', 'EsploraTFT', 459 'EthernetClient', 'LiquidCrystal', 'RobotControl', 'GSMVoiceCall',
447 'HttpClient', 'RobotMotor', 'WiFiClient', 'GSMScanner', 460 'EthernetUDP', 'EsploraTFT', 'HttpClient', 'RobotMotor', 'WiFiClient',
448 'FileSystem', 'Scheduler', 'GSMServer', 'YunClient', 'YunServer', 461 'GSMScanner', 'FileSystem', 'Scheduler', 'GSMServer', 'YunClient', 'YunServer',
449 'IPAddress', 'GSMClient', 'GSMModem', 'Keyboard', 'Ethernet', 462 'IPAddress', 'GSMClient', 'GSMModem', 'Keyboard', 'Ethernet', 'Console',
450 'Console', 'GSMBand', 'Esplora', 'Stepper', 'Process', 463 'GSMBand', 'Esplora', 'Stepper', 'Process', 'WiFiUDP', 'GSM_SMS', 'Mailbox',
451 'WiFiUDP', 'GSM_SMS', 'Mailbox', 'USBHost', 'Firmata', 'PImage', 464 'USBHost', 'Firmata', 'PImage', 'Client', 'Server', 'GSMPIN', 'FileIO',
452 'Client', 'Server', 'GSMPIN', 'FileIO', 'Bridge', 'Serial', 465 'Bridge', 'Serial', 'EEPROM', 'Stream', 'Mouse', 'Audio', 'Servo', 'File',
453 'EEPROM', 'Stream', 'Mouse', 'Audio', 'Servo', 'File', 'Task', 466 'Task', 'GPRS', 'WiFi', 'Wire', 'TFT', 'GSM', 'SPI', 'SD',
454 'GPRS', 'WiFi', 'Wire', 'TFT', 'GSM', 'SPI', 'SD', 467 'runShellCommandAsynchronously', 'analogWriteResolution',
455 'runShellCommandAsynchronously', 'analogWriteResolution', 468 'retrieveCallingNumber', 'printFirmwareVersion', 'analogReadResolution',
456 'retrieveCallingNumber', 'printFirmwareVersion', 469 'sendDigitalPortPair', 'noListenOnLocalhost', 'readJoystickButton',
457 'analogReadResolution', 'sendDigitalPortPair', 470 'setFirmwareVersion', 'readJoystickSwitch', 'scrollDisplayRight',
458 'noListenOnLocalhost', 'readJoystickButton', 'setFirmwareVersion', 471 'getVoiceCallStatus', 'scrollDisplayLeft', 'writeMicroseconds',
459 'readJoystickSwitch', 'scrollDisplayRight', 'getVoiceCallStatus', 472 'delayMicroseconds', 'beginTransmission', 'getSignalStrength',
460 'scrollDisplayLeft', 'writeMicroseconds', 'delayMicroseconds', 473 'runAsynchronously', 'getAsynchronously', 'listenOnLocalhost',
461 'beginTransmission', 'getSignalStrength', 'runAsynchronously', 474 'getCurrentCarrier', 'readAccelerometer', 'messageAvailable',
462 'getAsynchronously', 'listenOnLocalhost', 'getCurrentCarrier', 475 'sendDigitalPorts', 'lineFollowConfig', 'countryNameWrite', 'runShellCommand',
463 'readAccelerometer', 'messageAvailable', 'sendDigitalPorts', 476 'readStringUntil', 'rewindDirectory', 'readTemperature', 'setClockDivider',
464 'lineFollowConfig', 'countryNameWrite', 'runShellCommand', 477 'readLightSensor', 'endTransmission', 'analogReference', 'detachInterrupt',
465 'readStringUntil', 'rewindDirectory', 'readTemperature', 478 'countryNameRead', 'attachInterrupt', 'encryptionType', 'readBytesUntil',
466 'setClockDivider', 'readLightSensor', 'endTransmission', 479 'robotNameWrite', 'readMicrophone', 'robotNameRead', 'cityNameWrite',
467 'analogReference', 'detachInterrupt', 'countryNameRead', 480 'userNameWrite', 'readJoystickY', 'readJoystickX', 'mouseReleased',
468 'attachInterrupt', 'encryptionType', 'readBytesUntil', 481 'openNextFile', 'scanNetworks', 'noInterrupts', 'digitalWrite', 'beginSpeaker',
469 'robotNameWrite', 'readMicrophone', 'robotNameRead', 'cityNameWrite', 482 'mousePressed', 'isActionDone', 'mouseDragged', 'displayLogos', 'noAutoscroll',
470 'userNameWrite', 'readJoystickY', 'readJoystickX', 'mouseReleased', 483 'addParameter', 'remoteNumber', 'getModifiers', 'keyboardRead', 'userNameRead',
471 'openNextFile', 'scanNetworks', 'noInterrupts', 'digitalWrite', 484 'waitContinue', 'processInput', 'parseCommand', 'printVersion', 'readNetworks',
472 'beginSpeaker', 'mousePressed', 'isActionDone', 'mouseDragged', 485 'writeMessage', 'blinkVersion', 'cityNameRead', 'readMessage', 'setDataMode',
473 'displayLogos', 'noAutoscroll', 'addParameter', 'remoteNumber', 486 'parsePacket', 'isListening', 'setBitOrder', 'beginPacket', 'isDirectory',
474 'getModifiers', 'keyboardRead', 'userNameRead', 'waitContinue', 487 'motorsWrite', 'drawCompass', 'digitalRead', 'clearScreen', 'serialEvent',
475 'processInput', 'parseCommand', 'printVersion', 'readNetworks', 488 'rightToLeft', 'setTextSize', 'leftToRight', 'requestFrom', 'keyReleased',
476 'writeMessage', 'blinkVersion', 'cityNameRead', 'readMessage', 489 'compassRead', 'analogWrite', 'interrupts', 'WiFiServer', 'disconnect',
477 'setDataMode', 'parsePacket', 'isListening', 'setBitOrder', 490 'playMelody', 'parseFloat', 'autoscroll', 'getPINUsed', 'setPINUsed',
478 'beginPacket', 'isDirectory', 'motorsWrite', 'drawCompass', 491 'setTimeout', 'sendAnalog', 'readSlider', 'analogRead', 'beginWrite',
479 'digitalRead', 'clearScreen', 'serialEvent', 'rightToLeft', 492 'createChar', 'motorsStop', 'keyPressed', 'tempoWrite', 'readButton',
480 'setTextSize', 'leftToRight', 'requestFrom', 'keyReleased', 493 'subnetMask', 'debugPrint', 'macAddress', 'writeGreen', 'randomSeed',
481 'compassRead', 'analogWrite', 'interrupts', 'WiFiServer', 494 'attachGPRS', 'readString', 'sendString', 'remotePort', 'releaseAll',
482 'disconnect', 'playMelody', 'parseFloat', 'autoscroll', 495 'mouseMoved', 'background', 'getXChange', 'getYChange', 'answerCall',
483 'getPINUsed', 'setPINUsed', 'setTimeout', 'sendAnalog', 496 'getResult', 'voiceCall', 'endPacket', 'constrain', 'getSocket', 'writeJSON',
484 'readSlider', 'analogRead', 'beginWrite', 'createChar', 497 'getButton', 'available', 'connected', 'findUntil', 'readBytes', 'exitValue',
485 'motorsStop', 'keyPressed', 'tempoWrite', 'readButton', 498 'readGreen', 'writeBlue', 'startLoop', 'IPAddress', 'isPressed', 'sendSysex',
486 'subnetMask', 'debugPrint', 'macAddress', 'writeGreen', 499 'pauseMode', 'gatewayIP', 'setCursor', 'getOemKey', 'tuneWrite', 'noDisplay',
487 'randomSeed', 'attachGPRS', 'readString', 'sendString', 500 'loadImage', 'switchPIN', 'onRequest', 'onReceive', 'changePIN', 'playFile',
488 'remotePort', 'releaseAll', 'mouseMoved', 'background', 501 'noBuffer', 'parseInt', 'overflow', 'checkPIN', 'knobRead', 'beginTFT',
489 'getXChange', 'getYChange', 'answerCall', 'getResult', 502 'bitClear', 'updateIR', 'bitWrite', 'position', 'writeRGB', 'highByte',
490 'voiceCall', 'endPacket', 'constrain', 'getSocket', 'writeJSON', 503 'writeRed', 'setSpeed', 'readBlue', 'noStroke', 'remoteIP', 'transfer',
491 'getButton', 'available', 'connected', 'findUntil', 'readBytes', 504 'shutdown', 'hangCall', 'beginSMS', 'endWrite', 'attached', 'maintain',
492 'exitValue', 'readGreen', 'writeBlue', 'startLoop', 'IPAddress', 505 'noCursor', 'checkReg', 'checkPUK', 'shiftOut', 'isValid', 'shiftIn', 'pulseIn',
493 'isPressed', 'sendSysex', 'pauseMode', 'gatewayIP', 'setCursor', 506 'connect', 'println', 'localIP', 'pinMode', 'getIMEI', 'display', 'noBlink',
494 'getOemKey', 'tuneWrite', 'noDisplay', 'loadImage', 'switchPIN', 507 'process', 'getBand', 'running', 'beginSD', 'drawBMP', 'lowByte', 'setBand',
495 'onRequest', 'onReceive', 'changePIN', 'playFile', 'noBuffer', 508 'release', 'bitRead', 'prepare', 'pointTo', 'readRed', 'setMode', 'noFill',
496 'parseInt', 'overflow', 'checkPIN', 'knobRead', 'beginTFT', 509 'remove', 'listen', 'stroke', 'detach', 'attach', 'noTone', 'exists', 'buffer',
497 'bitClear', 'updateIR', 'bitWrite', 'position', 'writeRGB', 510 'height', 'bitSet', 'circle', 'config', 'cursor', 'random', 'IRread', 'setDNS',
498 'highByte', 'writeRed', 'setSpeed', 'readBlue', 'noStroke', 511 'endSMS', 'getKey', 'micros', 'millis', 'begin', 'print', 'write', 'ready',
499 'remoteIP', 'transfer', 'shutdown', 'hangCall', 'beginSMS', 512 'flush', 'width', 'isPIN', 'blink', 'clear', 'press', 'mkdir', 'rmdir', 'close',
500 'endWrite', 'attached', 'maintain', 'noCursor', 'checkReg', 513 'point', 'yield', 'image', 'BSSID', 'click', 'delay', 'read', 'text', 'move',
501 'checkPUK', 'shiftOut', 'isValid', 'shiftIn', 'pulseIn', 514 'peek', 'beep', 'rect', 'line', 'open', 'seek', 'fill', 'size', 'turn', 'stop',
502 'connect', 'println', 'localIP', 'pinMode', 'getIMEI', 515 'home', 'find', 'step', 'tone', 'sqrt', 'RSSI', 'SSID', 'end', 'bit', 'tan',
503 'display', 'noBlink', 'process', 'getBand', 'running', 'beginSD', 516 'cos', 'sin', 'pow', 'map', 'abs', 'max', 'min', 'get', 'run', 'put',
504 'drawBMP', 'lowByte', 'setBand', 'release', 'bitRead', 'prepare', 517 'isAlphaNumeric', 'isAlpha', 'isAscii', 'isWhitespace', 'isControl', 'isDigit',
505 'pointTo', 'readRed', 'setMode', 'noFill', 'remove', 'listen', 518 'isGraph', 'isLowerCase', 'isPrintable', 'isPunct', 'isSpace', 'isUpperCase',
506 'stroke', 'detach', 'attach', 'noTone', 'exists', 'buffer', 519 'isHexadecimalDigit'))
507 'height', 'bitSet', 'circle', 'config', 'cursor', 'random', 520
508 'IRread', 'sizeof', 'setDNS', 'endSMS', 'getKey', 'micros', 521 # do not highlight
509 'millis', 'begin', 'print', 'write', 'ready', 'flush', 'width', 522 suppress_highlight = set((
510 'isPIN', 'blink', 'clear', 'press', 'mkdir', 'rmdir', 'close', 523 'namespace', 'template', 'mutable', 'using', 'asm', 'typeid',
511 'point', 'yield', 'image', 'float', 'BSSID', 'click', 'delay', 524 'typename', 'this', 'alignof', 'constexpr', 'decltype', 'noexcept',
512 'read', 'text', 'move', 'peek', 'beep', 'rect', 'line', 'open', 525 'static_assert', 'thread_local', 'restrict'))
513 'seek', 'fill', 'size', 'turn', 'stop', 'home', 'find', 'char', 526
514 'byte', 'step', 'word', 'long', 'tone', 'sqrt', 'RSSI', 'SSID',
515 'end', 'bit', 'tan', 'cos', 'sin', 'pow', 'map', 'abs', 'max',
516 'min', 'int', 'get', 'run', 'put'))
517
518 527
519 def get_tokens_unprocessed(self, text): 528 def get_tokens_unprocessed(self, text):
520 for index, token, value in CppLexer.get_tokens_unprocessed(self, text): 529 for index, token, value in CppLexer.get_tokens_unprocessed(self, text):
521 if token is Name: 530 if value in self.structure:
522 if value in self.constants: 531 yield index, Name.Builtin, value
523 yield index, Keyword.Constant, value 532 elif value in self.operators:
524 elif value in self.functions: 533 yield index, Operator, value
525 yield index, Name.Function, value 534 elif value in self.variables:
526 elif value in self.storage: 535 yield index, Keyword.Reserved, value
527 yield index, Keyword.Type, value 536 elif value in self.suppress_highlight:
528 else: 537 yield index, Name, value
529 yield index, token, value 538 elif value in self.functions:
530 elif token is Name.Function: 539 yield index, Name.Function, value
531 if value in self.structure:
532 yield index, Name.Other, value
533 else:
534 yield index, token, value
535 elif token is Keyword:
536 if value in self.storage:
537 yield index, Keyword.Type, value
538 else:
539 yield index, token, value
540 else: 540 else:
541 yield index, token, value 541 yield index, token, value

eric ide

mercurial