|
1 # -*- coding: utf-8 -*- |
|
2 """ |
|
3 pygments.lexers.automation |
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
5 |
|
6 Lexers for automation scripting languages. |
|
7 |
|
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. |
|
9 :license: BSD, see LICENSE for details. |
|
10 """ |
|
11 |
|
12 from pygments.lexer import RegexLexer, include, bygroups, combined |
|
13 from pygments.token import Text, Comment, Operator, Name, String, \ |
|
14 Number, Punctuation, Generic |
|
15 |
|
16 __all__ = ['AutohotkeyLexer', 'AutoItLexer'] |
|
17 |
|
18 |
|
19 class AutohotkeyLexer(RegexLexer): |
|
20 """ |
|
21 For `autohotkey <http://www.autohotkey.com/>`_ source code. |
|
22 |
|
23 .. versionadded:: 1.4 |
|
24 """ |
|
25 name = 'autohotkey' |
|
26 aliases = ['ahk', 'autohotkey'] |
|
27 filenames = ['*.ahk', '*.ahkl'] |
|
28 mimetypes = ['text/x-autohotkey'] |
|
29 |
|
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 } |
|
194 |
|
195 |
|
196 class AutoItLexer(RegexLexer): |
|
197 """ |
|
198 For `AutoIt <http://www.autoitscript.com/site/autoit/>`_ files. |
|
199 |
|
200 AutoIt is a freeware BASIC-like scripting language |
|
201 designed for automating the Windows GUI and general scripting |
|
202 |
|
203 .. versionadded:: 1.6 |
|
204 """ |
|
205 name = 'AutoIt' |
|
206 aliases = ['autoit'] |
|
207 filenames = ['*.au3'] |
|
208 mimetypes = ['text/x-autoit'] |
|
209 |
|
210 # Keywords, functions, macros from au3.keywords.properties |
|
211 # which can be found in AutoIt installed directory, e.g. |
|
212 # c:\Program Files (x86)\AutoIt3\SciTE\au3.keywords.properties |
|
213 |
|
214 keywords = """\ |
|
215 #include-once #include #endregion #forcedef #forceref #region |
|
216 and byref case continueloop dim do else elseif endfunc endif |
|
217 endselect exit exitloop for func global |
|
218 if local next not or return select step |
|
219 then to until wend while exit""".split() |
|
220 |
|
221 functions = """\ |
|
222 abs acos adlibregister adlibunregister asc ascw asin assign atan |
|
223 autoitsetoption autoitwingettitle autoitwinsettitle beep binary binarylen |
|
224 binarymid binarytostring bitand bitnot bitor bitrotate bitshift bitxor |
|
225 blockinput break call cdtray ceiling chr chrw clipget clipput consoleread |
|
226 consolewrite consolewriteerror controlclick controlcommand controldisable |
|
227 controlenable controlfocus controlgetfocus controlgethandle controlgetpos |
|
228 controlgettext controlhide controllistview controlmove controlsend |
|
229 controlsettext controlshow controltreeview cos dec dircopy dircreate |
|
230 dirgetsize dirmove dirremove dllcall dllcalladdress dllcallbackfree |
|
231 dllcallbackgetptr dllcallbackregister dllclose dllopen dllstructcreate |
|
232 dllstructgetdata dllstructgetptr dllstructgetsize dllstructsetdata |
|
233 drivegetdrive drivegetfilesystem drivegetlabel drivegetserial drivegettype |
|
234 drivemapadd drivemapdel drivemapget drivesetlabel drivespacefree |
|
235 drivespacetotal drivestatus envget envset envupdate eval execute exp |
|
236 filechangedir fileclose filecopy filecreatentfslink filecreateshortcut |
|
237 filedelete fileexists filefindfirstfile filefindnextfile fileflush |
|
238 filegetattrib filegetencoding filegetlongname filegetpos filegetshortcut |
|
239 filegetshortname filegetsize filegettime filegetversion fileinstall filemove |
|
240 fileopen fileopendialog fileread filereadline filerecycle filerecycleempty |
|
241 filesavedialog fileselectfolder filesetattrib filesetpos filesettime |
|
242 filewrite filewriteline floor ftpsetproxy guicreate guictrlcreateavi |
|
243 guictrlcreatebutton guictrlcreatecheckbox guictrlcreatecombo |
|
244 guictrlcreatecontextmenu guictrlcreatedate guictrlcreatedummy |
|
245 guictrlcreateedit guictrlcreategraphic guictrlcreategroup guictrlcreateicon |
|
246 guictrlcreateinput guictrlcreatelabel guictrlcreatelist |
|
247 guictrlcreatelistview guictrlcreatelistviewitem guictrlcreatemenu |
|
248 guictrlcreatemenuitem guictrlcreatemonthcal guictrlcreateobj |
|
249 guictrlcreatepic guictrlcreateprogress guictrlcreateradio |
|
250 guictrlcreateslider guictrlcreatetab guictrlcreatetabitem |
|
251 guictrlcreatetreeview guictrlcreatetreeviewitem guictrlcreateupdown |
|
252 guictrldelete guictrlgethandle guictrlgetstate guictrlread guictrlrecvmsg |
|
253 guictrlregisterlistviewsort guictrlsendmsg guictrlsendtodummy |
|
254 guictrlsetbkcolor guictrlsetcolor guictrlsetcursor guictrlsetdata |
|
255 guictrlsetdefbkcolor guictrlsetdefcolor guictrlsetfont guictrlsetgraphic |
|
256 guictrlsetimage guictrlsetlimit guictrlsetonevent guictrlsetpos |
|
257 guictrlsetresizing guictrlsetstate guictrlsetstyle guictrlsettip guidelete |
|
258 guigetcursorinfo guigetmsg guigetstyle guiregistermsg guisetaccelerators |
|
259 guisetbkcolor guisetcoord guisetcursor guisetfont guisethelp guiseticon |
|
260 guisetonevent guisetstate guisetstyle guistartgroup guiswitch hex hotkeyset |
|
261 httpsetproxy httpsetuseragent hwnd inetclose inetget inetgetinfo inetgetsize |
|
262 inetread inidelete iniread inireadsection inireadsectionnames |
|
263 inirenamesection iniwrite iniwritesection inputbox int isadmin isarray |
|
264 isbinary isbool isdeclared isdllstruct isfloat ishwnd isint iskeyword |
|
265 isnumber isobj isptr isstring log memgetstats mod mouseclick mouseclickdrag |
|
266 mousedown mousegetcursor mousegetpos mousemove mouseup mousewheel msgbox |
|
267 number objcreate objcreateinterface objevent objevent objget objname |
|
268 onautoitexitregister onautoitexitunregister opt ping pixelchecksum |
|
269 pixelgetcolor pixelsearch pluginclose pluginopen processclose processexists |
|
270 processgetstats processlist processsetpriority processwait processwaitclose |
|
271 progressoff progresson progressset ptr random regdelete regenumkey |
|
272 regenumval regread regwrite round run runas runaswait runwait send |
|
273 sendkeepactive seterror setextended shellexecute shellexecutewait shutdown |
|
274 sin sleep soundplay soundsetwavevolume splashimageon splashoff splashtexton |
|
275 sqrt srandom statusbargettext stderrread stdinwrite stdioclose stdoutread |
|
276 string stringaddcr stringcompare stringformat stringfromasciiarray |
|
277 stringinstr stringisalnum stringisalpha stringisascii stringisdigit |
|
278 stringisfloat stringisint stringislower stringisspace stringisupper |
|
279 stringisxdigit stringleft stringlen stringlower stringmid stringregexp |
|
280 stringregexpreplace stringreplace stringright stringsplit stringstripcr |
|
281 stringstripws stringtoasciiarray stringtobinary stringtrimleft |
|
282 stringtrimright stringupper tan tcpaccept tcpclosesocket tcpconnect |
|
283 tcplisten tcpnametoip tcprecv tcpsend tcpshutdown tcpstartup timerdiff |
|
284 timerinit tooltip traycreateitem traycreatemenu traygetmsg trayitemdelete |
|
285 trayitemgethandle trayitemgetstate trayitemgettext trayitemsetonevent |
|
286 trayitemsetstate trayitemsettext traysetclick trayseticon traysetonevent |
|
287 traysetpauseicon traysetstate traysettooltip traytip ubound udpbind |
|
288 udpclosesocket udpopen udprecv udpsend udpshutdown udpstartup vargettype |
|
289 winactivate winactive winclose winexists winflash wingetcaretpos |
|
290 wingetclasslist wingetclientsize wingethandle wingetpos wingetprocess |
|
291 wingetstate wingettext wingettitle winkill winlist winmenuselectitem |
|
292 winminimizeall winminimizeallundo winmove winsetontop winsetstate |
|
293 winsettitle winsettrans winwait winwaitactive winwaitclose |
|
294 winwaitnotactive""".split() |
|
295 |
|
296 macros = """\ |
|
297 @appdatacommondir @appdatadir @autoitexe @autoitpid @autoitversion |
|
298 @autoitx64 @com_eventobj @commonfilesdir @compiled @computername @comspec |
|
299 @cpuarch @cr @crlf @desktopcommondir @desktopdepth @desktopdir |
|
300 @desktopheight @desktoprefresh @desktopwidth @documentscommondir @error |
|
301 @exitcode @exitmethod @extended @favoritescommondir @favoritesdir |
|
302 @gui_ctrlhandle @gui_ctrlid @gui_dragfile @gui_dragid @gui_dropid |
|
303 @gui_winhandle @homedrive @homepath @homeshare @hotkeypressed @hour |
|
304 @ipaddress1 @ipaddress2 @ipaddress3 @ipaddress4 @kblayout @lf |
|
305 @logondnsdomain @logondomain @logonserver @mday @min @mon @msec @muilang |
|
306 @mydocumentsdir @numparams @osarch @osbuild @oslang @osservicepack @ostype |
|
307 @osversion @programfilesdir @programscommondir @programsdir @scriptdir |
|
308 @scriptfullpath @scriptlinenumber @scriptname @sec @startmenucommondir |
|
309 @startmenudir @startupcommondir @startupdir @sw_disable @sw_enable @sw_hide |
|
310 @sw_lock @sw_maximize @sw_minimize @sw_restore @sw_show @sw_showdefault |
|
311 @sw_showmaximized @sw_showminimized @sw_showminnoactive @sw_showna |
|
312 @sw_shownoactivate @sw_shownormal @sw_unlock @systemdir @tab @tempdir |
|
313 @tray_id @trayiconflashing @trayiconvisible @username @userprofiledir @wday |
|
314 @windowsdir @workingdir @yday @year""".split() |
|
315 |
|
316 tokens = { |
|
317 'root': [ |
|
318 (r';.*\n', Comment.Single), |
|
319 (r'(#comments-start|#cs)(.|\n)*?(#comments-end|#ce)', |
|
320 Comment.Multiline), |
|
321 (r'[\[\]{}(),;]', Punctuation), |
|
322 (r'(and|or|not)\b', Operator.Word), |
|
323 (r'[$|@][a-zA-Z_]\w*', Name.Variable), |
|
324 (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator), |
|
325 include('commands'), |
|
326 include('labels'), |
|
327 include('builtInFunctions'), |
|
328 include('builtInMarcros'), |
|
329 (r'"', String, combined('stringescape', 'dqs')), |
|
330 include('numbers'), |
|
331 (r'[a-zA-Z_#@$][\w#@$]*', Name), |
|
332 (r'\\|\'', Text), |
|
333 (r'\`([,%`abfnrtv\-+;])', String.Escape), |
|
334 (r'_\n', Text), # Line continuation |
|
335 include('garbage'), |
|
336 ], |
|
337 'commands': [ |
|
338 (r'(?i)(\s*)(%s)\b' % '|'.join(keywords), |
|
339 bygroups(Text, Name.Builtin)), |
|
340 ], |
|
341 'builtInFunctions': [ |
|
342 (r'(?i)(%s)\b' % '|'.join(functions), |
|
343 Name.Function), |
|
344 ], |
|
345 'builtInMarcros': [ |
|
346 (r'(?i)(%s)\b' % '|'.join(macros), |
|
347 Name.Variable.Global), |
|
348 ], |
|
349 'labels': [ |
|
350 # sendkeys |
|
351 (r'(^\s*)(\{\S+?\})', bygroups(Text, Name.Label)), |
|
352 ], |
|
353 'numbers': [ |
|
354 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), |
|
355 (r'\d+[eE][+-]?[0-9]+', Number.Float), |
|
356 (r'0\d+', Number.Oct), |
|
357 (r'0[xX][a-fA-F0-9]+', Number.Hex), |
|
358 (r'\d+L', Number.Integer.Long), |
|
359 (r'\d+', Number.Integer) |
|
360 ], |
|
361 'stringescape': [ |
|
362 (r'\"\"|\`([,%`abfnrtv])', String.Escape), |
|
363 ], |
|
364 'strings': [ |
|
365 (r'[^"\n]+', String), |
|
366 ], |
|
367 'dqs': [ |
|
368 (r'"', String, '#pop'), |
|
369 include('strings') |
|
370 ], |
|
371 'garbage': [ |
|
372 (r'[^\S\n]', Text), |
|
373 ], |
|
374 } |