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

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

Carlos

  • Moderador Global
  • ****
  • Mensajes: 294
Resaltado de sintaxis Arduino para Genshi
« en: 02/Abr/2015, 01:08:26 am »
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) [Seleccionar]
<?php
/*************************************************************************************
 * arduino.php (based on c.php)
 * -----
 * Author: Nigel McNie (nigel@geshi.org)
 * Contributors:
 *  - Jack Lloyd (lloyd@randombit.net)
 *  - Michael Mol (mikemol@gmail.com)
 *  - Trimbitas Sorin-Iulian (trimbitassorin@hotmail.com)
 *  - Rick Winscot (rick.winscot@gmail.com)
 *
 * Copyright: (c) 2004 Nigel McNie (http://qbnz.com/highlighter/)
 * Release Version: 1.0.1
 * Date Started: 2009/08/09
 *
 * Arduino language file for GeSHi.
 *
 * CHANGES
 * -------
 *  2012/17/12 (1.0.1)
 *   -  Implemented REDIRECT for handling complex URLs (see: redirect.php )
 *   -  Added Arduino primary function reference links
 *  2009/08/09 (1.0.0)
 *   -  Forked / first release c.php 1.0.8.3 => arduino.php 1.0.0
 *
 * TODO (updated 2012/12/17)
 * -------------------------
 *  -  first, second, and fourth level reference links
 *  -  add drop-in support for libraries 
 *
 *************************************************************************************
 *
 *     This file is part of GeSHi.
 *
 *   GeSHi is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   GeSHi is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with GeSHi; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 ************************************************************************************/

$language_data = array (
    
'LANG_NAME' => 'Arduino',
    
'COMMENT_SINGLE' => array(=> '//'=> '#'),
    
'COMMENT_MULTI' => array('/*' => '*/'),
    
'COMMENT_REGEXP' => array(
        
//Multiline-continued single-line comments
        
=> '/\/\/(?:\\\\\\\\|\\\\\\n|.)*$/m',
        
//Multiline-continued preprocessor define
        
=> '/#(?:\\\\\\\\|\\\\\\n|.)*$/m'
        
),
    
'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
    
'QUOTEMARKS' => array("'"'"'),
    
'ESCAPE_CHAR' => '',
    
'ESCAPE_REGEXP' => array(
        
//Simple Single Char Escapes
        
=> "#\\\\[\\\\abfnrtv\'\"?\n]#i",
        
//Hexadecimal Char Specs
        
=> "#\\\\x[\da-fA-F]{2}#",
        
//Hexadecimal Char Specs
        
=> "#\\\\u[\da-fA-F]{4}#",
        
//Hexadecimal Char Specs
        
=> "#\\\\U[\da-fA-F]{8}#",
        
//Octal Char Specs
        
=> "#\\\\[0-7]{1,3}#"
        
),
    
'NUMBERS' =>
        
GESHI_NUMBER_INT_BASIC GESHI_NUMBER_INT_CSTYLE GESHI_NUMBER_BIN_PREFIX_0B |
        
GESHI_NUMBER_OCT_PREFIX GESHI_NUMBER_HEX_PREFIX GESHI_NUMBER_FLT_NONSCI |
        
GESHI_NUMBER_FLT_NONSCI_F GESHI_NUMBER_FLT_SCI_SHORT GESHI_NUMBER_FLT_SCI_ZERO,
    
'KEYWORDS' => array(
        
=> array(
            
'if''return''while''case''continue',
'default''do''else''for''switch''goto'
            
),
        
=> array(
            
'null''false''break''true''function''enum''extern''inline',
            ),
        
=> array(
            
'pinMode''digitalWrite''digitalRead''analogRead''analogWrite''shiftOut''pulseIn',
'millis''micros''delay''delayMicroseconds''min''max''abs''constrain''map''pow',
'sq''sqrt''sin''cos''tan''randomSeed''random''Serial''sizeof''lowByte''highByte',
'bitRead''bitWrite''bitSet''bitClear''bit''attachInterrupt''detachInterrupt''interrupts''noInterrupts''Serial''Stream''sizeof''Mouse''Keyboard'  
            
),
        
=> array(
            
'void''boolean''char''const''unsigned''float''int''long''volatile',
            
'short''signed''static''string''double''byte''''array''word',
            ),
=> array(
    'setup''loop',
    'Serial''pio',
    ),
=> array(
     'HIGH''LOW''INPUT''OUTPUT',
    ),
        ),
    
'SYMBOLS' => array(
        
'('')''{''}''['']',
        
'+''-''*''/''%',
        
'=''<''>',
        
'!''^''&''|',
        
'?'':',
        
';'','
        
),
    
'CASE_SENSITIVE' => array(
        
GESHI_COMMENTS => false,
        
=> true,
        
=> true,
        
=> true,
        
=> true,
        ),
    
'STYLES' => array(
        
'KEYWORDS' => array(
            
=> 'color: #cc6600;',
            
=> 'color: #cc6600;',
            
=> 'color: #cc6600;',
            
=> 'color: #cc6600;',
            
=> 'color: #cc6600; font-weight: bold;',
            
=> 'color: #006699;',
            ),
        
'COMMENTS' => array(
            
=> 'color: #666666; font-style: italic;',
            
=> 'color: #339933;',
            
'MULTI' => 'color: #808080; font-style: italic;'
            
),
        
'ESCAPE_CHAR' => array(
            
=> 'color: #006699; font-weight: bold;',
            
=> 'color: #006699; font-weight: bold;',
            
=> 'color: #006699; font-weight: bold;',
            
=> 'color: #006699; font-weight: bold;',
            
=> 'color: #006699; font-weight: bold;',
            
=> 'color: #006699; font-weight: bold;',
            
'HARD' => '',
            ),
        
'BRACKETS' => array(
            
=> 'color: #000000;'
            
),
        
'STRINGS' => array(
            
=> 'color: #006699;'
            
),
        
'NUMBERS' => array(
            
=> 'color: #000000;',
            
GESHI_NUMBER_BIN_PREFIX_0B => 'color: #208080;',
            
GESHI_NUMBER_OCT_PREFIX => 'color: #208080;',
            
GESHI_NUMBER_HEX_PREFIX => 'color: #208080;',
            
GESHI_NUMBER_FLT_SCI_SHORT => 'color:#800080;',
            
GESHI_NUMBER_FLT_SCI_ZERO => 'color:#800080;',
            
GESHI_NUMBER_FLT_NONSCI_F => 'color:#800080;',
            
GESHI_NUMBER_FLT_NONSCI => 'color:#800080;'
            
),
        
'METHODS' => array(
            
=> 'color: #202020;',
            
=> 'color: #202020;'
            
),
        
'SYMBOLS' => array(
            
=> 'color: #000000;'
            
),
        
'REGEXPS' => array(
            ),
        
'SCRIPT' => array(
            )
        ),
    
'URLS' => array(
        
=> '',
        
=> '',
        
=> 'geshi/redirect.php?language=arduino&search={FNAME}',
        
=> ''
        
),
    
'REDIRECT' => array(
    
'setup' => 'http://arduino.cc/en/Reference/Setup',
    
'loop' => 'http://arduino.cc/en/Reference/Loop',
    
'pinMode' => 'http://arduino.cc/en/Reference/PinMode',
    
'digitalWrite' => 'http://arduino.cc/en/Reference/DigitalWrite',
    
'digitalRead' => 'http://arduino.cc/en/Reference/DigitalRead',
    
'analogReference' => 'http://arduino.cc/en/Reference/AnalogReference',
    
'analogRead' => 'http://arduino.cc/en/Reference/AnalogRead',
    
'analogWrite' => 'http://arduino.cc/en/Reference/AnalogWrite',
    
'analogReadResolution' => 'http://arduino.cc/en/Reference/AnalogReadResolution',
    
'analogWriteResolution' => 'http://arduino.cc/en/Reference/AnalogWriteResolution',
    
'tone' => 'http://arduino.cc/en/Reference/Tone',
    
'noTone' => 'http://arduino.cc/en/Reference/NoTone',
    
'shiftOut' => 'http://arduino.cc/en/Reference/ShiftOut',
    
'shiftIn' => 'http://arduino.cc/en/Reference/ShiftIn',
    
'pulseIn' => 'http://arduino.cc/en/Reference/PulseIn',
    
'millis' => 'http://arduino.cc/en/Reference/Millis',
    
'micros' => 'http://arduino.cc/en/Reference/Micros',
    
'delay' => 'http://arduino.cc/en/Reference/Delay',
    
'delayMicroseconds' => 'http://arduino.cc/en/Reference/DelayMicroseconds',
    
'min' => 'http://arduino.cc/en/Reference/Min',
    
'max' => 'http://arduino.cc/en/Reference/Max',
    
'abs' => 'http://arduino.cc/en/Reference/Abs',
    
'constrain' => 'http://arduino.cc/en/Reference/Constrain',
    
'map' => 'http://arduino.cc/en/Reference/Map',
    
'pow' => 'http://arduino.cc/en/Reference/Pow',
    
'sqrt' => 'http://arduino.cc/en/Reference/Sqrt',
    
'sin' => 'http://arduino.cc/en/Reference/Sin',
    
'cos' => 'http://arduino.cc/en/Reference/Cos',
    
'tan' => 'http://arduino.cc/en/Reference/Tan',
    
'randomSeed' => 'http://arduino.cc/en/Reference/RandomSeed',
    
'random' => 'http://arduino.cc/en/Reference/Random',
    
'lowByte' => 'http://arduino.cc/en/Reference/LowByte',
    
'highByte' => 'http://arduino.cc/en/Reference/HighByte',
    
'bitRead' => 'http://arduino.cc/en/Reference/BitRead',
    
'bitWrite' => 'http://arduino.cc/en/Reference/BitWrite',
    
'bitSet' => 'http://arduino.cc/en/Reference/BitSet',
    
'bitClear' => 'http://arduino.cc/en/Reference/BitClear',
    
'bit' => 'http://arduino.cc/en/Reference/Bit',
    
'attachInterrupt' => 'http://arduino.cc/en/Reference/AttachInterrupt',
    
'detachInterrupt' => 'http://arduino.cc/en/Reference/DetachInterrupt',
    
'interrupts' => 'http://arduino.cc/en/Reference/Interrupts',
    
'noInterrupts' => 'http://arduino.cc/en/Reference/NoInterrupts',
    
'Serial' => 'http://arduino.cc/en/Reference/Serial',
    
'Stream' => 'http://arduino.cc/en/Reference/Stream',
    
'sizeof' => 'http://arduino.cc/en/Reference/Sizeof',
    
'Keyboard' => 'http://arduino.cc/en/Reference/Keyboard',
    
'Mouse' => 'http://arduino.cc/en/Reference/Mouse'
    
),
    
'OOLANG' => true,
    
'OBJECT_SPLITTERS' => array(
        
=> '.',
        
=> '::'
        
),
    
'REGEXPS' => array(
        ),
    
'STRICT_MODE_APPLIES' => GESHI_NEVER,
    
'SCRIPT_DELIMITERS' => array(
        ),
    
'HIGHLIGHT_STRICT_BLOCK' => array(
        ),
    
'TAB_WIDTH' => 4
);

?>


Saludos.
« Última modificación: 01/Sep/2015, 10:01:17 am por Picuino »