Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pygments/lexers/automation.py: 100%
20 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-01 06:54 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-01 06:54 +0000
1"""
2 pygments.lexers.automation
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~
5 Lexers for automation scripting languages.
7 :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
8 :license: BSD, see LICENSE for details.
9"""
11from pygments.lexer import RegexLexer, include, bygroups, combined
12from pygments.token import Text, Comment, Operator, Name, String, \
13 Number, Punctuation, Generic
15__all__ = ['AutohotkeyLexer', 'AutoItLexer']
18class AutohotkeyLexer(RegexLexer):
19 """
20 For autohotkey source code.
22 .. versionadded:: 1.4
23 """
24 name = 'autohotkey'
25 url = 'http://www.autohotkey.com/'
26 aliases = ['autohotkey', 'ahk']
27 filenames = ['*.ahk', '*.ahkl']
28 mimetypes = ['text/x-autohotkey']
30 tokens = {
31 'root': [
32 (r'^(\s*)(/\*)', bygroups(Text, Comment.Multiline), 'incomment'),
33 (r'^(\s*)(\()', bygroups(Text, Generic), 'incontinuation'),
34 (r'\s+;.*?$', Comment.Single),
35 (r'^;.*?$', Comment.Single),
36 (r'[]{}(),;[]', Punctuation),
37 (r'(in|is|and|or|not)\b', Operator.Word),
38 (r'\%[a-zA-Z_#@$][\w#@$]*\%', Name.Variable),
39 (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator),
40 include('commands'),
41 include('labels'),
42 include('builtInFunctions'),
43 include('builtInVariables'),
44 (r'"', String, combined('stringescape', 'dqs')),
45 include('numbers'),
46 (r'[a-zA-Z_#@$][\w#@$]*', Name),
47 (r'\\|\'', Text),
48 (r'\`([,%`abfnrtv\-+;])', String.Escape),
49 include('garbage'),
50 ],
51 'incomment': [
52 (r'^\s*\*/', Comment.Multiline, '#pop'),
53 (r'[^*]+', Comment.Multiline),
54 (r'\*', Comment.Multiline)
55 ],
56 'incontinuation': [
57 (r'^\s*\)', Generic, '#pop'),
58 (r'[^)]', Generic),
59 (r'[)]', Generic),
60 ],
61 'commands': [
62 (r'(?i)^(\s*)(global|local|static|'
63 r'#AllowSameLineComments|#ClipboardTimeout|#CommentFlag|'
64 r'#ErrorStdOut|#EscapeChar|#HotkeyInterval|#HotkeyModifierTimeout|'
65 r'#Hotstring|#IfWinActive|#IfWinExist|#IfWinNotActive|'
66 r'#IfWinNotExist|#IncludeAgain|#Include|#InstallKeybdHook|'
67 r'#InstallMouseHook|#KeyHistory|#LTrim|#MaxHotkeysPerInterval|'
68 r'#MaxMem|#MaxThreads|#MaxThreadsBuffer|#MaxThreadsPerHotkey|'
69 r'#NoEnv|#NoTrayIcon|#Persistent|#SingleInstance|#UseHook|'
70 r'#WinActivateForce|AutoTrim|BlockInput|Break|Click|ClipWait|'
71 r'Continue|Control|ControlClick|ControlFocus|ControlGetFocus|'
72 r'ControlGetPos|ControlGetText|ControlGet|ControlMove|ControlSend|'
73 r'ControlSendRaw|ControlSetText|CoordMode|Critical|'
74 r'DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|'
75 r'DriveSpaceFree|Edit|Else|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|'
76 r'EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|'
77 r'FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|'
78 r'FileDelete|FileGetAttrib|FileGetShortcut|FileGetSize|'
79 r'FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|'
80 r'FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|'
81 r'FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|'
82 r'FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|'
83 r'GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|'
84 r'GuiControlGet|Hotkey|IfEqual|IfExist|IfGreaterOrEqual|IfGreater|'
85 r'IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|'
86 r'IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|'
87 r'IfWinNotExist|If |ImageSearch|IniDelete|IniRead|IniWrite|'
88 r'InputBox|Input|KeyHistory|KeyWait|ListHotkeys|ListLines|'
89 r'ListVars|Loop|Menu|MouseClickDrag|MouseClick|MouseGetPos|'
90 r'MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|'
91 r'PixelSearch|PostMessage|Process|Progress|Random|RegDelete|'
92 r'RegRead|RegWrite|Reload|Repeat|Return|RunAs|RunWait|Run|'
93 r'SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|Send|'
94 r'SetBatchLines|SetCapslockState|SetControlDelay|'
95 r'SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|'
96 r'SetMouseDelay|SetNumlockState|SetScrollLockState|'
97 r'SetStoreCapslockMode|SetTimer|SetTitleMatchMode|'
98 r'SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|'
99 r'SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|'
100 r'SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|'
101 r'SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|'
102 r'StringGetPos|StringLeft|StringLen|StringLower|StringMid|'
103 r'StringReplace|StringRight|StringSplit|StringTrimLeft|'
104 r'StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|'
105 r'Transform|TrayTip|URLDownloadToFile|While|WinActivate|'
106 r'WinActivateBottom|WinClose|WinGetActiveStats|WinGetActiveTitle|'
107 r'WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinGet|WinHide|'
108 r'WinKill|WinMaximize|WinMenuSelectItem|WinMinimizeAllUndo|'
109 r'WinMinimizeAll|WinMinimize|WinMove|WinRestore|WinSetTitle|'
110 r'WinSet|WinShow|WinWaitActive|WinWaitClose|WinWaitNotActive|'
111 r'WinWait)\b', bygroups(Text, Name.Builtin)),
112 ],
113 'builtInFunctions': [
114 (r'(?i)(Abs|ACos|Asc|ASin|ATan|Ceil|Chr|Cos|DllCall|Exp|FileExist|'
115 r'Floor|GetKeyState|IL_Add|IL_Create|IL_Destroy|InStr|IsFunc|'
116 r'IsLabel|Ln|Log|LV_Add|LV_Delete|LV_DeleteCol|LV_GetCount|'
117 r'LV_GetNext|LV_GetText|LV_Insert|LV_InsertCol|LV_Modify|'
118 r'LV_ModifyCol|LV_SetImageList|Mod|NumGet|NumPut|OnMessage|'
119 r'RegExMatch|RegExReplace|RegisterCallback|Round|SB_SetIcon|'
120 r'SB_SetParts|SB_SetText|Sin|Sqrt|StrLen|SubStr|Tan|TV_Add|'
121 r'TV_Delete|TV_GetChild|TV_GetCount|TV_GetNext|TV_Get|'
122 r'TV_GetParent|TV_GetPrev|TV_GetSelection|TV_GetText|TV_Modify|'
123 r'VarSetCapacity|WinActive|WinExist|Object|ComObjActive|'
124 r'ComObjArray|ComObjEnwrap|ComObjUnwrap|ComObjParameter|'
125 r'ComObjType|ComObjConnect|ComObjCreate|ComObjGet|ComObjError|'
126 r'ComObjValue|Insert|MinIndex|MaxIndex|Remove|SetCapacity|'
127 r'GetCapacity|GetAddress|_NewEnum|FileOpen|Read|Write|ReadLine|'
128 r'WriteLine|ReadNumType|WriteNumType|RawRead|RawWrite|Seek|Tell|'
129 r'Close|Next|IsObject|StrPut|StrGet|Trim|LTrim|RTrim)\b',
130 Name.Function),
131 ],
132 'builtInVariables': [
133 (r'(?i)(A_AhkPath|A_AhkVersion|A_AppData|A_AppDataCommon|'
134 r'A_AutoTrim|A_BatchLines|A_CaretX|A_CaretY|A_ComputerName|'
135 r'A_ControlDelay|A_Cursor|A_DDDD|A_DDD|A_DD|A_DefaultMouseSpeed|'
136 r'A_Desktop|A_DesktopCommon|A_DetectHiddenText|'
137 r'A_DetectHiddenWindows|A_EndChar|A_EventInfo|A_ExitReason|'
138 r'A_FormatFloat|A_FormatInteger|A_Gui|A_GuiEvent|A_GuiControl|'
139 r'A_GuiControlEvent|A_GuiHeight|A_GuiWidth|A_GuiX|A_GuiY|A_Hour|'
140 r'A_IconFile|A_IconHidden|A_IconNumber|A_IconTip|A_Index|'
141 r'A_IPAddress1|A_IPAddress2|A_IPAddress3|A_IPAddress4|A_ISAdmin|'
142 r'A_IsCompiled|A_IsCritical|A_IsPaused|A_IsSuspended|A_KeyDelay|'
143 r'A_Language|A_LastError|A_LineFile|A_LineNumber|A_LoopField|'
144 r'A_LoopFileAttrib|A_LoopFileDir|A_LoopFileExt|A_LoopFileFullPath|'
145 r'A_LoopFileLongPath|A_LoopFileName|A_LoopFileShortName|'
146 r'A_LoopFileShortPath|A_LoopFileSize|A_LoopFileSizeKB|'
147 r'A_LoopFileSizeMB|A_LoopFileTimeAccessed|A_LoopFileTimeCreated|'
148 r'A_LoopFileTimeModified|A_LoopReadLine|A_LoopRegKey|'
149 r'A_LoopRegName|A_LoopRegSubkey|A_LoopRegTimeModified|'
150 r'A_LoopRegType|A_MDAY|A_Min|A_MM|A_MMM|A_MMMM|A_Mon|A_MouseDelay|'
151 r'A_MSec|A_MyDocuments|A_Now|A_NowUTC|A_NumBatchLines|A_OSType|'
152 r'A_OSVersion|A_PriorHotkey|A_ProgramFiles|A_Programs|'
153 r'A_ProgramsCommon|A_ScreenHeight|A_ScreenWidth|A_ScriptDir|'
154 r'A_ScriptFullPath|A_ScriptName|A_Sec|A_Space|A_StartMenu|'
155 r'A_StartMenuCommon|A_Startup|A_StartupCommon|A_StringCaseSense|'
156 r'A_Tab|A_Temp|A_ThisFunc|A_ThisHotkey|A_ThisLabel|A_ThisMenu|'
157 r'A_ThisMenuItem|A_ThisMenuItemPos|A_TickCount|A_TimeIdle|'
158 r'A_TimeIdlePhysical|A_TimeSincePriorHotkey|A_TimeSinceThisHotkey|'
159 r'A_TitleMatchMode|A_TitleMatchModeSpeed|A_UserName|A_WDay|'
160 r'A_WinDelay|A_WinDir|A_WorkingDir|A_YDay|A_YEAR|A_YWeek|A_YYYY|'
161 r'Clipboard|ClipboardAll|ComSpec|ErrorLevel|ProgramFiles|True|'
162 r'False|A_IsUnicode|A_FileEncoding|A_OSVersion|A_PtrSize)\b',
163 Name.Variable),
164 ],
165 'labels': [
166 # hotkeys and labels
167 # technically, hotkey names are limited to named keys and buttons
168 (r'(^\s*)([^:\s("]+?:{1,2})', bygroups(Text, Name.Label)),
169 (r'(^\s*)(::[^:\s]+?::)', bygroups(Text, Name.Label)),
170 ],
171 'numbers': [
172 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
173 (r'\d+[eE][+-]?[0-9]+', Number.Float),
174 (r'0\d+', Number.Oct),
175 (r'0[xX][a-fA-F0-9]+', Number.Hex),
176 (r'\d+L', Number.Integer.Long),
177 (r'\d+', Number.Integer)
178 ],
179 'stringescape': [
180 (r'\"\"|\`([,%`abfnrtv])', String.Escape),
181 ],
182 'strings': [
183 (r'[^"\n]+', String),
184 ],
185 'dqs': [
186 (r'"', String, '#pop'),
187 include('strings')
188 ],
189 'garbage': [
190 (r'[^\S\n]', Text),
191 # (r'.', Text), # no cheating
192 ],
193 }
196class AutoItLexer(RegexLexer):
197 """
198 For AutoIt files.
200 AutoIt is a freeware BASIC-like scripting language
201 designed for automating the Windows GUI and general scripting
203 .. versionadded:: 1.6
204 """
205 name = 'AutoIt'
206 url = 'http://www.autoitscript.com/site/autoit/'
207 aliases = ['autoit']
208 filenames = ['*.au3']
209 mimetypes = ['text/x-autoit']
211 # Keywords, functions, macros from au3.keywords.properties
212 # which can be found in AutoIt installed directory, e.g.
213 # c:\Program Files (x86)\AutoIt3\SciTE\au3.keywords.properties
215 keywords = """\
216 #include-once #include #endregion #forcedef #forceref #region
217 and byref case continueloop dim do else elseif endfunc endif
218 endselect exit exitloop for func global
219 if local next not or return select step
220 then to until wend while exit""".split()
222 functions = """\
223 abs acos adlibregister adlibunregister asc ascw asin assign atan
224 autoitsetoption autoitwingettitle autoitwinsettitle beep binary binarylen
225 binarymid binarytostring bitand bitnot bitor bitrotate bitshift bitxor
226 blockinput break call cdtray ceiling chr chrw clipget clipput consoleread
227 consolewrite consolewriteerror controlclick controlcommand controldisable
228 controlenable controlfocus controlgetfocus controlgethandle controlgetpos
229 controlgettext controlhide controllistview controlmove controlsend
230 controlsettext controlshow controltreeview cos dec dircopy dircreate
231 dirgetsize dirmove dirremove dllcall dllcalladdress dllcallbackfree
232 dllcallbackgetptr dllcallbackregister dllclose dllopen dllstructcreate
233 dllstructgetdata dllstructgetptr dllstructgetsize dllstructsetdata
234 drivegetdrive drivegetfilesystem drivegetlabel drivegetserial drivegettype
235 drivemapadd drivemapdel drivemapget drivesetlabel drivespacefree
236 drivespacetotal drivestatus envget envset envupdate eval execute exp
237 filechangedir fileclose filecopy filecreatentfslink filecreateshortcut
238 filedelete fileexists filefindfirstfile filefindnextfile fileflush
239 filegetattrib filegetencoding filegetlongname filegetpos filegetshortcut
240 filegetshortname filegetsize filegettime filegetversion fileinstall filemove
241 fileopen fileopendialog fileread filereadline filerecycle filerecycleempty
242 filesavedialog fileselectfolder filesetattrib filesetpos filesettime
243 filewrite filewriteline floor ftpsetproxy guicreate guictrlcreateavi
244 guictrlcreatebutton guictrlcreatecheckbox guictrlcreatecombo
245 guictrlcreatecontextmenu guictrlcreatedate guictrlcreatedummy
246 guictrlcreateedit guictrlcreategraphic guictrlcreategroup guictrlcreateicon
247 guictrlcreateinput guictrlcreatelabel guictrlcreatelist
248 guictrlcreatelistview guictrlcreatelistviewitem guictrlcreatemenu
249 guictrlcreatemenuitem guictrlcreatemonthcal guictrlcreateobj
250 guictrlcreatepic guictrlcreateprogress guictrlcreateradio
251 guictrlcreateslider guictrlcreatetab guictrlcreatetabitem
252 guictrlcreatetreeview guictrlcreatetreeviewitem guictrlcreateupdown
253 guictrldelete guictrlgethandle guictrlgetstate guictrlread guictrlrecvmsg
254 guictrlregisterlistviewsort guictrlsendmsg guictrlsendtodummy
255 guictrlsetbkcolor guictrlsetcolor guictrlsetcursor guictrlsetdata
256 guictrlsetdefbkcolor guictrlsetdefcolor guictrlsetfont guictrlsetgraphic
257 guictrlsetimage guictrlsetlimit guictrlsetonevent guictrlsetpos
258 guictrlsetresizing guictrlsetstate guictrlsetstyle guictrlsettip guidelete
259 guigetcursorinfo guigetmsg guigetstyle guiregistermsg guisetaccelerators
260 guisetbkcolor guisetcoord guisetcursor guisetfont guisethelp guiseticon
261 guisetonevent guisetstate guisetstyle guistartgroup guiswitch hex hotkeyset
262 httpsetproxy httpsetuseragent hwnd inetclose inetget inetgetinfo inetgetsize
263 inetread inidelete iniread inireadsection inireadsectionnames
264 inirenamesection iniwrite iniwritesection inputbox int isadmin isarray
265 isbinary isbool isdeclared isdllstruct isfloat ishwnd isint iskeyword
266 isnumber isobj isptr isstring log memgetstats mod mouseclick mouseclickdrag
267 mousedown mousegetcursor mousegetpos mousemove mouseup mousewheel msgbox
268 number objcreate objcreateinterface objevent objevent objget objname
269 onautoitexitregister onautoitexitunregister opt ping pixelchecksum
270 pixelgetcolor pixelsearch pluginclose pluginopen processclose processexists
271 processgetstats processlist processsetpriority processwait processwaitclose
272 progressoff progresson progressset ptr random regdelete regenumkey
273 regenumval regread regwrite round run runas runaswait runwait send
274 sendkeepactive seterror setextended shellexecute shellexecutewait shutdown
275 sin sleep soundplay soundsetwavevolume splashimageon splashoff splashtexton
276 sqrt srandom statusbargettext stderrread stdinwrite stdioclose stdoutread
277 string stringaddcr stringcompare stringformat stringfromasciiarray
278 stringinstr stringisalnum stringisalpha stringisascii stringisdigit
279 stringisfloat stringisint stringislower stringisspace stringisupper
280 stringisxdigit stringleft stringlen stringlower stringmid stringregexp
281 stringregexpreplace stringreplace stringright stringsplit stringstripcr
282 stringstripws stringtoasciiarray stringtobinary stringtrimleft
283 stringtrimright stringupper tan tcpaccept tcpclosesocket tcpconnect
284 tcplisten tcpnametoip tcprecv tcpsend tcpshutdown tcpstartup timerdiff
285 timerinit tooltip traycreateitem traycreatemenu traygetmsg trayitemdelete
286 trayitemgethandle trayitemgetstate trayitemgettext trayitemsetonevent
287 trayitemsetstate trayitemsettext traysetclick trayseticon traysetonevent
288 traysetpauseicon traysetstate traysettooltip traytip ubound udpbind
289 udpclosesocket udpopen udprecv udpsend udpshutdown udpstartup vargettype
290 winactivate winactive winclose winexists winflash wingetcaretpos
291 wingetclasslist wingetclientsize wingethandle wingetpos wingetprocess
292 wingetstate wingettext wingettitle winkill winlist winmenuselectitem
293 winminimizeall winminimizeallundo winmove winsetontop winsetstate
294 winsettitle winsettrans winwait winwaitactive winwaitclose
295 winwaitnotactive""".split()
297 macros = """\
298 @appdatacommondir @appdatadir @autoitexe @autoitpid @autoitversion
299 @autoitx64 @com_eventobj @commonfilesdir @compiled @computername @comspec
300 @cpuarch @cr @crlf @desktopcommondir @desktopdepth @desktopdir
301 @desktopheight @desktoprefresh @desktopwidth @documentscommondir @error
302 @exitcode @exitmethod @extended @favoritescommondir @favoritesdir
303 @gui_ctrlhandle @gui_ctrlid @gui_dragfile @gui_dragid @gui_dropid
304 @gui_winhandle @homedrive @homepath @homeshare @hotkeypressed @hour
305 @ipaddress1 @ipaddress2 @ipaddress3 @ipaddress4 @kblayout @lf
306 @logondnsdomain @logondomain @logonserver @mday @min @mon @msec @muilang
307 @mydocumentsdir @numparams @osarch @osbuild @oslang @osservicepack @ostype
308 @osversion @programfilesdir @programscommondir @programsdir @scriptdir
309 @scriptfullpath @scriptlinenumber @scriptname @sec @startmenucommondir
310 @startmenudir @startupcommondir @startupdir @sw_disable @sw_enable @sw_hide
311 @sw_lock @sw_maximize @sw_minimize @sw_restore @sw_show @sw_showdefault
312 @sw_showmaximized @sw_showminimized @sw_showminnoactive @sw_showna
313 @sw_shownoactivate @sw_shownormal @sw_unlock @systemdir @tab @tempdir
314 @tray_id @trayiconflashing @trayiconvisible @username @userprofiledir @wday
315 @windowsdir @workingdir @yday @year""".split()
317 tokens = {
318 'root': [
319 (r';.*\n', Comment.Single),
320 (r'(#comments-start|#cs)(.|\n)*?(#comments-end|#ce)',
321 Comment.Multiline),
322 (r'[\[\]{}(),;]', Punctuation),
323 (r'(and|or|not)\b', Operator.Word),
324 (r'[$|@][a-zA-Z_]\w*', Name.Variable),
325 (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator),
326 include('commands'),
327 include('labels'),
328 include('builtInFunctions'),
329 include('builtInMarcros'),
330 (r'"', String, combined('stringescape', 'dqs')),
331 (r"'", String, 'sqs'),
332 include('numbers'),
333 (r'[a-zA-Z_#@$][\w#@$]*', Name),
334 (r'\\|\'', Text),
335 (r'\`([,%`abfnrtv\-+;])', String.Escape),
336 (r'_\n', Text), # Line continuation
337 include('garbage'),
338 ],
339 'commands': [
340 (r'(?i)(\s*)(%s)\b' % '|'.join(keywords),
341 bygroups(Text, Name.Builtin)),
342 ],
343 'builtInFunctions': [
344 (r'(?i)(%s)\b' % '|'.join(functions),
345 Name.Function),
346 ],
347 'builtInMarcros': [
348 (r'(?i)(%s)\b' % '|'.join(macros),
349 Name.Variable.Global),
350 ],
351 'labels': [
352 # sendkeys
353 (r'(^\s*)(\{\S+?\})', bygroups(Text, Name.Label)),
354 ],
355 'numbers': [
356 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
357 (r'\d+[eE][+-]?[0-9]+', Number.Float),
358 (r'0\d+', Number.Oct),
359 (r'0[xX][a-fA-F0-9]+', Number.Hex),
360 (r'\d+L', Number.Integer.Long),
361 (r'\d+', Number.Integer)
362 ],
363 'stringescape': [
364 (r'\"\"|\`([,%`abfnrtv])', String.Escape),
365 ],
366 'strings': [
367 (r'[^"\n]+', String),
368 ],
369 'dqs': [
370 (r'"', String, '#pop'),
371 include('strings')
372 ],
373 'sqs': [
374 (r'\'\'|\`([,%`abfnrtv])', String.Escape),
375 (r"'", String, '#pop'),
376 (r"[^'\n]+", String)
377 ],
378 'garbage': [
379 (r'[^\S\n]', Text),
380 ],
381 }