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 |