-
Notifications
You must be signed in to change notification settings - Fork 662
Expand file tree
/
Copy pathpowershell.lsh
More file actions
86 lines (84 loc) · 2.3 KB
/
powershell.lsh
File metadata and controls
86 lines (84 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#[display_name = "PowerShell"]
#[path = "**/*.ps1"]
#[path = "**/*.psd1"]
#[path = "**/*.psm1"]
pub fn powershell() {
until /$/ {
yield other;
if /#.*/ {
yield comment;
} else if /<#/ {
loop {
yield comment;
if /#>/ { yield comment; break; }
await input;
}
} else if /'/ {
loop {
yield string;
if /'/ { yield string; break; }
await input;
}
} else if /@'\s*$/ {
yield string;
loop {
if /.*/ {}
yield string;
await input;
if /'@/ {
yield string;
break;
}
}
} else if /@"\s*$/ {
yield string;
loop {
if /.*/ {}
yield string;
await input;
if /"@/ {
yield string;
break;
}
}
} else if /"/ {
loop {
yield string;
if /`./ {}
else if /"/ { yield string; break; }
await input;
}
} else if /(?i:function|param|class|enum|cmdletbinding|static)/ {
if /\w+/ {
yield other;
} else {
yield keyword.other;
}
} else if /(?i:elseif|else|if|for(each)?|switch|default|throw|try|catch|finally|return)/ {
if /\w+/ {
yield other;
} else {
yield keyword.control;
}
} else if /-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/ {
if /[\w\-]+/ {
yield method;
} else {
yield constant.numeric;
}
} else if /\$false|\$true|\$null/ {
if /\w+/ {
yield variable;
} else {
yield constant.language;
}
} else if /[$@][\w\d?:]+/ {
yield variable;
} else if /[\w\d?:]+-[\w\d?:-]*/ {
yield method;
} else if /[\w\d?:]+/ {
// Gobble any other tokens that should not be highlighted
}
yield other;
}
}