1Description="Microsoft PowerShell"
2
3Categories = {"source", "script", "shell"}
4
5Identifiers=[[ [a-zA-Z_][\w\-]* ]]
6
7Keywords={
8  { Id=1,
9    List={"add-content", "add-history", "add-member", "add-pssnapin",
10        "clear-content", "clear-item", "clear-itemproperty", "clear-variable",
11        "compare-object", "convertfrom-securestring",
12        "convert-path", "convertto-html", "convertto-securestring", "copy-item",
13        "copy-itemproperty", "export-alias", "export-clixml", "export-console",
14        "export-csv", "foreach-object", "format-custom",
15        "format-list", "format-table", "format-wide", "get-acl", "get-alias",
16        "get-authenticodesignature", "get-childitem", "get-command", "get-content",
17        "get-credential", "get-culture", "get-date",
18        "get-eventlog", "get-executionpolicy", "get-help", "get-history",
19        "get-host", "get-item", "get-itemproperty", "get-location", "get-member",
20        "get-pfxcertificate", "get-process", "get-psdrive",
21        "get-psprovider", "get-pssnapin", "get-service", "get-tracesource",
22        "get-uiculture", "get-unique", "get-variable", "get-wmiobject", "group-object",
23        "import-alias", "import-clixml", "import-csv",
24        "invoke-expression", "invoke-history", "invoke-item", "join-path",
25        "measure-command", "measure-object", "move-item", "move-itemproperty",
26        "new-alias", "new-item", "new-itemproperty", "new-object", "write-host",
27        "new-psdrive", "new-service", "new-timespan", "new-variable", "out-default",
28        "out-file", "out-host", "out-null", "out-printer", "out-string", "pop-location",
29        "push-location", "read-host",
30        "remove-item", "remove-itemproperty", "remove-psdrive", "remove-pssnapin",
31        "remove-variable", "rename-item", "rename-itemproperty", "resolve-path",
32        "restart-service", "resume-service", "select-object",
33        "select-string", "set-acl", "set-alias", "set-authenticodesignature",
34        "set-content", "set-date", "set-executionpolicy", "set-item",
35        "set-itemproperty", "set-location", "set-psdebug", "set-service",
36        "set-tracesource", "set-variable", "sort-object", "split-path",
37        "start-service", "start-sleep", "start-transcript", "stop-process",
38        "stop-service", "stop-transcript", "suspend-service", "tee-object",
39        "test-path", "trace-command", "update-formatdata", "update-typedata",
40        "where-object", "write-debug",
41        "write-error", "write-host", "write-output", "write-progress",
42        "write-verbose", "write-warning", "switch", "function", "if", "throw", "else",
43        "while", "break", "in", "return", "try", "catch", "for"},
44  },
45  { Id=2,
46    List={"ac", "asnp", "clc", "cli", "clp", "clv", "cpi", "cpp", "cvpa",
47        "diff", "epal", "epcsv", "fc", "fl", "foreach", "%", "ft", "fw", "gal", "gc",
48        "gci", "gcm", "gdr", "ghy", "gi", "gl", "gm", "gp",
49        "gps", "group", "gsv", "gsnp", "gu", "gv", "gwmi", "iex", "ihy", "ii",
50        "ipal", "ipcsv", "mi", "mp", "nal", "ndr", "ni", "nv", "oh", "rdr", "ri", "rni",
51        "rnp", "rp", "rsnp", "rv", "rvpa", "sal", "sasv",
52        "sc", "select", "si", "sl", "sleep", "sort", "sp", "spps", "spsv", "sv",
53        "tee", "where", "write", "cat", "cd", "clear", "cp", "h", "history",
54        "kill", "lp", "ls", "mount", "mv", "popd", "ps", "pushd",
55        "pwd", "r", "rm", "rmdir", "echo", "cls", "chdir", "copy", "del", "dir",
56        "erase", "move", "rd", "ren", "set", "type"},
57  },
58  { Id=3,
59    Regex=[[Win32_\w+]],
60  },
61  { Id=4,
62    Regex=[[\$\w+]],
63  },
64}
65
66Strings={
67  Delimiter=[["|']],
68  Escape=[[ `\d{3}|`x\d{2}|^[ntvbrfa`\?'"] ]],
69    Interpolation=[[ \$\w+|\$\(.+?\) ]],
70}
71
72IgnoreCase=true
73
74Comments={
75  { Block=false,
76    Delimiter= { [[#]] },
77  },
78}
79
80Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\.|\:|\&|<|>|\!|\=|\/|\*|\%|\+|\-|\~|\?|\||\.]]
81
82EnableIndentation=false
83
84-- fix recognition of $
85function OnStateChange(oldState, newState, token)
86
87  if  (string.sub(token,1,1) =="$") and oldState==HL_STRING and newState==HL_KEYWORD then
88    return HL_INTERPOLATION
89  end
90
91end
92