-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #771 from Golmote/prism-autoit
Add support for AutoIt. Fix #453
- Loading branch information
Showing
16 changed files
with
370 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Prism.languages.autoit = { | ||
"comment": [ | ||
/;.*/, | ||
{ | ||
// The multi-line comments delimiters can actually be commented out with ";" | ||
pattern: /(^\s*)#(?:comments-start|cs)[\s\S]*?^\s*#(?:comments-end|ce)/m, | ||
lookbehind: true | ||
} | ||
], | ||
"url": { | ||
pattern: /(^\s*#include\s+)(?:<[^\r\n>]+>|"[^\r\n"]+")/m, | ||
lookbehind: true | ||
}, | ||
"string": { | ||
pattern: /(["'])(?:\1\1|(?!\1)[^\r\n])*\1/, | ||
inside: { | ||
"variable": /([%$@])\w+\1/ | ||
} | ||
}, | ||
"directive": { | ||
pattern: /(^\s*)#\w+/m, | ||
lookbehind: true, | ||
alias: 'keyword' | ||
}, | ||
"function": /\b\w+(?=\()/, | ||
// Variables and macros | ||
"variable": /[$@]\w+/, | ||
"keyword": /\b(?:Case|Const|Continue(?:Case|Loop)|Default|Dim|Do|Else(?:If)?|End(?:Func|If|Select|Switch|With)|Enum|Exit(?:Loop)?|For|Func|Global|If|In|Local|Next|Null|ReDim|Select|Static|Step|Switch|Then|To|Until|Volatile|WEnd|While|With)\b/i, | ||
"number": /\b(?:0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/i, | ||
"boolean": /\b(?:True|False)\b/i, | ||
"operator": /<[=>]?|[-+*\/=&>]=?|[?^]|\b(?:And|Or|Not)\b/i, | ||
"punctuation": /[\[\]().,:]/ | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<h1>AutoIt</h1> | ||
<p>To use this language, use the class "language-autoit".</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code>; Single-line comment | ||
#comments-start | ||
Multi-line | ||
comment | ||
#comments-end | ||
#cs | ||
Multi-line | ||
comment | ||
#ce | ||
;#comments-start | ||
foo() | ||
;#comments-end</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>"foo'bar'baz" | ||
"foo""bar""baz" | ||
'foo"bar"baz' | ||
'foo''bar''baz'</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>2 | ||
4.566 | ||
1.5e3 | ||
0x4fff</code></pre> | ||
|
||
<h2>Booleans</h2> | ||
<pre><code>True | ||
False</code></pre> | ||
|
||
<h2>Keywords and variables</h2> | ||
<pre><code>; Display all the numbers for 1 to 10 but skip displaying 7. | ||
For $i = 1 To 10 | ||
If $i = 7 Then | ||
ContinueLoop ; Skip displaying the message box when $i is equal to 7. | ||
EndIf | ||
MsgBox($MB_SYSTEMMODAL, "", "The value of $i is: " & $i) | ||
Next</code></pre> | ||
|
||
<h2>Known failures</h2> | ||
<p>There are certain edge cases where Prism will fail. | ||
There are always such cases in every regex-based syntax highlighter. | ||
However, Prism dares to be open and honest about them. | ||
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug. | ||
</p> | ||
|
||
<h3>Comment-like substrings</h3> | ||
<pre><code>"This string ; is broken"</code></pre> | ||
|
||
<h3>Nested block comments</h3> | ||
<pre><code>#cs | ||
#cs | ||
foo() | ||
#ce | ||
#ce</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
True | ||
False | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["boolean", "True"], | ||
["boolean", "False"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for booleans. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
; | ||
; foo | ||
#comments-start | ||
foobar() | ||
#comments-end | ||
#cs | ||
foobar() | ||
#ce | ||
;#comments-start | ||
foobar() | ||
;#comments-end | ||
;#cs | ||
foobar() | ||
;#ce | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", ";"], | ||
["comment", "; foo"], | ||
["comment", "#comments-start\r\n\tfoobar()\r\n#comments-end"], | ||
["comment", "#cs\r\n\tfoobar()\r\n#ce"], | ||
["comment", ";#comments-start"], | ||
["function", "foobar"], ["punctuation", "("], ["punctuation", ")"], | ||
["comment", ";#comments-end"], | ||
["comment", ";#cs"], | ||
["function", "foobar"], ["punctuation", "("], ["punctuation", ")"], | ||
["comment", ";#ce"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#NoTrayIcon | ||
#OnAutoItStartRegister "Example" | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["directive", "#NoTrayIcon"], | ||
["directive", "#OnAutoItStartRegister"], ["string", ["\"Example\""]] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for directives. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
foo() | ||
foo_bar() | ||
foo_bar_42() | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "foo"], ["punctuation", "("], ["punctuation", ")"], | ||
["function", "foo_bar"], ["punctuation", "("], ["punctuation", ")"], | ||
["function", "foo_bar_42"], ["punctuation", "("], ["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
Case | ||
Const | ||
ContinueCase | ||
ContinueLoop | ||
Default | ||
Dim | ||
Do | ||
Else | ||
ElseIf | ||
EndFunc | ||
EndIf | ||
EndSelect | ||
EndSwitch | ||
EndWith | ||
Enum | ||
Exit | ||
ExitLoop | ||
For | ||
Func | ||
Global | ||
If | ||
In | ||
Local | ||
Next | ||
Null | ||
ReDim | ||
Select | ||
Static | ||
Step | ||
Switch | ||
Then | ||
To | ||
Until | ||
Volatile | ||
WEnd | ||
While | ||
With | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "Case"], | ||
["keyword", "Const"], | ||
["keyword", "ContinueCase"], | ||
["keyword", "ContinueLoop"], | ||
["keyword", "Default"], | ||
["keyword", "Dim"], | ||
["keyword", "Do"], | ||
["keyword", "Else"], | ||
["keyword", "ElseIf"], | ||
["keyword", "EndFunc"], | ||
["keyword", "EndIf"], | ||
["keyword", "EndSelect"], | ||
["keyword", "EndSwitch"], | ||
["keyword", "EndWith"], | ||
["keyword", "Enum"], | ||
["keyword", "Exit"], | ||
["keyword", "ExitLoop"], | ||
["keyword", "For"], | ||
["keyword", "Func"], | ||
["keyword", "Global"], | ||
["keyword", "If"], | ||
["keyword", "In"], | ||
["keyword", "Local"], | ||
["keyword", "Next"], | ||
["keyword", "Null"], | ||
["keyword", "ReDim"], | ||
["keyword", "Select"], | ||
["keyword", "Static"], | ||
["keyword", "Step"], | ||
["keyword", "Switch"], | ||
["keyword", "Then"], | ||
["keyword", "To"], | ||
["keyword", "Until"], | ||
["keyword", "Volatile"], | ||
["keyword", "WEnd"], | ||
["keyword", "While"], | ||
["keyword", "With"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for keywords. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
42 | ||
3.14159 | ||
4e8 | ||
3.5E-9 | ||
0.7e+12 | ||
0xBadFace | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["number", "42"], | ||
["number", "3.14159"], | ||
["number", "4e8"], | ||
["number", "3.5E-9"], | ||
["number", "0.7e+12"], | ||
["number", "0xBadFace"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for numbers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
< <= <> | ||
> >= | ||
+ += - -= | ||
* *= / /= | ||
& &= | ||
? ^ | ||
And Or Not | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["operator", "<"], ["operator", "<="], ["operator", "<>"], | ||
["operator", ">"], ["operator", ">="], | ||
["operator", "+"], ["operator", "+="], ["operator", "-"], ["operator", "-="], | ||
["operator", "*"], ["operator", "*="], ["operator", "/"], ["operator", "/="], | ||
["operator", "&"], ["operator", "&="], | ||
["operator", "?"], ["operator", "^"], | ||
["operator", "And"], ["operator", "Or"], ["operator", "Not"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for operators. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"" | ||
"foo""bar" | ||
"foo %foo% bar $bar$ baz @baz@" | ||
'' | ||
'foo''bar' | ||
'foo %foo% bar $bar$ baz @baz@' | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["string", ["\"\""]], | ||
["string", ["\"foo\"\"bar\""]], | ||
["string", [ | ||
"\"foo ", | ||
["variable", "%foo%"], | ||
" bar ", | ||
["variable", "$bar$"], | ||
" baz ", | ||
["variable", "@baz@"], | ||
"\"" | ||
]], | ||
["string", ["''"]], | ||
["string", ["'foo''bar'"]], | ||
["string", [ | ||
"'foo ", | ||
["variable", "%foo%"], | ||
" bar ", | ||
["variable", "$bar$"], | ||
" baz ", | ||
["variable", "@baz@"], | ||
"'" | ||
]] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for strings and interpolation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <foo.au3> | ||
#include "foo.au3" | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["directive", "#include"], | ||
["url", "<foo.au3>"], | ||
["directive", "#include"], | ||
["url", "\"foo.au3\""] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for files in includes. |
Oops, something went wrong.