Ted Shaw avatar Ted Shaw committed db8a977

open in binary mode so \n will not be changed to OS specific end-of-line, and add AutoItLexer

Comments (0)

Files changed (2)

pygments/lexers/_mapping.py

     'AppleScriptLexer': ('pygments.lexers.other', 'AppleScript', ('applescript',), ('*.applescript',), ()),
     'AspectJLexer': ('pygments.lexers.jvm', 'AspectJ', ('aspectj',), ('*.aj',), ('text/x-aspectj',)),
     'AsymptoteLexer': ('pygments.lexers.other', 'Asymptote', ('asy', 'asymptote'), ('*.asy',), ('text/x-asymptote',)),
+    'AutoItLexer': ('pygments.lexers.other', 'AutoIt', ('autoit', 'Autoit'), ('*.au3',), ('text/x-autoit',)),
     'AutohotkeyLexer': ('pygments.lexers.other', 'autohotkey', ('ahk',), ('*.ahk', '*.ahkl'), ('text/x-autohotkey',)),
     'AwkLexer': ('pygments.lexers.other', 'Awk', ('awk', 'gawk', 'mawk', 'nawk'), ('*.awk',), ('application/x-awk',)),
     'BBCodeLexer': ('pygments.lexers.text', 'BBCode', ('bbcode',), (), ('text/x-bbcode',)),
     footer = content[content.find("if __name__ == '__main__':"):]
 
     # write new file
-    f = open(__file__, 'w')
+    f = open(__file__, 'wb')
     f.write(header)
     f.write('LEXERS = {\n    %s,\n}\n\n' % ',\n    '.join(found_lexers))
     f.write(footer)

pygments/lexers/other.py

            'AutohotkeyLexer', 'GoodDataCLLexer', 'MaqlLexer', 'ProtoBufLexer',
            'HybrisLexer', 'AwkLexer', 'Cfengine3Lexer', 'SnobolLexer',
            'ECLLexer', 'UrbiscriptLexer', 'OpenEdgeLexer', 'BroLexer',
-           'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer']
+           'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer',
+           'AutoItLexer']
 
 
 class ECLLexer(RegexLexer):
                     elif value in self._functions:
                         tokens = Name.Builtin
             yield index, token, value
+
+class AutoItLexer(RegexLexer):
+    """
+    For `AutoIt <http://www.autoitscript.com/site/autoit/>`_ files.
+    
+    AutoIt is a freeware BASIC-like scripting language 
+    designed for automating the Windows GUI and general scripting
+    
+    *New in Pygments 1.6.*
+    """
+    name = 'AutoIt'
+    aliases = ['autoit', 'Autoit']
+    filenames = ['*.au3']
+    mimetypes = ['text/x-autoit']
+    
+    # Keywords, functions, macros from au3.keywords.properties
+    # which can be found in AutoIt installed directory, e.g.
+    # c:\Program Files (x86)\AutoIt3\SciTE\au3.keywords.properties   
+
+    keywords = """
+#include-once #include #endregion #forcedef #forceref #region
+and byref case continueloop dim do else elseif endfunc endif
+endselect exit exitloop for func global
+if local next not or return select step 
+then to until wend while exit""".split() 
+   
+    functions="""
+abs acos adlibregister adlibunregister asc ascw asin assign
+atan autoitsetoption autoitwingettitle autoitwinsettitle beep binary binarylen binarymid 
+binarytostring bitand bitnot bitor bitrotate bitshift bitxor blockinput break call 
+cdtray ceiling chr chrw clipget clipput consoleread consolewrite consolewriteerror 
+controlclick controlcommand controldisable controlenable controlfocus controlgetfocus 
+controlgethandle controlgetpos controlgettext controlhide controllistview controlmove 
+controlsend controlsettext controlshow controltreeview cos dec dircopy dircreate 
+dirgetsize dirmove dirremove dllcall dllcalladdress dllcallbackfree dllcallbackgetptr 
+dllcallbackregister dllclose dllopen dllstructcreate dllstructgetdata dllstructgetptr 
+dllstructgetsize dllstructsetdata drivegetdrive drivegetfilesystem drivegetlabel 
+drivegetserial drivegettype drivemapadd drivemapdel drivemapget drivesetlabel drivespacefree 
+drivespacetotal drivestatus envget envset envupdate eval execute exp filechangedir 
+fileclose filecopy filecreatentfslink filecreateshortcut filedelete fileexists filefindfirstfile 
+filefindnextfile fileflush filegetattrib filegetencoding filegetlongname filegetpos 
+filegetshortcut filegetshortname filegetsize filegettime filegetversion fileinstall 
+filemove fileopen fileopendialog fileread filereadline filerecycle filerecycleempty 
+filesavedialog fileselectfolder filesetattrib filesetpos filesettime filewrite filewriteline 
+floor ftpsetproxy guicreate guictrlcreateavi guictrlcreatebutton guictrlcreatecheckbox 
+guictrlcreatecombo guictrlcreatecontextmenu guictrlcreatedate guictrlcreatedummy 
+guictrlcreateedit guictrlcreategraphic guictrlcreategroup guictrlcreateicon guictrlcreateinput 
+guictrlcreatelabel guictrlcreatelist guictrlcreatelistview guictrlcreatelistviewitem 
+guictrlcreatemenu guictrlcreatemenuitem guictrlcreatemonthcal guictrlcreateobj guictrlcreatepic 
+guictrlcreateprogress guictrlcreateradio guictrlcreateslider guictrlcreatetab guictrlcreatetabitem 
+guictrlcreatetreeview guictrlcreatetreeviewitem guictrlcreateupdown guictrldelete 
+guictrlgethandle guictrlgetstate guictrlread guictrlrecvmsg guictrlregisterlistviewsort 
+guictrlsendmsg guictrlsendtodummy guictrlsetbkcolor guictrlsetcolor guictrlsetcursor 
+guictrlsetdata guictrlsetdefbkcolor guictrlsetdefcolor guictrlsetfont guictrlsetgraphic 
+guictrlsetimage guictrlsetlimit guictrlsetonevent guictrlsetpos guictrlsetresizing 
+guictrlsetstate guictrlsetstyle guictrlsettip guidelete guigetcursorinfo guigetmsg 
+guigetstyle guiregistermsg guisetaccelerators guisetbkcolor guisetcoord guisetcursor 
+guisetfont guisethelp guiseticon guisetonevent guisetstate guisetstyle guistartgroup 
+guiswitch hex hotkeyset httpsetproxy httpsetuseragent hwnd inetclose inetget inetgetinfo 
+inetgetsize inetread inidelete iniread inireadsection inireadsectionnames inirenamesection 
+iniwrite iniwritesection inputbox int isadmin isarray isbinary isbool isdeclared 
+isdllstruct isfloat ishwnd isint iskeyword isnumber isobj isptr isstring log memgetstats 
+mod mouseclick mouseclickdrag mousedown mousegetcursor mousegetpos mousemove mouseup 
+mousewheel msgbox number objcreate objcreateinterface objevent objevent objget objname 
+onautoitexitregister onautoitexitunregister opt ping pixelchecksum pixelgetcolor 
+pixelsearch pluginclose pluginopen processclose processexists processgetstats processlist 
+processsetpriority processwait processwaitclose progressoff progresson progressset 
+ptr random regdelete regenumkey regenumval regread regwrite round run runas runaswait 
+runwait send sendkeepactive seterror setextended shellexecute shellexecutewait shutdown 
+sin sleep soundplay soundsetwavevolume splashimageon splashoff splashtexton sqrt 
+srandom statusbargettext stderrread stdinwrite stdioclose stdoutread string stringaddcr 
+stringcompare stringformat stringfromasciiarray stringinstr stringisalnum stringisalpha 
+stringisascii stringisdigit stringisfloat stringisint stringislower stringisspace 
+stringisupper stringisxdigit stringleft stringlen stringlower stringmid stringregexp 
+stringregexpreplace stringreplace stringright stringsplit stringstripcr stringstripws 
+stringtoasciiarray stringtobinary stringtrimleft stringtrimright stringupper tan 
+tcpaccept tcpclosesocket tcpconnect tcplisten tcpnametoip tcprecv tcpsend tcpshutdown 
+tcpstartup timerdiff timerinit tooltip traycreateitem traycreatemenu traygetmsg trayitemdelete 
+trayitemgethandle trayitemgetstate trayitemgettext trayitemsetonevent trayitemsetstate 
+trayitemsettext traysetclick trayseticon traysetonevent traysetpauseicon traysetstate 
+traysettooltip traytip ubound udpbind udpclosesocket udpopen udprecv udpsend udpshutdown 
+udpstartup vargettype winactivate winactive winclose winexists winflash wingetcaretpos 
+wingetclasslist wingetclientsize wingethandle wingetpos wingetprocess wingetstate 
+wingettext wingettitle winkill winlist winmenuselectitem winminimizeall winminimizeallundo 
+winmove winsetontop winsetstate winsettitle winsettrans winwait winwaitactive winwaitclose 
+winwaitnotactive""".split()
+
+    macros="""
+@appdatacommondir @appdatadir @autoitexe @autoitpid @autoitversion
+@autoitx64 @com_eventobj @commonfilesdir @compiled @computername @comspec @cpuarch
+@cr @crlf @desktopcommondir @desktopdepth @desktopdir @desktopheight @desktoprefresh
+@desktopwidth @documentscommondir @error @exitcode @exitmethod @extended @favoritescommondir
+@favoritesdir @gui_ctrlhandle @gui_ctrlid @gui_dragfile @gui_dragid @gui_dropid @gui_winhandle
+@homedrive @homepath @homeshare @hotkeypressed @hour @ipaddress1 @ipaddress2 @ipaddress3
+@ipaddress4 @kblayout @lf @logondnsdomain @logondomain @logonserver @mday @min @mon
+@msec @muilang @mydocumentsdir @numparams @osarch @osbuild @oslang @osservicepack
+@ostype @osversion @programfilesdir @programscommondir @programsdir @scriptdir @scriptfullpath
+@scriptlinenumber @scriptname @sec @startmenucommondir @startmenudir @startupcommondir
+@startupdir @sw_disable @sw_enable @sw_hide @sw_lock @sw_maximize @sw_minimize @sw_restore
+@sw_show @sw_showdefault @sw_showmaximized @sw_showminimized @sw_showminnoactive
+@sw_showna @sw_shownoactivate @sw_shownormal @sw_unlock @systemdir @tab @tempdir
+@tray_id @trayiconflashing @trayiconvisible @username @userprofiledir @wday @windowsdir
+@workingdir @yday @year""".split()
+
+    tokens = {
+        'root': [
+            (r';.*\n', Comment.Single),
+            (r'(#comments-start|#cs).*?(#comments-end|#ce)', Comment.Multiline),
+            (r'[\[\]{}(),;]', Punctuation),
+            (r'(and|or|not)\b', Operator.Word),
+            (r'[\$|@][a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
+            (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator),
+            include('commands'),
+            include('labels'),
+            include('builtInFunctions'),
+            include('builtInMarcros'),
+            (r'"', String, combined('stringescape', 'dqs')),
+            include('numbers'),
+            (r'[a-zA-Z_#@$][a-zA-Z0-9_#@$]*', Name),
+            (r'\\|\'', Text),
+            (r'\`([\,\%\`abfnrtv\-\+;])', String.Escape),
+            (r'_\n', Text), # Line continuation
+            include('garbage'),
+        ],
+        'commands': [
+            (r'(?i)(\s*)(%s)\b' % '|'.join(keywords),
+            bygroups(Text, Name.Builtin)),
+        ],
+        'builtInFunctions': [
+            (r'(?i)(%s)\b' % '|'.join(functions),
+             Name.Function),
+        ],
+        'builtInMarcros': [
+            (r'(?i)(%s)\b' % '|'.join(macros),
+             Name.Variable.Global),
+        ],
+        'labels': [
+            # sendkeys
+            (r'(^\s*)({[^\s]+?})', bygroups(Text, Name.Label)),
+        ],
+        'numbers': [
+            (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
+            (r'\d+[eE][+-]?[0-9]+', Number.Float),
+            (r'0\d+', Number.Oct),
+            (r'0[xX][a-fA-F0-9]+', Number.Hex),
+            (r'\d+L', Number.Integer.Long),
+            (r'\d+', Number.Integer)
+        ],
+        'stringescape': [
+            (r'\"\"|\`([\,\%\`abfnrtv])', String.Escape),
+        ],
+        'strings': [
+            (r'[^"\n]+', String),
+        ],
+        'dqs': [
+            (r'"', String, '#pop'),
+            include('strings')
+        ],
+        'garbage': [
+            (r'[^\S\n]', Text),
+        ],
+    }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.