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.

277 lines
14KB

  1. <?php
  2. /*************************************************************************************
  3. * powershell.php
  4. * ---------------------------------
  5. * Author: Frode Aarebrot (frode@aarebrot.net)
  6. * Copyright: (c) 2008 Frode Aarebrot (http://www.aarebrot.net)
  7. * Release Version: 1.0.8.11
  8. * Date Started: 2008/06/20
  9. *
  10. * PowerShell language file for GeSHi.
  11. *
  12. * I've tried to make this language file as true to the highlighting in PowerGUI as
  13. * possible. Unfortunately it's not 100% complete, although it is pretty close.
  14. *
  15. * I've included some classes and their members, but there's tons and tons of these.
  16. * I suggest you add the ones you need yourself. I've included a few Sharepoint ones
  17. * in this language file.
  18. *
  19. * CHANGES
  20. * -------
  21. * 2008/06/20 (1.0.8)
  22. * - First Release
  23. *
  24. * TODO (updated 2008/06/20)
  25. * -------------------------
  26. * - Color text between Cmdlets/Aliases and pipe/end-of-line
  27. * - Try and get -- and ++ to work in the KEYWORDS array with the other operators
  28. *
  29. *************************************************************************************
  30. *
  31. * This file is part of GeSHi.
  32. *
  33. * GeSHi is free software; you can redistribute it and/or modify
  34. * it under the terms of the GNU General Public License as published by
  35. * the Free Software Foundation; either version 2 of the License, or
  36. * (at your option) any later version.
  37. *
  38. * GeSHi is distributed in the hope that it will be useful,
  39. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  40. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  41. * GNU General Public License for more details.
  42. *
  43. * You should have received a copy of the GNU General Public License
  44. * along with GeSHi; if not, write to the Free Software
  45. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  46. *
  47. ************************************************************************************/
  48. $language_data = array (
  49. 'LANG_NAME' => 'PowerShell',
  50. 'COMMENT_SINGLE' => array(1 => '#'),
  51. 'COMMENT_MULTI' => array('<#' => '#>'),
  52. 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
  53. 'QUOTEMARKS' => array("'", '"'),
  54. 'ESCAPE_CHAR' => '`',
  55. 'KEYWORDS' => array(
  56. 1 => array(
  57. // Cmdlets
  58. 'Add-Content', 'Add-History', 'Add-Member', 'Add-PSSnapin', 'Clear-Content', 'Clear-Item',
  59. 'Clear-ItemProperty', 'Clear-Variable', 'Compare-Object', 'ConvertFrom-SecureString',
  60. 'Convert-Path', 'ConvertTo-Html', 'ConvertTo-SecureString', 'Copy-Item', 'Copy-ItemProperty',
  61. 'Export-Alias', 'Export-Clixml', 'Export-Console', 'Export-Csv', 'ForEach-Object',
  62. 'Format-Custom', 'Format-List', 'Format-Table', 'Format-Wide', 'Get-Acl', 'Get-Alias',
  63. 'Get-AuthenticodeSignature', 'Get-ChildItem', 'Get-Command', 'Get-Content', 'Get-Credential',
  64. 'Get-Culture', 'Get-Date', 'Get-EventLog', 'Get-ExecutionPolicy', 'Get-Help', 'Get-History',
  65. 'Get-Host', 'Get-Item', 'Get-ItemProperty', 'Get-Location', 'Get-Member',
  66. 'Get-PfxCertificate', 'Get-Process', 'Get-PSDrive', 'Get-PSProvider', 'Get-PSSnapin',
  67. 'Get-Service', 'Get-TraceSource', 'Get-UICulture', 'Get-Unique', 'Get-Variable',
  68. 'Get-WmiObject', 'Group-Object', 'Import-Alias', 'Import-Clixml', 'Import-Csv',
  69. 'Invoke-Expression', 'Invoke-History', 'Invoke-Item', 'Join-Path', 'Measure-Command',
  70. 'Measure-Object', 'Move-Item', 'Move-ItemProperty', 'New-Alias', 'New-Item',
  71. 'New-ItemProperty', 'New-Object', 'New-PSDrive', 'New-Service', 'New-TimeSpan',
  72. 'New-Variable', 'Out-Default', 'Out-File', 'Out-Host', 'Out-Null', 'Out-Printer',
  73. 'Out-String', 'Pop-Location', 'Push-Location', 'Read-Host', 'Remove-Item',
  74. 'Remove-ItemProperty', 'Remove-PSDrive', 'Remove-PSSnapin', 'Remove-Variable', 'Rename-Item',
  75. 'Rename-ItemProperty', 'Resolve-Path', 'Restart-Service', 'Resume-Service', 'Select-Object',
  76. 'Select-String', 'Set-Acl', 'Set-Alias', 'Set-AuthenticodeSignature', 'Set-Content',
  77. 'Set-Date', 'Set-ExecutionPolicy', 'Set-Item', 'Set-ItemProperty', 'Set-Location',
  78. 'Set-PSDebug', 'Set-Service', 'Set-TraceSource', 'Set-Variable', 'Sort-Object', 'Split-Path',
  79. 'Start-Service', 'Start-Sleep', 'Start-Transcript', 'Stop-Process', 'Stop-Service',
  80. 'Stop-Transcript', 'Suspend-Service', 'Tee-Object', 'Test-Path', 'Trace-Command',
  81. 'Update-FormatData', 'Update-TypeData', 'Where-Object', 'Write-Debug', 'Write-Error',
  82. 'Write-Host', 'Write-Output', 'Write-Progress', 'Write-Verbose', 'Write-Warning'
  83. ),
  84. 2 => array(
  85. // Aliases
  86. 'ac', 'asnp', 'clc', 'cli', 'clp', 'clv', 'cpi', 'cpp', 'cvpa', 'diff', 'epal', 'epcsv', 'fc',
  87. 'fl', 'ft', 'fw', 'gal', 'gc', 'gci', 'gcm', 'gdr', 'ghy', 'gi', 'gl', 'gm',
  88. 'gp', 'gps', 'group', 'gsv', 'gsnp', 'gu', 'gv', 'gwmi', 'iex', 'ihy', 'ii', 'ipal', 'ipcsv',
  89. 'mi', 'mp', 'nal', 'ndr', 'ni', 'nv', 'oh', 'rdr', 'ri', 'rni', 'rnp', 'rp', 'rsnp', 'rv',
  90. 'rvpa', 'sal', 'sasv', 'sc', 'select', 'si', 'sl', 'sleep', 'sort', 'sp', 'spps', 'spsv', 'sv',
  91. 'tee', 'write', 'cat', 'cd', 'clear', 'cp', 'h', 'history', 'kill', 'lp', 'ls',
  92. 'mount', 'mv', 'popd', 'ps', 'pushd', 'pwd', 'r', 'rm', 'rmdir', 'echo', 'cls', 'chdir',
  93. 'copy', 'del', 'dir', 'erase', 'move', 'rd', 'ren', 'set', 'type'
  94. ),
  95. 3 => array(
  96. // Reserved words
  97. 'break', 'continue', 'do', 'for', 'foreach', 'while', 'if', 'switch', 'until', 'where',
  98. 'function', 'filter', 'else', 'elseif', 'in', 'return', 'param', 'throw', 'trap'
  99. ),
  100. 4 => array(
  101. // Operators
  102. '-eq', '-ne', '-gt', '-ge', '-lt', '-le', '-ieq', '-ine', '-igt', '-ige', '-ilt', '-ile',
  103. '-ceq', '-cne', '-cgt', '-cge', '-clt', '-cle', '-like', '-notlike', '-match', '-notmatch',
  104. '-ilike', '-inotlike', '-imatch', '-inotmatch', '-clike', '-cnotlike', '-cmatch', '-cnotmatch',
  105. '-contains', '-notcontains', '-icontains', '-inotcontains', '-ccontains', '-cnotcontains',
  106. '-isnot', '-is', '-as', '-replace', '-ireplace', '-creplace', '-and', '-or', '-band', '-bor',
  107. '-not', '-bnot', '-f', '-casesensitive', '-exact', '-file', '-regex', '-wildcard'
  108. ),
  109. 5 => array(
  110. // Options
  111. '-Year', '-Wrap', '-Word', '-Width', '-WhatIf', '-Wait', '-View', '-Verbose', '-Verb',
  112. '-Variable', '-ValueOnly', '-Value', '-Unique', '-UFormat', '-TypeName', '-Trace', '-TotalCount',
  113. '-Title', '-TimestampServer', '-TargetObject', '-Syntax', '-SyncWindow', '-Sum', '-String',
  114. '-Strict', '-Stream', '-Step', '-Status', '-Static', '-StartupType', '-Start', '-StackName',
  115. '-Stack', '-SourceId', '-SimpleMatch', '-ShowError', '-Separator', '-SecureString', '-SecureKey',
  116. '-SecondValue', '-SecondsRemaining', '-Seconds', '-Second', '-Scope', '-Root', '-Role',
  117. '-Resolve', '-RemoveListener', '-RemoveFileListener', '-Registered', '-ReferenceObject',
  118. '-Recurse', '-RecommendedAction', '-ReadCount', '-Quiet', '-Query', '-Qualifier', '-PSSnapin',
  119. '-PSProvider', '-PSHost', '-PSDrive', '-PropertyType', '-Property', '-Prompt', '-Process',
  120. '-PrependPath', '-PercentComplete', '-Pattern', '-PathType', '-Path', '-PassThru', '-ParentId',
  121. '-Parent', '-Parameter', '-Paging', '-OutVariable', '-OutBuffer', '-Option', '-OnType', '-Off',
  122. '-Object', '-Noun', '-NoTypeInformation', '-NoQualifier', '-NoNewline', '-NoElement',
  123. '-NoClobber', '-NewName', '-Newest', '-Namespace', '-Name', '-Month', '-Minutes', '-Minute',
  124. '-Minimum', '-Milliseconds', '-Message', '-MemberType', '-Maximum', '-LogName', '-LiteralPath',
  125. '-LiteralName', '-ListenerOption', '-List', '-Line', '-Leaf', '-Last', '-Key', '-ItemType',
  126. '-IsValid', '-IsAbsolute', '-InputObject', '-IncludeEqual', '-IncludeChain', '-Include',
  127. '-IgnoreWhiteSpace', '-Id', '-Hours', '-Hour', '-HideTableHeaders', '-Head', '-GroupBy',
  128. '-Functionality', '-Full', '-Format', '-ForegroundColor', '-Force', '-First', '-FilterScript',
  129. '-Filter', '-FilePath', '-Expression', '-ExpandProperty', '-Expand', '-ExecutionPolicy',
  130. '-ExcludeProperty', '-ExcludeDifferent', '-Exclude', '-Exception', '-Examples', '-ErrorVariable',
  131. '-ErrorRecord', '-ErrorId', '-ErrorAction', '-End', '-Encoding', '-DisplayName', '-DisplayHint',
  132. '-DisplayError', '-DifferenceObject', '-Detailed', '-Destination', '-Description', '-Descending',
  133. '-Depth', '-DependsOn', '-Delimiter', '-Debugger', '-Debug', '-Days', '-Day', '-Date',
  134. '-CurrentOperation', '-Culture', '-Credential', '-Count', '-Container', '-Confirm',
  135. '-ComputerName', '-Component', '-Completed', '-ComObject', '-CommandType', '-Command',
  136. '-Column', '-Class', '-ChildPath', '-Character', '-Certificate', '-CategoryTargetType',
  137. '-CategoryTargetName', '-CategoryReason', '-CategoryActivity', '-Category', '-CaseSensitive',
  138. '-Body', '-BinaryPathName', '-Begin', '-BackgroundColor', '-Average', '-AutoSize', '-Audit',
  139. '-AsString', '-AsSecureString', '-AsPlainText', '-As', '-ArgumentList', '-AppendPath', '-Append',
  140. '-Adjust', '-Activity', '-AclObject'
  141. ),
  142. 6 => array(
  143. '_','args','DebugPreference','Error','ErrorActionPreference',
  144. 'foreach','Home','Host','Input','LASTEXITCODE','MaximumAliasCount',
  145. 'MaximumDriveCount','MaximumFunctionCount','MaximumHistoryCount',
  146. 'MaximumVariableCount','OFS','PsHome',
  147. 'ReportErrorShowExceptionClass','ReportErrorShowInnerException',
  148. 'ReportErrorShowSource','ReportErrorShowStackTrace',
  149. 'ShouldProcessPreference','ShouldProcessReturnPreference',
  150. 'StackTrace','VerbosePreference','WarningPreference','PWD'
  151. )
  152. ),
  153. 'SYMBOLS' => array(
  154. '(', ')', '[', ']', '{', '}', '=', '<', '>', '@', '|', '&', ',', '?',
  155. '+=', '-=', '*=', '/=', '%=', '*', '/', '%', '!', '+', '-', '++', '--'
  156. ),
  157. 'CASE_SENSITIVE' => array(
  158. GESHI_COMMENTS => false,
  159. 1 => false,
  160. 2 => false,
  161. 3 => false,
  162. 4 => false,
  163. 5 => false,
  164. 6 => true
  165. ),
  166. 'STYLES' => array(
  167. 'KEYWORDS' => array(
  168. 1 => 'color: #008080; font-weight: bold;',
  169. 2 => 'color: #008080; font-weight: bold;',
  170. 3 => 'color: #0000FF;',
  171. 4 => 'color: #FF0000;',
  172. 5 => 'color: #008080; font-style: italic;',
  173. 6 => 'color: #000080;'
  174. ),
  175. 'COMMENTS' => array(
  176. 1 => 'color: #008000;',
  177. 'MULTI' => 'color: #008000;'
  178. ),
  179. 'ESCAPE_CHAR' => array(
  180. 0 => 'color: #008080; font-weight: bold;'
  181. ),
  182. 'BRACKETS' => array(
  183. 0 => 'color: #000000;'
  184. ),
  185. 'STRINGS' => array(
  186. 0 => 'color: #800000;'
  187. ),
  188. 'NUMBERS' => array(
  189. 0 => 'color: #804000;'
  190. ),
  191. 'METHODS' => array(
  192. 0 => 'color: pink;'
  193. ),
  194. 'SYMBOLS' => array(
  195. 0 => 'color: pink;'
  196. ),
  197. 'REGEXPS' => array(
  198. 0 => 'color: #800080;',
  199. 3 => 'color: #008080;',
  200. 4 => 'color: #008080;',
  201. 5 => 'color: #800000;',
  202. 6 => 'color: #000080;'
  203. ),
  204. 'SCRIPT' => array(
  205. )
  206. ),
  207. 'URLS' => array(
  208. 1 => '',
  209. 2 => '',
  210. 3 => '',
  211. 4 => '',
  212. 5 => '',
  213. 6 => 'about:blank',
  214. ),
  215. 'OOLANG' => false,
  216. 'OBJECT_SPLITTERS' => array(
  217. ),
  218. 'REGEXPS' => array(
  219. // special after pipe
  220. 3 => array(
  221. GESHI_SEARCH => '(\[)(int|long|string|char|bool|byte|double|decimal|float|single|regex|array|xml|scriptblock|switch|hashtable|type|ref|psobject|wmi|wmisearcher|wmiclass|object)((\[.*\])?\])',
  222. GESHI_REPLACE => '\2',
  223. GESHI_MODIFIERS => 'si',
  224. GESHI_BEFORE => '\1',
  225. GESHI_AFTER => '\3'
  226. ),
  227. // Classes
  228. 4 => array(
  229. GESHI_SEARCH => '(\[)(System\.Reflection\.Assembly|System\.Net\.CredentialCache|Microsoft\.SharePoint\.SPFileLevel|Microsoft\.SharePoint\.Publishing\.PublishingWeb|Microsoft\.SharePoint\.Publishing|Microsoft\.SharePoint\.SPWeb)(\])',
  230. GESHI_REPLACE => '\2',
  231. GESHI_MODIFIERS => 'i',
  232. GESHI_BEFORE => '\1',
  233. GESHI_AFTER => '\3'
  234. ),
  235. // Members
  236. // There's about a hundred million of these, add the ones you need as you need them
  237. 5 => array (
  238. GESHI_SEARCH => '(::)(ReflectionOnlyLoadFrom|ReflectionOnlyLoad|ReferenceEquals|LoadWithPartialName|LoadFrom|LoadFile|Load|GetExecutingAssembly|GetEntryAssembly|GetCallingAssembly|GetAssembly|Equals|DefaultNetworkCredentials|DefaultCredentials|CreateQualifiedName|Checkout|Draft|Published|IsPublishingWeb)',
  239. GESHI_REPLACE => '\2',
  240. GESHI_MODIFIERS => '',
  241. GESHI_BEFORE => '\1',
  242. GESHI_AFTER => ''
  243. ),
  244. // Special variables
  245. 6 => array(
  246. GESHI_SEARCH => '(\$)(\$[_\^]?|\?)(?!\w)',
  247. GESHI_REPLACE => '\1\2',
  248. GESHI_MODIFIERS => '',
  249. GESHI_BEFORE => '',
  250. GESHI_AFTER => ''
  251. ),
  252. // variables
  253. //BenBE: Please note that changes here and in Keyword group 6 have to be synchronized in order to work properly.
  254. //This Regexp must only match, if keyword group 6 doesn't. If this assumption fails
  255. //Highlighting of the keywords will be incomplete or incorrect!
  256. 0 => "(?<!\\\$|>)[\\\$](\w+)(?=[^|\w])",
  257. ),
  258. 'STRICT_MODE_APPLIES' => GESHI_NEVER,
  259. 'SCRIPT_DELIMITERS' => array(
  260. ),
  261. 'HIGHLIGHT_STRICT_BLOCK' => array(
  262. ),
  263. 'PARSER_CONTROL' => array(
  264. 'KEYWORDS' => array(
  265. 4 => array(
  266. 'DISALLOWED_AFTER' => '(?![a-zA-Z])',
  267. 'DISALLOWED_BEFORE' => ''
  268. ),
  269. 6 => array(
  270. 'DISALLOWED_BEFORE' => '(?<!\$>)\$'
  271. )
  272. )
  273. )
  274. );
  275. ?>