ThirdParty/Pygments/pygments/lexers/c_like.py

changeset 4697
c2e9bf425554
parent 4172
4f20dba37ab6
child 5713
6762afd9f963
equal deleted inserted replaced
4696:bf4d19a7cade 4697:c2e9bf425554
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-2014 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2015 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
18 18
19 from pygments.lexers.c_cpp import CLexer, CppLexer 19 from pygments.lexers.c_cpp import CLexer, CppLexer
20 from pygments.lexers import _mql_builtins 20 from pygments.lexers import _mql_builtins
21 21
22 __all__ = ['PikeLexer', 'NesCLexer', 'ClayLexer', 'ECLexer', 'ValaLexer', 22 __all__ = ['PikeLexer', 'NesCLexer', 'ClayLexer', 'ECLexer', 'ValaLexer',
23 'CudaLexer', 'SwigLexer', 'MqlLexer'] 23 'CudaLexer', 'SwigLexer', 'MqlLexer', 'ArduinoLexer']
24 24
25 25
26 class PikeLexer(CppLexer): 26 class PikeLexer(CppLexer):
27 """ 27 """
28 For `Pike <http://pike.lysator.liu.se/>`_ source code. 28 For `Pike <http://pike.lysator.liu.se/>`_ source code.
409 (words(_mql_builtins.colors, prefix='(clr)?', suffix=r'\b'), 409 (words(_mql_builtins.colors, prefix='(clr)?', suffix=r'\b'),
410 Name.Constant), 410 Name.Constant),
411 inherit, 411 inherit,
412 ], 412 ],
413 } 413 }
414
415 class ArduinoLexer(CppLexer):
416 """
417 For `Arduino(tm) <https://arduino.cc/>`_ source.
418
419 This is an extension of the CppLexer, as the Arduino® Language is a superset
420 of C++
421
422 .. versionadded:: 2.1
423 """
424
425 name = 'Arduino'
426 aliases = ['arduino']
427 filenames = ['*.ino']
428 mimetypes = ['text/x-arduino']
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
438 structure = set(('setup', 'loop'))
439
440 # Language variable types
441 storage = set(('boolean', 'const', 'byte', 'word', 'string', 'String', 'array'))
442
443 # Language shipped functions and class ( )
444 functions = set(('KeyboardController', 'MouseController', 'SoftwareSerial',
445 'EthernetServer', 'EthernetClient', 'LiquidCrystal',
446 'RobotControl', 'GSMVoiceCall', 'EthernetUDP', 'EsploraTFT',
447 'HttpClient', 'RobotMotor', 'WiFiClient', 'GSMScanner',
448 'FileSystem', 'Scheduler', 'GSMServer', 'YunClient', 'YunServer',
449 'IPAddress', 'GSMClient', 'GSMModem', 'Keyboard', 'Ethernet',
450 'Console', 'GSMBand', 'Esplora', 'Stepper', 'Process',
451 'WiFiUDP', 'GSM_SMS', 'Mailbox', 'USBHost', 'Firmata', 'PImage',
452 'Client', 'Server', 'GSMPIN', 'FileIO', 'Bridge', 'Serial',
453 'EEPROM', 'Stream', 'Mouse', 'Audio', 'Servo', 'File', 'Task',
454 'GPRS', 'WiFi', 'Wire', 'TFT', 'GSM', 'SPI', 'SD',
455 'runShellCommandAsynchronously', 'analogWriteResolution',
456 'retrieveCallingNumber', 'printFirmwareVersion',
457 'analogReadResolution', 'sendDigitalPortPair',
458 'noListenOnLocalhost', 'readJoystickButton', 'setFirmwareVersion',
459 'readJoystickSwitch', 'scrollDisplayRight', 'getVoiceCallStatus',
460 'scrollDisplayLeft', 'writeMicroseconds', 'delayMicroseconds',
461 'beginTransmission', 'getSignalStrength', 'runAsynchronously',
462 'getAsynchronously', 'listenOnLocalhost', 'getCurrentCarrier',
463 'readAccelerometer', 'messageAvailable', 'sendDigitalPorts',
464 'lineFollowConfig', 'countryNameWrite', 'runShellCommand',
465 'readStringUntil', 'rewindDirectory', 'readTemperature',
466 'setClockDivider', 'readLightSensor', 'endTransmission',
467 'analogReference', 'detachInterrupt', 'countryNameRead',
468 'attachInterrupt', 'encryptionType', 'readBytesUntil',
469 'robotNameWrite', 'readMicrophone', 'robotNameRead', 'cityNameWrite',
470 'userNameWrite', 'readJoystickY', 'readJoystickX', 'mouseReleased',
471 'openNextFile', 'scanNetworks', 'noInterrupts', 'digitalWrite',
472 'beginSpeaker', 'mousePressed', 'isActionDone', 'mouseDragged',
473 'displayLogos', 'noAutoscroll', 'addParameter', 'remoteNumber',
474 'getModifiers', 'keyboardRead', 'userNameRead', 'waitContinue',
475 'processInput', 'parseCommand', 'printVersion', 'readNetworks',
476 'writeMessage', 'blinkVersion', 'cityNameRead', 'readMessage',
477 'setDataMode', 'parsePacket', 'isListening', 'setBitOrder',
478 'beginPacket', 'isDirectory', 'motorsWrite', 'drawCompass',
479 'digitalRead', 'clearScreen', 'serialEvent', 'rightToLeft',
480 'setTextSize', 'leftToRight', 'requestFrom', 'keyReleased',
481 'compassRead', 'analogWrite', 'interrupts', 'WiFiServer',
482 'disconnect', 'playMelody', 'parseFloat', 'autoscroll',
483 'getPINUsed', 'setPINUsed', 'setTimeout', 'sendAnalog',
484 'readSlider', 'analogRead', 'beginWrite', 'createChar',
485 'motorsStop', 'keyPressed', 'tempoWrite', 'readButton',
486 'subnetMask', 'debugPrint', 'macAddress', 'writeGreen',
487 'randomSeed', 'attachGPRS', 'readString', 'sendString',
488 'remotePort', 'releaseAll', 'mouseMoved', 'background',
489 'getXChange', 'getYChange', 'answerCall', 'getResult',
490 'voiceCall', 'endPacket', 'constrain', 'getSocket', 'writeJSON',
491 'getButton', 'available', 'connected', 'findUntil', 'readBytes',
492 'exitValue', 'readGreen', 'writeBlue', 'startLoop', 'IPAddress',
493 'isPressed', 'sendSysex', 'pauseMode', 'gatewayIP', 'setCursor',
494 'getOemKey', 'tuneWrite', 'noDisplay', 'loadImage', 'switchPIN',
495 'onRequest', 'onReceive', 'changePIN', 'playFile', 'noBuffer',
496 'parseInt', 'overflow', 'checkPIN', 'knobRead', 'beginTFT',
497 'bitClear', 'updateIR', 'bitWrite', 'position', 'writeRGB',
498 'highByte', 'writeRed', 'setSpeed', 'readBlue', 'noStroke',
499 'remoteIP', 'transfer', 'shutdown', 'hangCall', 'beginSMS',
500 'endWrite', 'attached', 'maintain', 'noCursor', 'checkReg',
501 'checkPUK', 'shiftOut', 'isValid', 'shiftIn', 'pulseIn',
502 'connect', 'println', 'localIP', 'pinMode', 'getIMEI',
503 'display', 'noBlink', 'process', 'getBand', 'running', 'beginSD',
504 'drawBMP', 'lowByte', 'setBand', 'release', 'bitRead', 'prepare',
505 'pointTo', 'readRed', 'setMode', 'noFill', 'remove', 'listen',
506 'stroke', 'detach', 'attach', 'noTone', 'exists', 'buffer',
507 'height', 'bitSet', 'circle', 'config', 'cursor', 'random',
508 'IRread', 'sizeof', 'setDNS', 'endSMS', 'getKey', 'micros',
509 'millis', 'begin', 'print', 'write', 'ready', 'flush', 'width',
510 'isPIN', 'blink', 'clear', 'press', 'mkdir', 'rmdir', 'close',
511 'point', 'yield', 'image', 'float', 'BSSID', 'click', 'delay',
512 'read', 'text', 'move', 'peek', 'beep', 'rect', 'line', 'open',
513 'seek', 'fill', 'size', 'turn', 'stop', 'home', 'find', 'char',
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
519 def get_tokens_unprocessed(self, text):
520 for index, token, value in CppLexer.get_tokens_unprocessed(self, text):
521 if token is Name:
522 if value in self.constants:
523 yield index, Keyword.Constant, value
524 elif value in self.functions:
525 yield index, Name.Function, value
526 elif value in self.storage:
527 yield index, Keyword.Type, value
528 else:
529 yield index, token, value
530 elif token is Name.Function:
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:
541 yield index, token, value

eric ide

mercurial