KXStudio Website https://kx.studio/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ecmascript.php 7.7KB

11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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.8.11
  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. $language_data = array (
  48. 'LANG_NAME' => 'ECMAScript',
  49. 'COMMENT_SINGLE' => array(1 => '//'),
  50. 'COMMENT_MULTI' => array('/*' => '*/'),
  51. // Regular Expression Literals
  52. 'COMMENT_REGEXP' => array(2 => "/(?<=[\\s^])s\\/(?:\\\\.|(?!\n)[^\\*\\/\\\\])+\\/(?:\\\\.|(?!\n)[^\\*\\/\\\\])+\\/[gimsu]*(?=[\\s$\\.\\;])|(?<=[\\s^(=])m?\\/(?:\\\\.|(?!\n)[^\\*\\/\\\\])+\\/[gimsu]*(?=[\\s$\\.\\,\\;\\)])/iU"),
  53. 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
  54. 'QUOTEMARKS' => array("'", '"'),
  55. 'ESCAPE_CHAR' => '',
  56. 'ESCAPE_REGEXP' => array(
  57. //Simple Single Char Escapes
  58. 1 => "#\\\\[\\\\abfnrtv\'\"?\n]#i",
  59. //Hexadecimal Char Specs
  60. 2 => "#\\\\x[\da-fA-F]{2}#",
  61. //Hexadecimal Char Specs
  62. 3 => "#\\\\u[\da-fA-F]{4}#",
  63. //Hexadecimal Char Specs
  64. 4 => "#\\\\U[\da-fA-F]{8}#",
  65. //Octal Char Specs
  66. 5 => "#\\\\[0-7]{1,3}#"
  67. ),
  68. 'NUMBERS' =>
  69. GESHI_NUMBER_INT_BASIC | GESHI_NUMBER_INT_CSTYLE | GESHI_NUMBER_BIN_PREFIX_0B |
  70. GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX | GESHI_NUMBER_FLT_NONSCI |
  71. GESHI_NUMBER_FLT_NONSCI_F | GESHI_NUMBER_FLT_SCI_SHORT | GESHI_NUMBER_FLT_SCI_ZERO,
  72. 'KEYWORDS' => array(
  73. 1 => array( // Reserved literals
  74. 'false', 'true',
  75. 'null'
  76. ),
  77. 2 => array( // Main keywords
  78. 'break', 'case', 'catch', 'continue', 'default', 'delete', 'do', 'else',
  79. 'finally', 'for', 'function', 'if', 'in', 'instanceof', 'new', 'return',
  80. 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while',
  81. 'with'
  82. ),
  83. 3 => array( // Extra keywords or keywords reserved for future use
  84. 'abstract', 'as', 'boolean', 'byte', 'char', 'class', 'const', 'debugger',
  85. 'double', 'enum', 'export', 'extends', 'final', 'float', 'goto', 'implements',
  86. 'import', 'int', 'interface', 'is', 'long', 'native', 'namespace', 'package',
  87. 'private', 'protected', 'public', 'short', 'static', 'super', 'synchronized', 'throws',
  88. 'transient', 'use', 'volatile'
  89. ),
  90. 4 => array( // Operators
  91. 'get', 'set'
  92. ),
  93. 5 => array( // Built-in object classes
  94. 'Array', 'Boolean', 'Date', 'EvalError', 'Error', 'Function', 'Math', 'Number',
  95. 'Object', 'RangeError', 'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError'
  96. ),
  97. 6 => array( // Global properties
  98. 'Infinity', 'NaN', 'undefined'
  99. ),
  100. 7 => array( // Global methods
  101. 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent',
  102. 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt',
  103. // The escape and unescape functions do not work properly for non-ASCII characters and have been deprecated.
  104. // In JavaScript 1.5 and later, use encodeURI, decodeURI, encodeURIComponent, and decodeURIComponent.
  105. 'escape', 'unescape'
  106. ),
  107. 8 => array( // Function's arguments
  108. 'arguments'
  109. )
  110. ),
  111. 'SYMBOLS' => array(
  112. '(', ')', '[', ']', '{', '}',
  113. '+', '-', '*', '/', '%',
  114. '!', '.', '&', '|', '^',
  115. '<', '>', '=', '~',
  116. ',', ';', '?', ':'
  117. ),
  118. 'CASE_SENSITIVE' => array(
  119. GESHI_COMMENTS => false,
  120. 1 => true,
  121. 2 => true,
  122. 3 => true,
  123. 4 => true,
  124. 5 => true,
  125. 6 => true,
  126. 7 => true,
  127. 8 => true
  128. ),
  129. 'STYLES' => array(
  130. 'KEYWORDS' => array(
  131. 1 => 'color: #009999;',
  132. 2 => 'color: #1500C8;',
  133. 3 => 'color: #1500C8;',
  134. 4 => 'color: #1500C8;',
  135. 5 => 'color: #1500C8;',
  136. 6 => 'color: #1500C8;',
  137. 7 => 'color: #1500C8;',
  138. 8 => 'color: #1500C8;'
  139. ),
  140. 'COMMENTS' => array(
  141. 1 => 'color: #666666; font-style: italic;',
  142. 2 => 'color: #CC0000;',
  143. 'MULTI' => 'color: #666666; font-style: italic;'
  144. ),
  145. 'ESCAPE_CHAR' => array(
  146. 0 => 'color: #3366CC;',
  147. 1 => 'color: #3366CC;',
  148. 2 => 'color: #3366CC;',
  149. 3 => 'color: #3366CC;',
  150. 4 => 'color: #3366CC;',
  151. 5 => 'color: #3366CC;',
  152. 'HARD' => '',
  153. ),
  154. 'BRACKETS' => array(
  155. 0 => 'color: #008800;'
  156. ),
  157. 'STRINGS' => array(
  158. 0 => 'color: #9900FF;'
  159. ),
  160. 'NUMBERS' => array(
  161. 0 => 'color: #FF00FF;',
  162. GESHI_NUMBER_BIN_PREFIX_0B => 'color: #FF00FF;',
  163. GESHI_NUMBER_OCT_PREFIX => 'color: #FF00FF;',
  164. GESHI_NUMBER_HEX_PREFIX => 'color: #FF00FF;',
  165. GESHI_NUMBER_FLT_SCI_SHORT => 'color: #FF00FF;',
  166. GESHI_NUMBER_FLT_SCI_ZERO => 'color: #FF00FF;',
  167. GESHI_NUMBER_FLT_NONSCI_F => 'color: #FF00FF;',
  168. GESHI_NUMBER_FLT_NONSCI => 'color: #FF00FF;'
  169. ),
  170. 'METHODS' => array(
  171. 1 => 'color: #660066;'
  172. ),
  173. 'SYMBOLS' => array(
  174. 0 => 'color: #339933;'
  175. ),
  176. 'REGEXPS' => array(
  177. ),
  178. 'SCRIPT' => array(
  179. 0 => '',
  180. 1 => '',
  181. 2 => '',
  182. 3 => ''
  183. )
  184. ),
  185. 'URLS' => array(
  186. 1 => '',
  187. 2 => '',
  188. 3 => '',
  189. 4 => '',
  190. 5 => '',
  191. 6 => '',
  192. 7 => '',
  193. 8 => ''
  194. ),
  195. 'OOLANG' => true,
  196. 'OBJECT_SPLITTERS' => array(
  197. 1 => '.'
  198. ),
  199. 'REGEXPS' => array(
  200. ),
  201. 'STRICT_MODE_APPLIES' => GESHI_NEVER,
  202. 'SCRIPT_DELIMITERS' => array(
  203. ),
  204. 'HIGHLIGHT_STRICT_BLOCK' => array(
  205. ),
  206. 'TAB_WIDTH' => 4
  207. );
  208. ?>