Autor Tema: Resaltado de sintaxis Arduino para Genshi  (Leído 1176 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Carlos

  • Moderador Global
  • ****
  • Mensajes: 325
Resaltado de sintaxis Arduino para Genshi
« en: 02/Abr./2015, 01:08:26 a. m. »
GeSHi es un programa para resaltado de sintaxis de código.
Está escrito en php y lo utiliza este foro.
Adjunto la modificación para resaltar sintaxis del código Arduino (1.0.6)

El programa original en el que está basado es:
https://github.com/rwinscot/geshi-arduino

Código: PHP
  1. <?php
  2. /*************************************************************************************
  3.  * arduino.php (based on c.php)
  4.  * -----
  5.  * Author: Nigel McNie (nigel@geshi.org)
  6.  * Contributors:
  7.  *  - Jack Lloyd (lloyd@randombit.net)
  8.  *  - Michael Mol (mikemol@gmail.com)
  9.  *  - Trimbitas Sorin-Iulian (trimbitassorin@hotmail.com)
  10.  *  - Rick Winscot (rick.winscot@gmail.com)
  11.  *
  12.  * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/)
  13.  * Release Version: 1.0.1
  14.  * Date Started: 2009/08/09
  15.  *
  16.  * Arduino language file for GeSHi.
  17.  *
  18.  * CHANGES
  19.  * -------
  20.  *  2012/17/12 (1.0.1)
  21.  *   -  Implemented REDIRECT for handling complex URLs (see: redirect.php )
  22.  *   -  Added Arduino primary function reference links
  23.  *  2009/08/09 (1.0.0)
  24.  *   -  Forked / first release c.php 1.0.8.3 => arduino.php 1.0.0
  25.  *
  26.  * TODO (updated 2012/12/17)
  27.  * -------------------------
  28.  *  -  first, second, and fourth level reference links
  29.  *  -  add drop-in support for libraries
  30.  *
  31.  *************************************************************************************
  32.  *
  33.  *     This file is part of GeSHi.
  34.  *
  35.  *   GeSHi is free software; you can redistribute it and/or modify
  36.  *   it under the terms of the GNU General Public License as published by
  37.  *   the Free Software Foundation; either version 2 of the License, or
  38.  *   (at your option) any later version.
  39.  *
  40.  *   GeSHi is distributed in the hope that it will be useful,
  41.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  42.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  43.  *   GNU General Public License for more details.
  44.  *
  45.  *   You should have received a copy of the GNU General Public License
  46.  *   along with GeSHi; if not, write to the Free Software
  47.  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  48.  *
  49.  ************************************************************************************/
  50.  
  51. $language_data = array (
  52.     'LANG_NAME' => 'Arduino',
  53.     'COMMENT_SINGLE' => array(1 => '//', 2 => '#'),
  54.     'COMMENT_MULTI' => array('/*' => '*/'),
  55.     'COMMENT_REGEXP' => array(
  56.         //Multiline-continued single-line comments
  57.         1 => '/\/\/(?:\\\\\\\\|\\\\\\n|.)*$/m',
  58.         //Multiline-continued preprocessor define
  59.         2 => '/#(?:\\\\\\\\|\\\\\\n|.)*$/m'
  60.         ),
  61.     'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
  62.     'QUOTEMARKS' => array("'", '"'),
  63.     'ESCAPE_CHAR' => '',
  64.     'ESCAPE_REGEXP' => array(
  65.         //Simple Single Char Escapes
  66.         1 => "#\\\\[\\\\abfnrtv\'\"?\n]#i",
  67.         //Hexadecimal Char Specs
  68.         2 => "#\\\\x[\da-fA-F]{2}#",
  69.         //Hexadecimal Char Specs
  70.         3 => "#\\\\u[\da-fA-F]{4}#",
  71.         //Hexadecimal Char Specs
  72.         4 => "#\\\\U[\da-fA-F]{8}#",
  73.         //Octal Char Specs
  74.         5 => "#\\\\[0-7]{1,3}#"
  75.         ),
  76.     'NUMBERS' =>
  77.         GESHI_NUMBER_INT_BASIC | GESHI_NUMBER_INT_CSTYLE | GESHI_NUMBER_BIN_PREFIX_0B |
  78.         GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX | GESHI_NUMBER_FLT_NONSCI |
  79.         GESHI_NUMBER_FLT_NONSCI_F | GESHI_NUMBER_FLT_SCI_SHORT | GESHI_NUMBER_FLT_SCI_ZERO,
  80.     'KEYWORDS' => array(
  81.         1 => array(
  82.             'if', 'return', 'while', 'case', 'continue',
  83.                         'default', 'do', 'else', 'for', 'switch', 'goto'
  84.             ),
  85.         2 => array(
  86.             'null', 'false', 'break', 'true', 'function', 'enum', 'extern', 'inline',
  87.             ),
  88.         3 => array(
  89.             'pinMode', 'digitalWrite', 'digitalRead', 'analogRead', 'analogWrite', 'shiftOut', 'pulseIn',
  90.                         'millis', 'micros', 'delay', 'delayMicroseconds', 'min', 'max', 'abs', 'constrain', 'map', 'pow',
  91.                         'sq', 'sqrt', 'sin', 'cos', 'tan', 'randomSeed', 'random', 'Serial', 'sizeof', 'lowByte', 'highByte',
  92.                         'bitRead', 'bitWrite', 'bitSet', 'bitClear', 'bit', 'attachInterrupt', 'detachInterrupt', 'interrupts', 'noInterrupts', 'Serial', 'Stream', 'sizeof', 'Mouse', 'Keyboard'  
  93.             ),
  94.         4 => array(
  95.             'void', 'boolean', 'char', 'const', 'unsigned', 'float', 'int', 'long', 'volatile',
  96.             'short', 'signed', 'static', 'string', 'double', 'byte', '', 'array', 'word',
  97.             ),
  98.                 5 => array(
  99.                     'setup', 'loop',
  100.                     'Serial', 'pio',
  101.                     ),
  102.                 6 => array(
  103.                      'HIGH', 'LOW', 'INPUT', 'OUTPUT',
  104.                     ),
  105.         ),
  106.     'SYMBOLS' => array(
  107.         '(', ')', '{', '}', '[', ']',
  108.         '+', '-', '*', '/', '%',
  109.         '=', '<', '>',
  110.         '!', '^', '&', '|',
  111.         '?', ':',
  112.         ';', ','
  113.         ),
  114.     'CASE_SENSITIVE' => array(
  115.         GESHI_COMMENTS => false,
  116.         1 => true,
  117.         2 => true,
  118.         3 => true,
  119.         4 => true,
  120.         ),
  121.     'STYLES' => array(
  122.         'KEYWORDS' => array(
  123.             1 => 'color: #cc6600;',
  124.             2 => 'color: #cc6600;',
  125.             3 => 'color: #cc6600;',
  126.             4 => 'color: #cc6600;',
  127.             5 => 'color: #cc6600; font-weight: bold;',
  128.             6 => 'color: #006699;',
  129.             ),
  130.         'COMMENTS' => array(
  131.             1 => 'color: #666666; font-style: italic;',
  132.             2 => 'color: #339933;',
  133.             'MULTI' => 'color: #808080; font-style: italic;'
  134.             ),
  135.         'ESCAPE_CHAR' => array(
  136.             0 => 'color: #006699; font-weight: bold;',
  137.             1 => 'color: #006699; font-weight: bold;',
  138.             2 => 'color: #006699; font-weight: bold;',
  139.             3 => 'color: #006699; font-weight: bold;',
  140.             4 => 'color: #006699; font-weight: bold;',
  141.             5 => 'color: #006699; font-weight: bold;',
  142.             'HARD' => '',
  143.             ),
  144.         'BRACKETS' => array(
  145.             0 => 'color: #000000;'
  146.             ),
  147.         'STRINGS' => array(
  148.             0 => 'color: #006699;'
  149.             ),
  150.         'NUMBERS' => array(
  151.             0 => 'color: #000000;',
  152.             GESHI_NUMBER_BIN_PREFIX_0B => 'color: #208080;',
  153.             GESHI_NUMBER_OCT_PREFIX => 'color: #208080;',
  154.             GESHI_NUMBER_HEX_PREFIX => 'color: #208080;',
  155.             GESHI_NUMBER_FLT_SCI_SHORT => 'color:#800080;',
  156.             GESHI_NUMBER_FLT_SCI_ZERO => 'color:#800080;',
  157.             GESHI_NUMBER_FLT_NONSCI_F => 'color:#800080;',
  158.             GESHI_NUMBER_FLT_NONSCI => 'color:#800080;'
  159.             ),
  160.         'METHODS' => array(
  161.             1 => 'color: #202020;',
  162.             2 => 'color: #202020;'
  163.             ),
  164.         'SYMBOLS' => array(
  165.             0 => 'color: #000000;'
  166.             ),
  167.         'REGEXPS' => array(
  168.             ),
  169.         'SCRIPT' => array(
  170.             )
  171.         ),
  172.     'URLS' => array(
  173.         1 => '',
  174.         2 => '',
  175.         3 => 'geshi/redirect.php?language=arduino&search={FNAME}',
  176.         4 => ''
  177.         ),
  178.     'REDIRECT' => array(
  179.         'setup' => 'http://arduino.cc/en/Reference/Setup',
  180.         'loop' => 'http://arduino.cc/en/Reference/Loop',
  181.         'pinMode' => 'http://arduino.cc/en/Reference/PinMode',
  182.         'digitalWrite' => 'http://arduino.cc/en/Reference/DigitalWrite',
  183.         'digitalRead' => 'http://arduino.cc/en/Reference/DigitalRead',
  184.         'analogReference' => 'http://arduino.cc/en/Reference/AnalogReference',
  185.         'analogRead' => 'http://arduino.cc/en/Reference/AnalogRead',
  186.         'analogWrite' => 'http://arduino.cc/en/Reference/AnalogWrite',
  187.         'analogReadResolution' => 'http://arduino.cc/en/Reference/AnalogReadResolution',
  188.         'analogWriteResolution' => 'http://arduino.cc/en/Reference/AnalogWriteResolution',
  189.         'tone' => 'http://arduino.cc/en/Reference/Tone',
  190.         'noTone' => 'http://arduino.cc/en/Reference/NoTone',
  191.         'shiftOut' => 'http://arduino.cc/en/Reference/ShiftOut',
  192.         'shiftIn' => 'http://arduino.cc/en/Reference/ShiftIn',
  193.         'pulseIn' => 'http://arduino.cc/en/Reference/PulseIn',
  194.         'millis' => 'http://arduino.cc/en/Reference/Millis',
  195.         'micros' => 'http://arduino.cc/en/Reference/Micros',
  196.         'delay' => 'http://arduino.cc/en/Reference/Delay',
  197.         'delayMicroseconds' => 'http://arduino.cc/en/Reference/DelayMicroseconds',
  198.         'min' => 'http://arduino.cc/en/Reference/Min',
  199.         'max' => 'http://arduino.cc/en/Reference/Max',
  200.         'abs' => 'http://arduino.cc/en/Reference/Abs',
  201.         'constrain' => 'http://arduino.cc/en/Reference/Constrain',
  202.         'map' => 'http://arduino.cc/en/Reference/Map',
  203.         'pow' => 'http://arduino.cc/en/Reference/Pow',
  204.         'sqrt' => 'http://arduino.cc/en/Reference/Sqrt',
  205.         'sin' => 'http://arduino.cc/en/Reference/Sin',
  206.         'cos' => 'http://arduino.cc/en/Reference/Cos',
  207.         'tan' => 'http://arduino.cc/en/Reference/Tan',
  208.         'randomSeed' => 'http://arduino.cc/en/Reference/RandomSeed',
  209.         'random' => 'http://arduino.cc/en/Reference/Random',
  210.         'lowByte' => 'http://arduino.cc/en/Reference/LowByte',
  211.         'highByte' => 'http://arduino.cc/en/Reference/HighByte',
  212.         'bitRead' => 'http://arduino.cc/en/Reference/BitRead',
  213.         'bitWrite' => 'http://arduino.cc/en/Reference/BitWrite',
  214.         'bitSet' => 'http://arduino.cc/en/Reference/BitSet',
  215.         'bitClear' => 'http://arduino.cc/en/Reference/BitClear',
  216.         'bit' => 'http://arduino.cc/en/Reference/Bit',
  217.         'attachInterrupt' => 'http://arduino.cc/en/Reference/AttachInterrupt',
  218.         'detachInterrupt' => 'http://arduino.cc/en/Reference/DetachInterrupt',
  219.         'interrupts' => 'http://arduino.cc/en/Reference/Interrupts',
  220.         'noInterrupts' => 'http://arduino.cc/en/Reference/NoInterrupts',
  221.         'Serial' => 'http://arduino.cc/en/Reference/Serial',
  222.         'Stream' => 'http://arduino.cc/en/Reference/Stream',
  223.         'sizeof' => 'http://arduino.cc/en/Reference/Sizeof',
  224.         'Keyboard' => 'http://arduino.cc/en/Reference/Keyboard',
  225.         'Mouse' => 'http://arduino.cc/en/Reference/Mouse'
  226.         ),
  227.     'OOLANG' => true,
  228.     'OBJECT_SPLITTERS' => array(
  229.         1 => '.',
  230.         2 => '::'
  231.         ),
  232.     'REGEXPS' => array(
  233.         ),
  234.     'STRICT_MODE_APPLIES' => GESHI_NEVER,
  235.     'SCRIPT_DELIMITERS' => array(
  236.         ),
  237.     'HIGHLIGHT_STRICT_BLOCK' => array(
  238.         ),
  239.     'TAB_WIDTH' => 4
  240. );
  241.  
  242. ?>
  243.  

Saludos.
« Última modificación: 01/Sept./2015, 10:01:17 a. m. por Picuino »