[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 * ecmascript.php 4 * -------------- 5 * Author: Michel Mariani (http://www.tonton-pixel.com/site/) 6 * Copyright: (c) 2010 Michel Mariani (http://www.tonton-pixel.com/site/) 7 * Release Version: 1.0.9.1 8 * Date Started: 2010/01/08 9 * 10 * ECMAScript language file for GeSHi. 11 * 12 * CHANGES 13 * ------- 14 * 2010/01/08 (1.0.8.6) 15 * - First Release 16 * - Adapted from javascript.php to support plain ECMAScript/JavaScript (no HTML, no DOM) 17 * - Fixed regular expression for 'COMMENT_REGEXP' to exclude 'COMMENT_MULTI' syntax 18 * - Added '~' and removed '@' from 'SYMBOLS' 19 * - Cleaned up and expanded the list of 'KEYWORDS' 20 * - Added support for 'ESCAPE_REGEXP' and 'NUMBERS' (from c.php) 21 * - Selected colors to match my web site color chart 22 * - Added full number highlighting in all C language style formats 23 * - Added highlighting of escape sequences in strings, in all C language style formats including Unicode (\uXXXX). 24 * 25 * TODO (updated 2010/01/08) 26 * ------------------------- 27 * 28 ************************************************************************************* 29 * 30 * This file is part of GeSHi. 31 * 32 * GeSHi is free software; you can redistribute it and/or modify 33 * it under the terms of the GNU General Public License as published by 34 * the Free Software Foundation; either version 2 of the License, or 35 * (at your option) any later version. 36 * 37 * GeSHi is distributed in the hope that it will be useful, 38 * but WITHOUT ANY WARRANTY; without even the implied warranty of 39 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 40 * GNU General Public License for more details. 41 * 42 * You should have received a copy of the GNU General Public License 43 * along with GeSHi; if not, write to the Free Software 44 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 45 * 46 ************************************************************************************/ 47 48 $language_data = array ( 49 'LANG_NAME' => 'ECMAScript', 50 'COMMENT_SINGLE' => array(1 => '//'), 51 'COMMENT_MULTI' => array('/*' => '*/'), 52 // Regular Expression Literals 53 'COMMENT_REGEXP' => array(2 => "/(?<=[\\s^])s\\/(?:\\\\.|(?!\n)[^\\*\\/\\\\])+\\/(?:\\\\.|(?!\n)[^\\*\\/\\\\])+\\/[gimsu]*(?=[\\s$\\.\\;])|(?<=[\\s^(=])m?\\/(?:\\\\.|(?!\n)[^\\*\\/\\\\])+\\/[gimsu]*(?=[\\s$\\.\\,\\;\\)])/iU"), 54 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, 55 'QUOTEMARKS' => array("'", '"'), 56 'ESCAPE_CHAR' => '', 57 'ESCAPE_REGEXP' => array( 58 //Simple Single Char Escapes 59 1 => "#\\\\[\\\\abfnrtv\'\"?\n]#i", 60 //Hexadecimal Char Specs 61 2 => "#\\\\x[\da-fA-F]{2}#", 62 //Hexadecimal Char Specs 63 3 => "#\\\\u[\da-fA-F]{4}#", 64 //Hexadecimal Char Specs 65 4 => "#\\\\U[\da-fA-F]{8}#", 66 //Octal Char Specs 67 5 => "#\\\\[0-7]{1,3}#" 68 ), 69 'NUMBERS' => 70 GESHI_NUMBER_INT_BASIC | GESHI_NUMBER_INT_CSTYLE | GESHI_NUMBER_BIN_PREFIX_0B | 71 GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX | GESHI_NUMBER_FLT_NONSCI | 72 GESHI_NUMBER_FLT_NONSCI_F | GESHI_NUMBER_FLT_SCI_SHORT | GESHI_NUMBER_FLT_SCI_ZERO, 73 'KEYWORDS' => array( 74 1 => array( // Reserved literals 75 'false', 'true', 76 'null' 77 ), 78 2 => array( // Main keywords 79 'break', 'case', 'catch', 'continue', 'default', 'delete', 'do', 'else', 80 'finally', 'for', 'function', 'if', 'in', 'instanceof', 'new', 'return', 81 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 82 'with' 83 ), 84 3 => array( // Extra keywords or keywords reserved for future use 85 'abstract', 'as', 'boolean', 'byte', 'char', 'class', 'const', 'debugger', 86 'double', 'enum', 'export', 'extends', 'final', 'float', 'goto', 'implements', 87 'import', 'int', 'interface', 'is', 'long', 'native', 'namespace', 'package', 88 'private', 'protected', 'public', 'short', 'static', 'super', 'synchronized', 'throws', 89 'transient', 'use', 'volatile' 90 ), 91 4 => array( // Operators 92 'get', 'set' 93 ), 94 5 => array( // Built-in object classes 95 'Array', 'Boolean', 'Date', 'EvalError', 'Error', 'Function', 'Math', 'Number', 96 'Object', 'RangeError', 'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError' 97 ), 98 6 => array( // Global properties 99 'Infinity', 'NaN', 'undefined' 100 ), 101 7 => array( // Global methods 102 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 103 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 104 // The escape and unescape functions do not work properly for non-ASCII characters and have been deprecated. 105 // In JavaScript 1.5 and later, use encodeURI, decodeURI, encodeURIComponent, and decodeURIComponent. 106 'escape', 'unescape' 107 ), 108 8 => array( // Function's arguments 109 'arguments' 110 ) 111 ), 112 'SYMBOLS' => array( 113 '(', ')', '[', ']', '{', '}', 114 '+', '-', '*', '/', '%', 115 '!', '.', '&', '|', '^', 116 '<', '>', '=', '~', 117 ',', ';', '?', ':' 118 ), 119 'CASE_SENSITIVE' => array( 120 GESHI_COMMENTS => false, 121 1 => true, 122 2 => true, 123 3 => true, 124 4 => true, 125 5 => true, 126 6 => true, 127 7 => true, 128 8 => true 129 ), 130 'STYLES' => array( 131 'KEYWORDS' => array( 132 1 => 'color: #009999;', 133 2 => 'color: #1500C8;', 134 3 => 'color: #1500C8;', 135 4 => 'color: #1500C8;', 136 5 => 'color: #1500C8;', 137 6 => 'color: #1500C8;', 138 7 => 'color: #1500C8;', 139 8 => 'color: #1500C8;' 140 ), 141 'COMMENTS' => array( 142 1 => 'color: #666666; font-style: italic;', 143 2 => 'color: #CC0000;', 144 'MULTI' => 'color: #666666; font-style: italic;' 145 ), 146 'ESCAPE_CHAR' => array( 147 0 => 'color: #3366CC;', 148 1 => 'color: #3366CC;', 149 2 => 'color: #3366CC;', 150 3 => 'color: #3366CC;', 151 4 => 'color: #3366CC;', 152 5 => 'color: #3366CC;', 153 'HARD' => '', 154 ), 155 'BRACKETS' => array( 156 0 => 'color: #008800;' 157 ), 158 'STRINGS' => array( 159 0 => 'color: #9900FF;' 160 ), 161 'NUMBERS' => array( 162 0 => 'color: #FF00FF;', 163 GESHI_NUMBER_BIN_PREFIX_0B => 'color: #FF00FF;', 164 GESHI_NUMBER_OCT_PREFIX => 'color: #FF00FF;', 165 GESHI_NUMBER_HEX_PREFIX => 'color: #FF00FF;', 166 GESHI_NUMBER_FLT_SCI_SHORT => 'color: #FF00FF;', 167 GESHI_NUMBER_FLT_SCI_ZERO => 'color: #FF00FF;', 168 GESHI_NUMBER_FLT_NONSCI_F => 'color: #FF00FF;', 169 GESHI_NUMBER_FLT_NONSCI => 'color: #FF00FF;' 170 ), 171 'METHODS' => array( 172 1 => 'color: #660066;' 173 ), 174 'SYMBOLS' => array( 175 0 => 'color: #339933;' 176 ), 177 'REGEXPS' => array( 178 ), 179 'SCRIPT' => array( 180 0 => '', 181 1 => '', 182 2 => '', 183 3 => '' 184 ) 185 ), 186 'URLS' => array( 187 1 => '', 188 2 => '', 189 3 => '', 190 4 => '', 191 5 => '', 192 6 => '', 193 7 => '', 194 8 => '' 195 ), 196 'OOLANG' => true, 197 'OBJECT_SPLITTERS' => array( 198 1 => '.' 199 ), 200 'REGEXPS' => array( 201 ), 202 'STRICT_MODE_APPLIES' => GESHI_NEVER, 203 'SCRIPT_DELIMITERS' => array( 204 ), 205 'HIGHLIGHT_STRICT_BLOCK' => array( 206 ), 207 'TAB_WIDTH' => 4 208 );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body