Commits

Thomas Aglassinger committed 7c52166 Merge

Merged birkenfeld/pygments-main into default

Comments (0)

Files changed (29)

 * Christian Jann -- ShellSession lexer
 * Christopher Creutzig -- MuPAD lexer
 * Pete Curry -- bugfixes
-* Owen Durni -- haXe lexer
+* Bryan Davis -- EBNF lexer
+* Owen Durni -- Haxe lexer
 * Nick Efford -- Python 3 lexer
 * Sven Efftinge -- Xtend lexer
 * Artem Egorkine -- terminal256 formatter
 * James H. Fisher -- PostScript lexer
+* William S. Fulton -- SWIG lexer
 * Carlos Galdino -- Elixir and Elixir Console lexers
 * Michael Galloy -- IDL lexer
 * Naveen Garg -- Autohotkey lexer
 * Laurent Gautier -- R/S lexer
 * Alex Gaynor -- PyPy log lexer
+* Richard Gerkin -- Igor Pro lexer
 * Alain Gilbert -- TypeScript lexer
+* Alex Gilding -- BlitzBasic lexer
 * Bertrand Goetzmann -- Groovy lexer
 * Krzysiek Goj -- Scala lexer
 * Matt Good -- Genshi, Cheetah lexers
+* Michał Górny -- vim modeline support
 * Patrick Gotthardt -- PHP namespaces support
 * Olivier Guibe -- Asymptote lexer
 * Jordi Gutiérrez Hermoso -- Octave lexer
 * Greg Hendershott -- Racket lexer
 * David Hess, Fish Software, Inc. -- Objective-J lexer
 * Varun Hiremath -- Debian control lexer
+* Rob Hoelz -- Perl 6 lexer
 * Doug Hogan -- Mscgen lexer
 * Ben Hollis -- Mason lexer
 * Dustin Howett -- Logos lexer
 * Mike Nolta -- Julia lexer
 * Jonas Obrist -- BBCode lexer
 * David Oliva -- Rebol lexer
+* Pat Pannuto -- nesC lexer
 * Jon Parise -- Protocol buffers lexer
 * Ronny Pfannschmidt -- BBCode lexer
 * Benjamin Peterson -- Test suite refactoring
 - Lexers added:
 
   * Clay (PR#184)
+  * Perl 6 (PR#181)
+  * Swig (PR#168)
+  * nesC (PR#166)
+  * BlitzBasic (PR#197)
+  * EBNF (PR#193)
+  * Igor Pro (PR#172)
+  * Rexx (PR#199)
+
+- Pygments will now recognize "vim" modelines when guessing the lexer for
+  a file based on content (PR#118).
+
+- The NameHighlightFilter now works with any Name.* token type (#790).
 
 - Python 3 lexer: add new exceptions from PEP 3151.
 
 - Lasso lexer: fix method highlighting, update builtins. Fix
   guessing so that plain XML isn't always taken as Lasso (PR#163).
 
+- Objective C/C++ lexers: allow "@" prefixing any expression (#871).
+
+- Ruby lexer: fix lexing of Name::Space tokens (#860).
+
+- Stan lexer: update for version 1.3.0 of the language (PR#162).
+
+- JavaScript lexer: add the "yield" keyword (PR#196).
+
+- HTTP lexer: support for PATCH method (PR#190).
+
+- Koka lexer: update to newest language spec (PR#201).
+
+- Haxe lexer: rewrite and support for Haxe 3 (PR#174).
+
+- Prolog lexer: add different kinds of numeric literals (#864).
+
 
 Version 1.6
 -----------
   * Ada
   * Coldfusion
   * Modula-2
-  * haXe
+  * Haxe
   * R console
   * Objective-J
   * Haml and Sass
   * CMake
   * Ooc
   * Coldfusion
-  * haXe
+  * Haxe
   * R console
 
 - Added options for rendering LaTeX in source code comments in the
-#!/usr/bin/env python
+#!/usr/bin/env python2
 
 import sys, pygments.cmdline
 try:

pygments/filters/__init__.py

 
 class NameHighlightFilter(Filter):
     """
-    Highlight a normal Name token with a different token type.
+    Highlight a normal Name (and Name.*) token with a different token type.
 
     Example::
 
 
     def filter(self, lexer, stream):
         for ttype, value in stream:
-            if ttype is Name and value in self.names:
+            if ttype in Name and value in self.names:
                 yield self.tokentype, value
             else:
                 yield ttype, value

pygments/formatter.py

         self.full  = get_bool_opt(options, 'full', False)
         self.title = options.get('title', '')
         self.encoding = options.get('encoding', None) or None
+        if self.encoding == 'guess':
+            # can happen for pygmentize -O encoding=guess
+            self.encoding = 'utf-8'
         self.encoding = options.get('outencoding', None) or self.encoding
         self.options = options
 

pygments/lexers/__init__.py

 from os.path import basename
 
 from pygments.lexers._mapping import LEXERS
+from pygments.modeline import get_filetype_from_buffer
 from pygments.plugin import find_plugin_lexers
 from pygments.util import ClassNotFound, bytes
 
     """
     Guess a lexer by strong distinctions in the text (eg, shebang).
     """
+
+    # try to get a vim modeline first
+    ft = get_filetype_from_buffer(_text)
+
+    if ft is not None:
+        try:
+            return get_lexer_by_name(ft, **options)
+        except ClassNotFound:
+            pass
+
     best_lexer = [0.0, None]
     for lexer in _iter_lexerclasses():
         rv = lexer.analyse_text(_text)

pygments/lexers/_mapping.py

     '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',)),
+    'AutohotkeyLexer': ('pygments.lexers.other', 'autohotkey', ('ahk', 'autohotkey'), ('*.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',)),
     'BaseMakefileLexer': ('pygments.lexers.text', 'Base Makefile', ('basemake',), (), ()),
     'BashLexer': ('pygments.lexers.shell', 'Bash', ('bash', 'sh', 'ksh'), ('*.sh', '*.ksh', '*.bash', '*.ebuild', '*.eclass', '.bashrc', 'bashrc', '.bash_*', 'bash_*'), ('application/x-sh', 'application/x-shellscript')),
     'BashSessionLexer': ('pygments.lexers.shell', 'Bash Session', ('console',), ('*.sh-session',), ('application/x-shell-session',)),
-    'BatchLexer': ('pygments.lexers.shell', 'Batchfile', ('bat',), ('*.bat', '*.cmd'), ('application/x-dos-batch',)),
+    'BatchLexer': ('pygments.lexers.shell', 'Batchfile', ('bat', 'dosbatch', 'winbatch'), ('*.bat', '*.cmd'), ('application/x-dos-batch',)),
     'BefungeLexer': ('pygments.lexers.other', 'Befunge', ('befunge',), ('*.befunge',), ('application/x-befunge',)),
     'BlitzBasicLexer': ('pygments.lexers.compiled', 'BlitzBasic', ('blitzbasic', 'b3d', 'bplus'), ('*.bb', '*.decls'), ('text/x-bb',)),
     'BlitzMaxLexer': ('pygments.lexers.compiled', 'BlitzMax', ('blitzmax', 'bmax'), ('*.bmx',), ('text/x-bmx',)),
     'CbmBasicV2Lexer': ('pygments.lexers.other', 'CBM BASIC V2', ('cbmbas',), ('*.bas',), ()),
     'CeylonLexer': ('pygments.lexers.jvm', 'Ceylon', ('ceylon',), ('*.ceylon',), ('text/x-ceylon',)),
     'Cfengine3Lexer': ('pygments.lexers.other', 'CFEngine3', ('cfengine3', 'cf3'), ('*.cf',), ()),
-    'CheetahHtmlLexer': ('pygments.lexers.templates', 'HTML+Cheetah', ('html+cheetah', 'html+spitfire'), (), ('text/html+cheetah', 'text/html+spitfire')),
+    'CheetahHtmlLexer': ('pygments.lexers.templates', 'HTML+Cheetah', ('html+cheetah', 'html+spitfire', 'htmlcheetah'), (), ('text/html+cheetah', 'text/html+spitfire')),
     'CheetahJavascriptLexer': ('pygments.lexers.templates', 'JavaScript+Cheetah', ('js+cheetah', 'javascript+cheetah', 'js+spitfire', 'javascript+spitfire'), (), ('application/x-javascript+cheetah', 'text/x-javascript+cheetah', 'text/javascript+cheetah', 'application/x-javascript+spitfire', 'text/x-javascript+spitfire', 'text/javascript+spitfire')),
     'CheetahLexer': ('pygments.lexers.templates', 'Cheetah', ('cheetah', 'spitfire'), ('*.tmpl', '*.spt'), ('application/x-cheetah', 'application/x-spitfire')),
     'CheetahXmlLexer': ('pygments.lexers.templates', 'XML+Cheetah', ('xml+cheetah', 'xml+spitfire'), (), ('application/xml+cheetah', 'application/xml+spitfire')),
     'ClojureLexer': ('pygments.lexers.jvm', 'Clojure', ('clojure', 'clj'), ('*.clj',), ('text/x-clojure', 'application/x-clojure')),
     'CobolFreeformatLexer': ('pygments.lexers.compiled', 'COBOLFree', ('cobolfree',), ('*.cbl', '*.CBL'), ()),
     'CobolLexer': ('pygments.lexers.compiled', 'COBOL', ('cobol',), ('*.cob', '*.COB', '*.cpy', '*.CPY'), ('text/x-cobol',)),
-    'CoffeeScriptLexer': ('pygments.lexers.web', 'CoffeeScript', ('coffee-script', 'coffeescript'), ('*.coffee',), ('text/coffeescript',)),
+    'CoffeeScriptLexer': ('pygments.lexers.web', 'CoffeeScript', ('coffee-script', 'coffeescript', 'coffee'), ('*.coffee',), ('text/coffeescript',)),
     'ColdfusionHtmlLexer': ('pygments.lexers.templates', 'Coldfusion HTML', ('cfm',), ('*.cfm', '*.cfml', '*.cfc'), ('application/x-coldfusion',)),
     'ColdfusionLexer': ('pygments.lexers.templates', 'cfstatement', ('cfs',), (), ()),
-    'CommonLispLexer': ('pygments.lexers.functional', 'Common Lisp', ('common-lisp', 'cl'), ('*.cl', '*.lisp', '*.el'), ('text/x-common-lisp',)),
+    'CommonLispLexer': ('pygments.lexers.functional', 'Common Lisp', ('common-lisp', 'cl', 'lisp'), ('*.cl', '*.lisp', '*.el'), ('text/x-common-lisp',)),
     'CoqLexer': ('pygments.lexers.functional', 'Coq', ('coq',), ('*.v',), ('text/x-coq',)),
     'CppLexer': ('pygments.lexers.compiled', 'C++', ('cpp', 'c++'), ('*.cpp', '*.hpp', '*.c++', '*.h++', '*.cc', '*.hh', '*.cxx', '*.hxx', '*.C', '*.H', '*.cp', '*.CPP'), ('text/x-c++hdr', 'text/x-c++src')),
     'CppObjdumpLexer': ('pygments.lexers.asm', 'cpp-objdump', ('cpp-objdump', 'c++-objdumb', 'cxx-objdump'), ('*.cpp-objdump', '*.c++-objdump', '*.cxx-objdump'), ('text/x-cpp-objdump',)),
     'CssPhpLexer': ('pygments.lexers.templates', 'CSS+PHP', ('css+php',), (), ('text/css+php',)),
     'CssSmartyLexer': ('pygments.lexers.templates', 'CSS+Smarty', ('css+smarty',), (), ('text/css+smarty',)),
     'CudaLexer': ('pygments.lexers.compiled', 'CUDA', ('cuda', 'cu'), ('*.cu', '*.cuh'), ('text/x-cuda',)),
-    'CythonLexer': ('pygments.lexers.compiled', 'Cython', ('cython', 'pyx'), ('*.pyx', '*.pxd', '*.pxi'), ('text/x-cython', 'application/x-cython')),
+    'CythonLexer': ('pygments.lexers.compiled', 'Cython', ('cython', 'pyx', 'pyrex'), ('*.pyx', '*.pxd', '*.pxi'), ('text/x-cython', 'application/x-cython')),
     'DLexer': ('pygments.lexers.compiled', 'D', ('d',), ('*.d', '*.di'), ('text/x-dsrc',)),
     'DObjdumpLexer': ('pygments.lexers.asm', 'd-objdump', ('d-objdump',), ('*.d-objdump',), ('text/x-d-objdump',)),
     'DarcsPatchLexer': ('pygments.lexers.text', 'Darcs Patch', ('dpatch',), ('*.dpatch', '*.darcspatch'), ()),
     'DartLexer': ('pygments.lexers.web', 'Dart', ('dart',), ('*.dart',), ('text/x-dart',)),
-    'DebianControlLexer': ('pygments.lexers.text', 'Debian Control file', ('control',), ('control',), ()),
+    'DebianControlLexer': ('pygments.lexers.text', 'Debian Control file', ('control', 'debcontrol'), ('control',), ()),
     'DelphiLexer': ('pygments.lexers.compiled', 'Delphi', ('delphi', 'pas', 'pascal', 'objectpascal'), ('*.pas',), ('text/x-pascal',)),
     'DgLexer': ('pygments.lexers.agile', 'dg', ('dg',), ('*.dg',), ('text/x-dg',)),
     'DiffLexer': ('pygments.lexers.text', 'Diff', ('diff', 'udiff'), ('*.diff', '*.patch'), ('text/x-diff', 'text/x-patch')),
     'ECLLexer': ('pygments.lexers.other', 'ECL', ('ecl',), ('*.ecl',), ('application/x-ecl',)),
     'ECLexer': ('pygments.lexers.compiled', 'eC', ('ec',), ('*.ec', '*.eh'), ('text/x-echdr', 'text/x-ecsrc')),
     'EasytrieveLexer': ('pygments.lexers.other', 'Easytrieve', ('easytrieve',), ('*.ezt', '*.mac'), ('text/x-easytrieve',)),
+    'EbnfLexer': ('pygments.lexers.text', 'EBNF', ('ebnf',), ('*.ebnf',), ('text/x-ebnf',)),
     'ElixirConsoleLexer': ('pygments.lexers.functional', 'Elixir iex session', ('iex',), (), ('text/x-elixir-shellsession',)),
     'ElixirLexer': ('pygments.lexers.functional', 'Elixir', ('elixir', 'ex', 'exs'), ('*.ex', '*.exs'), ('text/x-elixir',)),
     'ErbLexer': ('pygments.lexers.templates', 'ERB', ('erb',), (), ('application/x-ruby-templating',)),
     'FortranLexer': ('pygments.lexers.compiled', 'Fortran', ('fortran',), ('*.f', '*.f90', '*.F', '*.F90'), ('text/x-fortran',)),
     'FoxProLexer': ('pygments.lexers.foxpro', 'FoxPro', ('Clipper', 'XBase'), ('*.PRG', '*.prg'), ()),
     'GLShaderLexer': ('pygments.lexers.compiled', 'GLSL', ('glsl',), ('*.vert', '*.frag', '*.geo'), ('text/x-glslsrc',)),
-    'GasLexer': ('pygments.lexers.asm', 'GAS', ('gas',), ('*.s', '*.S'), ('text/x-gas',)),
+    'GasLexer': ('pygments.lexers.asm', 'GAS', ('gas', 'asm'), ('*.s', '*.S'), ('text/x-gas',)),
     'GenshiLexer': ('pygments.lexers.templates', 'Genshi', ('genshi', 'kid', 'xml+genshi', 'xml+kid'), ('*.kid',), ('application/x-genshi', 'application/x-kid')),
     'GenshiTextLexer': ('pygments.lexers.templates', 'Genshi Text', ('genshitext',), (), ('application/x-genshi-text', 'text/x-genshi')),
     'GettextLexer': ('pygments.lexers.text', 'Gettext Catalog', ('pot', 'po'), ('*.pot', '*.po'), ('application/x-gettext', 'text/x-gettext', 'text/gettext')),
     'GroovyLexer': ('pygments.lexers.jvm', 'Groovy', ('groovy',), ('*.groovy',), ('text/x-groovy',)),
     'HamlLexer': ('pygments.lexers.web', 'Haml', ('haml', 'HAML'), ('*.haml',), ('text/x-haml',)),
     'HaskellLexer': ('pygments.lexers.functional', 'Haskell', ('haskell', 'hs'), ('*.hs',), ('text/x-haskell',)),
-    'HaxeLexer': ('pygments.lexers.web', 'haXe', ('hx', 'haXe'), ('*.hx',), ('text/haxe',)),
-    'HtmlDjangoLexer': ('pygments.lexers.templates', 'HTML+Django/Jinja', ('html+django', 'html+jinja'), (), ('text/html+django', 'text/html+jinja')),
+    'HaxeLexer': ('pygments.lexers.web', 'Haxe', ('hx', 'Haxe', 'haxe', 'haXe', 'hxsl'), ('*.hx', '*.hxsl'), ('text/haxe', 'text/x-haxe', 'text/x-hx')),
+    'HtmlDjangoLexer': ('pygments.lexers.templates', 'HTML+Django/Jinja', ('html+django', 'html+jinja', 'htmldjango'), (), ('text/html+django', 'text/html+jinja')),
     'HtmlGenshiLexer': ('pygments.lexers.templates', 'HTML+Genshi', ('html+genshi', 'html+kid'), (), ('text/html+genshi',)),
     'HtmlLexer': ('pygments.lexers.web', 'HTML', ('html',), ('*.html', '*.htm', '*.xhtml', '*.xslt'), ('text/html', 'application/xhtml+xml')),
     'HtmlPhpLexer': ('pygments.lexers.templates', 'HTML+PHP', ('html+php',), ('*.phtml',), ('application/x-php', 'application/x-httpd-php', 'application/x-httpd-php3', 'application/x-httpd-php4', 'application/x-httpd-php5')),
     'HxmlLexer': ('pygments.lexers.text', 'Hxml', ('haxeml', 'hxml'), ('*.hxml',), ()),
     'HybrisLexer': ('pygments.lexers.other', 'Hybris', ('hybris', 'hy'), ('*.hy', '*.hyb'), ('text/x-hybris', 'application/x-hybris')),
     'IDLLexer': ('pygments.lexers.math', 'IDL', ('idl',), ('*.pro',), ('text/idl',)),
-    'IniLexer': ('pygments.lexers.text', 'INI', ('ini', 'cfg'), ('*.ini', '*.cfg'), ('text/x-ini',)),
+    'IgorLexer': ('pygments.lexers.math', 'Igor', ('igor', 'igorpro'), ('*.ipf',), ('text/ipf',)),
+    'IniLexer': ('pygments.lexers.text', 'INI', ('ini', 'cfg', 'dosini'), ('*.ini', '*.cfg'), ('text/x-ini',)),
     'IoLexer': ('pygments.lexers.agile', 'Io', ('io',), ('*.io',), ('text/x-iosrc',)),
     'IokeLexer': ('pygments.lexers.jvm', 'Ioke', ('ioke', 'ik'), ('*.ik',), ('text/x-iokesrc',)),
     'IrcLogsLexer': ('pygments.lexers.text', 'IRC logs', ('irc',), ('*.weechatlog',), ('text/x-irclog',)),
     'LassoLexer': ('pygments.lexers.web', 'Lasso', ('lasso', 'lassoscript'), ('*.lasso', '*.lasso[89]'), ('text/x-lasso',)),
     'LassoXmlLexer': ('pygments.lexers.templates', 'XML+Lasso', ('xml+lasso',), (), ('application/xml+lasso',)),
     'LighttpdConfLexer': ('pygments.lexers.text', 'Lighttpd configuration file', ('lighty', 'lighttpd'), (), ('text/x-lighttpd-conf',)),
-    'LiterateHaskellLexer': ('pygments.lexers.functional', 'Literate Haskell', ('lhs', 'literate-haskell'), ('*.lhs',), ('text/x-literate-haskell',)),
+    'LiterateHaskellLexer': ('pygments.lexers.functional', 'Literate Haskell', ('lhs', 'literate-haskell', 'lhaskell'), ('*.lhs',), ('text/x-literate-haskell',)),
     'LiveScriptLexer': ('pygments.lexers.web', 'LiveScript', ('live-script', 'livescript'), ('*.ls',), ('text/livescript',)),
     'LlvmLexer': ('pygments.lexers.asm', 'LLVM', ('llvm',), ('*.ll',), ('text/x-llvm',)),
     'LogosLexer': ('pygments.lexers.compiled', 'Logos', ('logos',), ('*.x', '*.xi', '*.xm', '*.xmi'), ('text/x-logos',)),
     'LogtalkLexer': ('pygments.lexers.other', 'Logtalk', ('logtalk',), ('*.lgt',), ('text/x-logtalk',)),
     'LuaLexer': ('pygments.lexers.agile', 'Lua', ('lua',), ('*.lua', '*.wlua'), ('text/x-lua', 'application/x-lua')),
-    'MOOCodeLexer': ('pygments.lexers.other', 'MOOCode', ('moocode',), ('*.moo',), ('text/x-moocode',)),
+    'MOOCodeLexer': ('pygments.lexers.other', 'MOOCode', ('moocode', 'moo'), ('*.moo',), ('text/x-moocode',)),
     'MakefileLexer': ('pygments.lexers.text', 'Makefile', ('make', 'makefile', 'mf', 'bsdmake'), ('*.mak', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile'), ('text/x-makefile',)),
     'MakoCssLexer': ('pygments.lexers.templates', 'CSS+Mako', ('css+mako',), (), ('text/css+mako',)),
     'MakoHtmlLexer': ('pygments.lexers.templates', 'HTML+Mako', ('html+mako',), (), ('text/html+mako',)),
     'PerlLexer': ('pygments.lexers.agile', 'Perl', ('perl', 'pl'), ('*.pl', '*.pm'), ('text/x-perl', 'application/x-perl')),
     'PhpLexer': ('pygments.lexers.web', 'PHP', ('php', 'php3', 'php4', 'php5'), ('*.php', '*.php[345]', '*.inc'), ('text/x-php',)),
     'PlPgsqlLexer': ('pygments.lexers.sql', 'PL/pgSQL', ('plpgsql',), (), ('text/x-plpgsql',)),
-    'PostScriptLexer': ('pygments.lexers.other', 'PostScript', ('postscript',), ('*.ps', '*.eps'), ('application/postscript',)),
+    'PostScriptLexer': ('pygments.lexers.other', 'PostScript', ('postscript', 'postscr'), ('*.ps', '*.eps'), ('application/postscript',)),
     'PostgresConsoleLexer': ('pygments.lexers.sql', 'PostgreSQL console (psql)', ('psql', 'postgresql-console', 'postgres-console'), (), ('text/x-postgresql-psql',)),
     'PostgresLexer': ('pygments.lexers.sql', 'PostgreSQL SQL dialect', ('postgresql', 'postgres'), (), ('text/x-postgresql',)),
     'PovrayLexer': ('pygments.lexers.other', 'POVRay', ('pov',), ('*.pov', '*.inc'), ('text/x-povray',)),
     'PowerShellLexer': ('pygments.lexers.shell', 'PowerShell', ('powershell', 'posh', 'ps1', 'psm1'), ('*.ps1', '*.psm1'), ('text/x-powershell',)),
     'PrologLexer': ('pygments.lexers.compiled', 'Prolog', ('prolog',), ('*.prolog', '*.pro', '*.pl'), ('text/x-prolog',)),
-    'PropertiesLexer': ('pygments.lexers.text', 'Properties', ('properties',), ('*.properties',), ('text/x-java-properties',)),
-    'ProtoBufLexer': ('pygments.lexers.other', 'Protocol Buffer', ('protobuf',), ('*.proto',), ()),
+    'PropertiesLexer': ('pygments.lexers.text', 'Properties', ('properties', 'jproperties'), ('*.properties',), ('text/x-java-properties',)),
+    'ProtoBufLexer': ('pygments.lexers.other', 'Protocol Buffer', ('protobuf', 'proto'), ('*.proto',), ()),
     'PuppetLexer': ('pygments.lexers.other', 'Puppet', ('puppet',), ('*.pp',), ()),
     'PyPyLogLexer': ('pygments.lexers.text', 'PyPy Log', ('pypylog', 'pypy'), ('*.pypylog',), ('application/x-pypylog',)),
     'Python3Lexer': ('pygments.lexers.agile', 'Python 3', ('python3', 'py3'), (), ('text/x-python3', 'application/x-python3')),
     'RebolLexer': ('pygments.lexers.other', 'REBOL', ('rebol',), ('*.r', '*.r3'), ('text/x-rebol',)),
     'RedcodeLexer': ('pygments.lexers.other', 'Redcode', ('redcode',), ('*.cw',), ()),
     'RegeditLexer': ('pygments.lexers.text', 'reg', ('registry',), ('*.reg',), ('text/x-windows-registry',)),
-    'RexxLexer': ('pygments.lexers.other', 'REXX', ('rexx', 'ARexx', 'arexx'), ('*.rexx', '*.rex', '*.rx', '*.arexx'), ('text/x-rexx',)),
+    'RexxLexer': ('pygments.lexers.other', 'Rexx', ('rexx', 'ARexx', 'arexx'), ('*.rexx', '*.rex', '*.rx', '*.arexx'), ('text/x-rexx',)),
     'RhtmlLexer': ('pygments.lexers.templates', 'RHTML', ('rhtml', 'html+erb', 'html+ruby'), ('*.rhtml',), ('text/html+ruby',)),
     'RobotFrameworkLexer': ('pygments.lexers.other', 'RobotFramework', ('RobotFramework', 'robotframework'), ('*.txt', '*.robot'), ('text/x-robotframework',)),
     'RstLexer': ('pygments.lexers.text', 'reStructuredText', ('rst', 'rest', 'restructuredtext'), ('*.rst', '*.rest'), ('text/x-rst', 'text/prs.fallenstein.rst')),
     'ScssLexer': ('pygments.lexers.web', 'SCSS', ('scss',), ('*.scss',), ('text/x-scss',)),
     'ShellSessionLexer': ('pygments.lexers.shell', 'Shell Session', ('shell-session',), ('*.shell-session',), ('application/x-sh-session',)),
     'SmaliLexer': ('pygments.lexers.dalvik', 'Smali', ('smali',), ('*.smali',), ('text/smali',)),
-    'SmalltalkLexer': ('pygments.lexers.other', 'Smalltalk', ('smalltalk', 'squeak'), ('*.st',), ('text/x-smalltalk',)),
+    'SmalltalkLexer': ('pygments.lexers.other', 'Smalltalk', ('smalltalk', 'squeak', 'st'), ('*.st',), ('text/x-smalltalk',)),
     'SmartyLexer': ('pygments.lexers.templates', 'Smarty', ('smarty',), ('*.tpl',), ('application/x-smarty',)),
     'SnobolLexer': ('pygments.lexers.other', 'Snobol', ('snobol',), ('*.snobol',), ('text/x-snobol',)),
     'SourcePawnLexer': ('pygments.lexers.other', 'SourcePawn', ('sp',), ('*.sp',), ('text/x-sourcepawn',)),
-    'SourcesListLexer': ('pygments.lexers.text', 'Debian Sourcelist', ('sourceslist', 'sources.list'), ('sources.list',), ()),
+    'SourcesListLexer': ('pygments.lexers.text', 'Debian Sourcelist', ('sourceslist', 'sources.list', 'debsources'), ('sources.list',), ()),
     'SqlLexer': ('pygments.lexers.sql', 'SQL', ('sql',), ('*.sql',), ('text/x-sql',)),
     'SqliteConsoleLexer': ('pygments.lexers.sql', 'sqlite3con', ('sqlite3',), ('*.sqlite3-console',), ('text/x-sqlite3-console',)),
     'SquidConfLexer': ('pygments.lexers.text', 'SquidConf', ('squidconf', 'squid.conf', 'squid'), ('squid.conf',), ('text/x-squidconf',)),
     'SspLexer': ('pygments.lexers.templates', 'Scalate Server Page', ('ssp',), ('*.ssp',), ('application/x-ssp',)),
     'StanLexer': ('pygments.lexers.math', 'Stan', ('stan',), ('*.stan',), ()),
+    'SwigLexer': ('pygments.lexers.compiled', 'SWIG', ('Swig', 'swig'), ('*.swg', '*.i'), ('text/swig',)),
     'SystemVerilogLexer': ('pygments.lexers.hdl', 'systemverilog', ('systemverilog', 'sv'), ('*.sv', '*.svh'), ('text/x-systemverilog',)),
     'TclLexer': ('pygments.lexers.agile', 'Tcl', ('tcl',), ('*.tcl',), ('text/x-tcl', 'text/x-script.tcl', 'application/x-tcl')),
     'TcshLexer': ('pygments.lexers.shell', 'Tcsh', ('tcsh', 'csh'), ('*.tcsh', '*.csh'), ('application/x-csh',)),
     'XQueryLexer': ('pygments.lexers.web', 'XQuery', ('xquery', 'xqy', 'xq', 'xql', 'xqm'), ('*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm'), ('text/xquery', 'application/xquery')),
     'XmlDjangoLexer': ('pygments.lexers.templates', 'XML+Django/Jinja', ('xml+django', 'xml+jinja'), (), ('application/xml+django', 'application/xml+jinja')),
     'XmlErbLexer': ('pygments.lexers.templates', 'XML+Ruby', ('xml+erb', 'xml+ruby'), (), ('application/xml+ruby',)),
-    'XmlLexer': ('pygments.lexers.web', 'XML', ('xml',), ('*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl'), ('text/xml', 'application/xml', 'image/svg+xml', 'application/rss+xml', 'application/atom+xml')),
+    'XmlLexer': ('pygments.lexers.web', 'XML', ('xml',), ('*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl', '*.wsf'), ('text/xml', 'application/xml', 'image/svg+xml', 'application/rss+xml', 'application/atom+xml')),
     'XmlPhpLexer': ('pygments.lexers.templates', 'XML+PHP', ('xml+php',), (), ('application/xml+php',)),
     'XmlSmartyLexer': ('pygments.lexers.templates', 'XML+Smarty', ('xml+smarty',), (), ('application/xml+smarty',)),
     'XsltLexer': ('pygments.lexers.web', 'XSLT', ('xslt',), ('*.xsl', '*.xslt', '*.xpl'), ('application/xsl+xml', 'application/xslt+xml')),

pygments/lexers/agile.py

              r'exception occurred:\n\n', Generic.Traceback),
             (r'^The above exception was the direct cause of the '
              r'following exception:\n\n', Generic.Traceback),
+            (r'^(?=  File "[^"]+", line \d+)', Generic.Traceback, 'intb'),
         ],
         'intb': [
             (r'^(  File )("[^"]+")(, line )(\d+)(, in )(.+)(\n)',
              bygroups(Text, Name.Builtin, Text, Number, Text, Name, Text)),
+            (r'^(  File )("[^"]+")(, line )(\d+)(\n)',
+             bygroups(Text, Name.Builtin, Text, Number, Text)),
             (r'^(    )(.+)(\n)',
              bygroups(Text, using(Python3Lexer), Text)),
             (r'^([ \t]*)(\.\.\.)(\n)',
             (r":'(\\\\|\\'|[^'])*'", String.Symbol),
             (r"'(\\\\|\\'|[^'])*'", String.Single),
             (r':"', String.Symbol, 'simple-sym'),
-            (r'([a-zA-Z_][a-zA-Z0-9]*)(:)',
+            (r'([a-zA-Z_][a-zA-Z0-9]*)(:)(?!:)',
              bygroups(String.Symbol, Punctuation)),  # Since Ruby 1.9
             (r'"', String.Double, 'simple-string'),
             (r'(?<!\.)`', String.Backtick, 'simple-backtick'),
 class Perl6Lexer(ExtendedRegexLexer):
     """
     For `Perl 6 <http://www.perl6.org>`_ source code.
+
+    *New in Pygments 1.7.*
     """
 
     name      = 'Perl6'

pygments/lexers/asm.py

     For Gas (AT&T) assembly code.
     """
     name = 'GAS'
-    aliases = ['gas']
+    aliases = ['gas', 'asm']
     filenames = ['*.s', '*.S']
     mimetypes = ['text/x-gas']
 

pygments/lexers/compiled.py

            'FortranLexer', 'GLShaderLexer', 'PrologLexer', 'CythonLexer',
            'ValaLexer', 'OocLexer', 'GoLexer', 'FelixLexer', 'AdaLexer',
            'Modula2Lexer', 'BlitzMaxLexer', 'BlitzBasicLexer', 'NimrodLexer',
-           'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer',
+           'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer', 'SwigLexer',
            'DylanLidLexer', 'DylanConsoleLexer', 'CobolLexer',
            'CobolFreeformatLexer', 'LogosLexer', 'ClayLexer']
 
         return 0.1
 
 
+class SwigLexer(CppLexer):
+    """
+    For `SWIG <http://www.swig.org/>`_ source code.
+
+    *New in Pygments 1.7.*
+    """
+    name = 'SWIG'
+    aliases = ['Swig', 'swig']
+    filenames = ['*.swg', '*.i']
+    mimetypes = ['text/swig']
+    priority = 0.04 # Lower than C/C++ and Objective C/C++
+
+    tokens = {
+        'statements': [
+            (r'(%[a-z_][a-z0-9_]*)', Name.Function), # SWIG directives
+            ('\$\**\&?[a-zA-Z0-9_]+', Name), # Special variables
+            (r'##*[a-zA-Z_][a-zA-Z0-9_]*', Comment.Preproc), # Stringification / additional preprocessor directives
+            inherit,
+         ],
+    }
+
+    # This is a far from complete set of SWIG directives
+    swig_directives = (
+        # Most common directives
+        '%apply', '%define', '%director', '%enddef', '%exception', '%extend',
+        '%feature', '%fragment', '%ignore', '%immutable', '%import', '%include',
+        '%inline', '%insert', '%module', '%newobject', '%nspace', '%pragma',
+        '%rename', '%shared_ptr', '%template', '%typecheck', '%typemap',
+        # Less common directives
+        '%arg', '%attribute', '%bang', '%begin', '%callback', '%catches', '%clear',
+        '%constant', '%copyctor', '%csconst', '%csconstvalue', '%csenum',
+        '%csmethodmodifiers', '%csnothrowexception', '%default', '%defaultctor',
+        '%defaultdtor', '%defined', '%delete', '%delobject', '%descriptor',
+        '%exceptionclass', '%exceptionvar', '%extend_smart_pointer', '%fragments',
+        '%header', '%ifcplusplus', '%ignorewarn', '%implicit', '%implicitconv',
+        '%init', '%javaconst', '%javaconstvalue', '%javaenum', '%javaexception',
+        '%javamethodmodifiers', '%kwargs', '%luacode', '%mutable', '%naturalvar',
+        '%nestedworkaround', '%perlcode', '%pythonabc', '%pythonappend',
+        '%pythoncallback', '%pythoncode', '%pythondynamic', '%pythonmaybecall',
+        '%pythonnondynamic', '%pythonprepend', '%refobject', '%shadow', '%sizeof',
+        '%trackobjects', '%types', '%unrefobject', '%varargs', '%warn', '%warnfilter')
+
+    def analyse_text(text):
+        rv = 0.1 # Same as C/C++
+        # Search for SWIG directives, which are conventionally at the beginning of
+        # a line. The probability of them being within a line is low, so let another
+        # lexer win in this case.
+        matches = re.findall(r'^\s*(%[a-z_][a-z0-9_]*)', text, re.M)
+        for m in matches:
+            if m in SwigLexer.swig_directives:
+                rv = 0.98
+                break
+            else:
+                rv = 0.91 # Fraction higher than MatlabLexer
+        return rv
+
+
 class ECLexer(CLexer):
     """
     For eC source code with preprocessor directives.
     """
     For `nesC <https://github.com/tinyos/nesc>`_ source code with preprocessor
     directives.
+
+    *New in Pygments 1.7.*
     """
     name = 'nesC'
     aliases = ['nesc']
                  ('#pop', 'oc_classname')),
                 (r'(@class|@protocol)(\s+)', bygroups(Keyword, Text),
                  ('#pop', 'oc_forward_classname')),
+                # @ can also prefix other expressions like @{...} or @(...)
+                (r'@', Punctuation),
                 inherit,
             ],
             'oc_classname' : [
             (r'^#.*', Comment.Single),
             (r'/\*', Comment.Multiline, 'nested-comment'),
             (r'%.*', Comment.Single),
-            (r'[0-9]+', Number),
+            # character literal
+            (r'0\'.', String.Char),
+            (r'0b[01]+', Number.Bin),
+            (r'0o[0-7]+', Number.Oct),
+            (r'0x[0-9a-fA-F]+', Number.Hex),
+            # literal with prepended base
+            (r'\d\d?\'[a-zA-Z0-9]+', Number.Integer),
+            (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
+            (r'\d+', Number.Integer),
             (r'[\[\](){}|.,;!]', Punctuation),
             (r':-|-->', Punctuation),
             (r'"(?:\\x[0-9a-fA-F]+\\|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|'
     """
 
     name = 'Cython'
-    aliases = ['cython', 'pyx']
+    aliases = ['cython', 'pyx', 'pyrex']
     filenames = ['*.pyx', '*.pxd', '*.pxi']
     mimetypes = ['text/x-cython', 'application/x-cython']
 
 class BlitzBasicLexer(RegexLexer):
     """
     For `BlitzBasic <http://blitzbasic.com>`_ source code.
+
+    *New in Pygments 1.7.*
     """
 
     name = 'BlitzBasic'

pygments/lexers/functional.py

     *New in Pygments 0.9.*
     """
     name = 'Common Lisp'
-    aliases = ['common-lisp', 'cl']
+    aliases = ['common-lisp', 'cl', 'lisp']
     filenames = ['*.cl', '*.lisp', '*.el']  # use for Elisp too
     mimetypes = ['text/x-common-lisp']
 
     *New in Pygments 0.9.*
     """
     name = 'Literate Haskell'
-    aliases = ['lhs', 'literate-haskell']
+    aliases = ['lhs', 'literate-haskell', 'lhaskell']
     filenames = ['*.lhs']
     mimetypes = ['text/x-literate-haskell']
 
 
 class KokaLexer(RegexLexer):
     """
-    Lexer for the `Koka <http://research.microsoft.com/en-us/projects/koka/>`_
+    Lexer for the `Koka <http://koka.codeplex.com>`_
     language.
 
     *New in Pygments 1.6.*
     mimetypes = ['text/x-koka']
 
     keywords = [
-        'infix', 'infixr', 'infixl', 'prefix', 'postfix',
+        'infix', 'infixr', 'infixl',
         'type', 'cotype', 'rectype', 'alias',
         'struct', 'con',
         'fun', 'function', 'val', 'var',
     sboundary = '(?!'+symbols+')'
 
     # name boundary: a keyword should not be followed by any of these
-    boundary = '(?![a-zA-Z0-9_\\-])'
+    boundary = '(?![\w/])'
+
+    # koka token abstractions
+    tokenType = Name.Attribute
+    tokenTypeDef = Name.Class
+    tokenConstructor = Generic.Emph
 
     # main lexer
     tokens = {
             include('whitespace'),
 
             # go into type mode
-            (r'::?' + sboundary, Keyword.Type, 'type'),
-            (r'alias' + boundary, Keyword, 'alias-type'),
-            (r'struct' + boundary, Keyword, 'struct-type'),
-            (r'(%s)' % '|'.join(typeStartKeywords) + boundary, Keyword, 'type'),
+            (r'::?' + sboundary, tokenType, 'type'),
+            (r'(alias)(\s+)([a-z]\w*)?', bygroups(Keyword, Text, tokenTypeDef),
+             'alias-type'),
+            (r'(struct)(\s+)([a-z]\w*)?', bygroups(Keyword, Text, tokenTypeDef),
+             'struct-type'),
+            ((r'(%s)' % '|'.join(typeStartKeywords)) +
+             r'(\s+)([a-z]\w*)?', bygroups(Keyword, Text, tokenTypeDef),
+             'type'),
 
             # special sequences of tokens (we use ?: for non-capturing group as
             # required by 'bygroups')
-            (r'(module)(\s*)((?:interface)?)(\s*)'
-             r'((?:[a-z](?:[a-zA-Z0-9_]|\-[a-zA-Z])*\.)*'
-             r'[a-z](?:[a-zA-Z0-9_]|\-[a-zA-Z])*)',
-             bygroups(Keyword, Text, Keyword, Text, Name.Namespace)),
-            (r'(import)(\s+)((?:[a-z](?:[a-zA-Z0-9_]|\-[a-zA-Z])*\.)*[a-z]'
-             r'(?:[a-zA-Z0-9_]|\-[a-zA-Z])*)(\s*)((?:as)?)'
-             r'((?:[A-Z](?:[a-zA-Z0-9_]|\-[a-zA-Z])*)?)',
-             bygroups(Keyword, Text, Name.Namespace, Text, Keyword,
-                      Name.Namespace)),
+            (r'(module)(\s+)(interface\s+)?((?:[a-z]\w*/)*[a-z]\w*)',
+             bygroups(Keyword, Text, Keyword, Name.Namespace)),
+            (r'(import)(\s+)((?:[a-z]\w*/)*[a-z]\w*)'
+             r'(?:(\s*)(=)(\s*)((?:qualified\s*)?)'
+             r'((?:[a-z]\w*/)*[a-z]\w*))?',
+             bygroups(Keyword, Text, Name.Namespace, Text, Keyword, Text,
+                      Keyword, Name.Namespace)),
+
+            (r'(^(?:(?:public|private)\s*)?(?:function|fun|val))'
+             r'(\s+)([a-z]\w*|\((?:' + symbols + r'|/)\))',
+             bygroups(Keyword, Text, Name.Function)),
+            (r'(^(?:(?:public|private)\s*)?external)(\s+)(inline\s+)?'
+             r'([a-z]\w*|\((?:' + symbols + r'|/)\))',
+             bygroups(Keyword, Text, Keyword, Name.Function)),
 
             # keywords
             (r'(%s)' % '|'.join(typekeywords) + boundary, Keyword.Type),
             (r'(%s)' % '|'.join(keywords) + boundary, Keyword),
             (r'(%s)' % '|'.join(builtin) + boundary, Keyword.Pseudo),
-            (r'::|:=|\->|[=\.:]' + sboundary, Keyword),
-            (r'\-' + sboundary, Generic.Strong),
+            (r'::?|:=|\->|[=\.]' + sboundary, Keyword),
 
             # names
-            (r'[A-Z]([a-zA-Z0-9_]|\-[a-zA-Z])*(?=\.)', Name.Namespace),
-            (r'[A-Z]([a-zA-Z0-9_]|\-[a-zA-Z])*(?!\.)', Name.Class),
-            (r'[a-z]([a-zA-Z0-9_]|\-[a-zA-Z])*', Name),
-            (r'_([a-zA-Z0-9_]|\-[a-zA-Z])*', Name.Variable),
+            (r'((?:[a-z]\w*/)*)([A-Z]\w*)',
+             bygroups(Name.Namespace, tokenConstructor)),
+            (r'((?:[a-z]\w*/)*)([a-z]\w*)', bygroups(Name.Namespace, Name)),
+            (r'((?:[a-z]\w*/)*)(\((?:' + symbols + r'|/)\))',
+             bygroups(Name.Namespace, Name)),
+            (r'_\w*', Name.Variable),
 
             # literal string
             (r'@"', String.Double, 'litstring'),
 
             # operators
-            (symbols, Operator),
+            (symbols + "|/(?![\*/])", Operator),
             (r'`', Operator),
             (r'[\{\}\(\)\[\];,]', Punctuation),
 
 
         # type started by colon
         'type': [
-            (r'[\(\[<]', Keyword.Type, 'type-nested'),
+            (r'[\(\[<]', tokenType, 'type-nested'),
             include('type-content')
         ],
 
         # type nested in brackets: can contain parameters, comma etc.
         'type-nested': [
-            (r'[\)\]>]', Keyword.Type, '#pop'),
-            (r'[\(\[<]', Keyword.Type, 'type-nested'),
-            (r',', Keyword.Type),
-            (r'([a-z](?:[a-zA-Z0-9_]|\-[a-zA-Z])*)(\s*)(:)(?!:)',
-             bygroups(Name.Variable,Text,Keyword.Type)),  # parameter name
+            (r'[\)\]>]', tokenType, '#pop'),
+            (r'[\(\[<]', tokenType, 'type-nested'),
+            (r',', tokenType),
+            (r'([a-z]\w*)(\s*)(:)(?!:)',
+             bygroups(Name, Text, tokenType)),  # parameter name
             include('type-content')
         ],
 
             include('whitespace'),
 
             # keywords
-            (r'(%s)' % '|'.join(typekeywords) + boundary, Keyword.Type),
+            (r'(%s)' % '|'.join(typekeywords) + boundary, Keyword),
             (r'(?=((%s)' % '|'.join(keywords) + boundary + '))',
              Keyword, '#pop'),  # need to match because names overlap...
 
             # kinds
-            (r'[EPH]' + boundary, Keyword.Type),
-            (r'[*!]', Keyword.Type),
+            (r'[EPHVX]' + boundary, tokenType),
 
             # type names
-            (r'[A-Z]([a-zA-Z0-9_]|\-[a-zA-Z])*(?=\.)', Name.Namespace),
-            (r'[A-Z]([a-zA-Z0-9_]|\-[a-zA-Z])*(?!\.)', Name.Class),
-            (r'[a-z][0-9]*(?![a-zA-Z_\-])', Keyword.Type),   # Generic.Emph
-            (r'_([a-zA-Z0-9_]|\-[a-zA-Z])*', Keyword.Type),  # Generic.Emph
-            (r'[a-z]([a-zA-Z0-9_]|\-[a-zA-Z])*', Keyword.Type),
+            (r'[a-z][0-9]*(?![\w/])', tokenType ),
+            (r'_\w*', tokenType.Variable),  # Generic.Emph
+            (r'((?:[a-z]\w*/)*)([A-Z]\w*)',
+             bygroups(Name.Namespace, tokenType)),
+            (r'((?:[a-z]\w*/)*)([a-z]\w+)',
+             bygroups(Name.Namespace, tokenType)),
 
             # type keyword operators
-            (r'::|\->|[\.:|]', Keyword.Type),
+            (r'::|\->|[\.:|]', tokenType),
 
             #catchall
             (r'', Text, '#pop')
 
         # comments and literals
         'whitespace': [
+            (r'\n\s*#.*$', Comment.Preproc),
             (r'\s+', Text),
             (r'/\*', Comment.Multiline, 'comment'),
             (r'//.*$', Comment.Single)
             (r'[\'\n]', String.Char, '#pop'),
         ],
         'escape-sequence': [
-            (r'\\[abfnrtv0\\\"\'\?]', String.Escape),
+            (r'\\[nrt\\\"\']', String.Escape),
             (r'\\x[0-9a-fA-F]{2}', String.Escape),
             (r'\\u[0-9a-fA-F]{4}', String.Escape),
             # Yes, \U literals are 6 hex digits.
             (r'\\U[0-9a-fA-F]{6}', String.Escape)
         ]
     }
-

File contents unchanged.

pygments/lexers/math.py

 __all__ = ['JuliaLexer', 'JuliaConsoleLexer', 'MuPADLexer', 'MatlabLexer',
            'MatlabSessionLexer', 'OctaveLexer', 'ScilabLexer', 'NumPyLexer',
            'RConsoleLexer', 'SLexer', 'JagsLexer', 'BugsLexer', 'StanLexer',
-           'IDLLexer', 'RdLexer']
+           'IDLLexer', 'RdLexer', 'IgorLexer']
 
 
 class JuliaLexer(RegexLexer):
     }
 
     def analyse_text(text):
-        return '<-' in text
+        if re.search(r'[a-z0-9_\])\s]<-(?!-)', text):
+            return 0.11
 
 
 class BugsLexer(RegexLexer):
             return 0
 
 class StanLexer(RegexLexer):
-    """Pygments Lexer for Stan models. 
+    """Pygments Lexer for Stan models.
 
     The Stan modeling language is specified in the *Stan 1.3.0
     Modeling Language Manual* `pdf
             (r'.', Text),
             ]
         }
+
+
+class IgorLexer(RegexLexer):
+    """
+    Pygments Lexer for Igor Pro procedure files (.ipf).
+    See http://www.wavemetrics.com/ and http://www.igorexchange.com/.
+
+    *New in Pygments 1.7.*
+    """
+
+    name = 'Igor'
+    aliases = ['igor', 'igorpro']
+    filenames = ['*.ipf']
+    mimetypes = ['text/ipf']
+
+    flags = re.IGNORECASE
+
+    flowControl = [
+        'if', 'else', 'elseif', 'endif', 'for', 'endfor', 'strswitch', 'switch',
+        'case', 'endswitch', 'do', 'while', 'try', 'catch', 'endtry', 'break',
+        'continue', 'return',
+    ]
+    types = [
+        'variable', 'string', 'constant', 'strconstant', 'NVAR', 'SVAR', 'WAVE',
+        'STRUCT', 'ThreadSafe', 'function', 'end', 'static', 'macro', 'window',
+        'graph', 'Structure', 'EndStructure', 'EndMacro', 'FuncFit', 'Proc',
+        'Picture', 'Menu', 'SubMenu', 'Prompt', 'DoPrompt',
+    ]
+    operations = [
+        'Abort', 'AddFIFOData', 'AddFIFOVectData', 'AddMovieAudio',
+        'AddMovieFrame', 'APMath', 'Append', 'AppendImage',
+        'AppendLayoutObject', 'AppendMatrixContour', 'AppendText',
+        'AppendToGraph', 'AppendToLayout', 'AppendToTable', 'AppendXYZContour',
+        'AutoPositionWindow', 'BackgroundInfo', 'Beep', 'BoundingBall',
+        'BrowseURL', 'BuildMenu', 'Button', 'cd', 'Chart', 'CheckBox',
+        'CheckDisplayed', 'ChooseColor', 'Close', 'CloseMovie', 'CloseProc',
+        'ColorScale', 'ColorTab2Wave', 'Concatenate', 'ControlBar',
+        'ControlInfo', 'ControlUpdate', 'ConvexHull', 'Convolve', 'CopyFile',
+        'CopyFolder', 'CopyScales', 'Correlate', 'CreateAliasShortcut', 'Cross',
+        'CtrlBackground', 'CtrlFIFO', 'CtrlNamedBackground', 'Cursor',
+        'CurveFit', 'CustomControl', 'CWT', 'Debugger', 'DebuggerOptions',
+        'DefaultFont', 'DefaultGuiControls', 'DefaultGuiFont', 'DefineGuide',
+        'DelayUpdate', 'DeleteFile', 'DeleteFolder', 'DeletePoints',
+        'Differentiate', 'dir', 'Display', 'DisplayHelpTopic',
+        'DisplayProcedure', 'DoAlert', 'DoIgorMenu', 'DoUpdate', 'DoWindow',
+        'DoXOPIdle', 'DrawAction', 'DrawArc', 'DrawBezier', 'DrawLine',
+        'DrawOval', 'DrawPICT', 'DrawPoly', 'DrawRect', 'DrawRRect', 'DrawText',
+        'DSPDetrend', 'DSPPeriodogram', 'Duplicate', 'DuplicateDataFolder',
+        'DWT', 'EdgeStats', 'Edit', 'ErrorBars', 'Execute', 'ExecuteScriptText',
+        'ExperimentModified', 'Extract', 'FastGaussTransform', 'FastOp',
+        'FBinRead', 'FBinWrite', 'FFT', 'FIFO2Wave', 'FIFOStatus', 'FilterFIR',
+        'FilterIIR', 'FindLevel', 'FindLevels', 'FindPeak', 'FindPointsInPoly',
+        'FindRoots', 'FindSequence', 'FindValue', 'FPClustering', 'fprintf',
+        'FReadLine', 'FSetPos', 'FStatus', 'FTPDelete', 'FTPDownload',
+        'FTPUpload', 'FuncFit', 'FuncFitMD', 'GetAxis', 'GetFileFolderInfo',
+        'GetLastUserMenuInfo', 'GetMarquee', 'GetSelection', 'GetWindow',
+        'GraphNormal', 'GraphWaveDraw', 'GraphWaveEdit', 'Grep', 'GroupBox',
+        'Hanning', 'HideIgorMenus', 'HideInfo', 'HideProcedures', 'HideTools',
+        'HilbertTransform', 'Histogram', 'IFFT', 'ImageAnalyzeParticles',
+        'ImageBlend', 'ImageBoundaryToMask', 'ImageEdgeDetection',
+        'ImageFileInfo', 'ImageFilter', 'ImageFocus', 'ImageGenerateROIMask',
+        'ImageHistModification', 'ImageHistogram', 'ImageInterpolate',
+        'ImageLineProfile', 'ImageLoad', 'ImageMorphology', 'ImageRegistration',
+        'ImageRemoveBackground', 'ImageRestore', 'ImageRotate', 'ImageSave',
+        'ImageSeedFill', 'ImageSnake', 'ImageStats', 'ImageThreshold',
+        'ImageTransform', 'ImageUnwrapPhase', 'ImageWindow', 'IndexSort',
+        'InsertPoints', 'Integrate', 'IntegrateODE', 'Interp3DPath',
+        'Interpolate3D', 'KillBackground', 'KillControl', 'KillDataFolder',
+        'KillFIFO', 'KillFreeAxis', 'KillPath', 'KillPICTs', 'KillStrings',
+        'KillVariables', 'KillWaves', 'KillWindow', 'KMeans', 'Label', 'Layout',
+        'Legend', 'LinearFeedbackShiftRegister', 'ListBox', 'LoadData',
+        'LoadPackagePreferences', 'LoadPICT', 'LoadWave', 'Loess',
+        'LombPeriodogram', 'Make', 'MakeIndex', 'MarkPerfTestTime',
+        'MatrixConvolve', 'MatrixCorr', 'MatrixEigenV', 'MatrixFilter',
+        'MatrixGaussJ', 'MatrixInverse', 'MatrixLinearSolve',
+        'MatrixLinearSolveTD', 'MatrixLLS', 'MatrixLUBkSub', 'MatrixLUD',
+        'MatrixMultiply', 'MatrixOP', 'MatrixSchur', 'MatrixSolve',
+        'MatrixSVBkSub', 'MatrixSVD', 'MatrixTranspose', 'MeasureStyledText',
+        'Modify', 'ModifyContour', 'ModifyControl', 'ModifyControlList',
+        'ModifyFreeAxis', 'ModifyGraph', 'ModifyImage', 'ModifyLayout',
+        'ModifyPanel', 'ModifyTable', 'ModifyWaterfall', 'MoveDataFolder',
+        'MoveFile', 'MoveFolder', 'MoveString', 'MoveSubwindow', 'MoveVariable',
+        'MoveWave', 'MoveWindow', 'NeuralNetworkRun', 'NeuralNetworkTrain',
+        'NewDataFolder', 'NewFIFO', 'NewFIFOChan', 'NewFreeAxis', 'NewImage',
+        'NewLayout', 'NewMovie', 'NewNotebook', 'NewPanel', 'NewPath',
+        'NewWaterfall', 'Note', 'Notebook', 'NotebookAction', 'Open',
+        'OpenNotebook', 'Optimize', 'ParseOperationTemplate', 'PathInfo',
+        'PauseForUser', 'PauseUpdate', 'PCA', 'PlayMovie', 'PlayMovieAction',
+        'PlaySnd', 'PlaySound', 'PopupContextualMenu', 'PopupMenu',
+        'Preferences', 'PrimeFactors', 'Print', 'printf', 'PrintGraphs',
+        'PrintLayout', 'PrintNotebook', 'PrintSettings', 'PrintTable',
+        'Project', 'PulseStats', 'PutScrapText', 'pwd', 'Quit',
+        'RatioFromNumber', 'Redimension', 'Remove', 'RemoveContour',
+        'RemoveFromGraph', 'RemoveFromLayout', 'RemoveFromTable', 'RemoveImage',
+        'RemoveLayoutObjects', 'RemovePath', 'Rename', 'RenameDataFolder',
+        'RenamePath', 'RenamePICT', 'RenameWindow', 'ReorderImages',
+        'ReorderTraces', 'ReplaceText', 'ReplaceWave', 'Resample',
+        'ResumeUpdate', 'Reverse', 'Rotate', 'Save', 'SaveData',
+        'SaveExperiment', 'SaveGraphCopy', 'SaveNotebook',
+        'SavePackagePreferences', 'SavePICT', 'SaveTableCopy',
+        'SetActiveSubwindow', 'SetAxis', 'SetBackground', 'SetDashPattern',
+        'SetDataFolder', 'SetDimLabel', 'SetDrawEnv', 'SetDrawLayer',
+        'SetFileFolderInfo', 'SetFormula', 'SetIgorHook', 'SetIgorMenuMode',
+        'SetIgorOption', 'SetMarquee', 'SetProcessSleep', 'SetRandomSeed',
+        'SetScale', 'SetVariable', 'SetWaveLock', 'SetWindow', 'ShowIgorMenus',
+        'ShowInfo', 'ShowTools', 'Silent', 'Sleep', 'Slider', 'Smooth',
+        'SmoothCustom', 'Sort', 'SoundInRecord', 'SoundInSet',
+        'SoundInStartChart', 'SoundInStatus', 'SoundInStopChart',
+        'SphericalInterpolate', 'SphericalTriangulate', 'SplitString',
+        'sprintf', 'sscanf', 'Stack', 'StackWindows',
+        'StatsAngularDistanceTest', 'StatsANOVA1Test', 'StatsANOVA2NRTest',
+        'StatsANOVA2RMTest', 'StatsANOVA2Test', 'StatsChiTest',
+        'StatsCircularCorrelationTest', 'StatsCircularMeans',
+        'StatsCircularMoments', 'StatsCircularTwoSampleTest',
+        'StatsCochranTest', 'StatsContingencyTable', 'StatsDIPTest',
+        'StatsDunnettTest', 'StatsFriedmanTest', 'StatsFTest',
+        'StatsHodgesAjneTest', 'StatsJBTest', 'StatsKendallTauTest',
+        'StatsKSTest', 'StatsKWTest', 'StatsLinearCorrelationTest',
+        'StatsLinearRegression', 'StatsMultiCorrelationTest',
+        'StatsNPMCTest', 'StatsNPNominalSRTest', 'StatsQuantiles',
+        'StatsRankCorrelationTest', 'StatsResample', 'StatsSample',
+        'StatsScheffeTest', 'StatsSignTest', 'StatsSRTest', 'StatsTTest',
+        'StatsTukeyTest', 'StatsVariancesTest', 'StatsWatsonUSquaredTest',
+        'StatsWatsonWilliamsTest', 'StatsWheelerWatsonTest',
+        'StatsWilcoxonRankTest', 'StatsWRCorrelationTest', 'String',
+        'StructGet', 'StructPut', 'TabControl', 'Tag', 'TextBox', 'Tile',
+        'TileWindows', 'TitleBox', 'ToCommandLine', 'ToolsGrid',
+        'Triangulate3d', 'Unwrap', 'ValDisplay', 'Variable', 'WaveMeanStdv',
+        'WaveStats', 'WaveTransform', 'wfprintf', 'WignerTransform',
+        'WindowFunction',
+    ]
+    functions = [
+        'abs', 'acos', 'acosh', 'AiryA', 'AiryAD', 'AiryB', 'AiryBD', 'alog',
+        'area', 'areaXY', 'asin', 'asinh', 'atan', 'atan2', 'atanh',
+        'AxisValFromPixel', 'Besseli', 'Besselj', 'Besselk', 'Bessely', 'bessi',
+        'bessj', 'bessk', 'bessy', 'beta', 'betai', 'BinarySearch',
+        'BinarySearchInterp', 'binomial', 'binomialln', 'binomialNoise', 'cabs',
+        'CaptureHistoryStart', 'ceil', 'cequal', 'char2num', 'chebyshev',
+        'chebyshevU', 'CheckName', 'cmplx', 'cmpstr', 'conj', 'ContourZ', 'cos',
+        'cosh', 'cot', 'CountObjects', 'CountObjectsDFR', 'cpowi',
+        'CreationDate', 'csc', 'DataFolderExists', 'DataFolderRefsEqual',
+        'DataFolderRefStatus', 'date2secs', 'datetime', 'DateToJulian',
+        'Dawson', 'DDEExecute', 'DDEInitiate', 'DDEPokeString', 'DDEPokeWave',
+        'DDERequestWave', 'DDEStatus', 'DDETerminate', 'deltax', 'digamma',
+        'DimDelta', 'DimOffset', 'DimSize', 'ei', 'enoise', 'equalWaves', 'erf',
+        'erfc', 'exists', 'exp', 'expInt', 'expNoise', 'factorial', 'fakedata',
+        'faverage', 'faverageXY', 'FindDimLabel', 'FindListItem', 'floor',
+        'FontSizeHeight', 'FontSizeStringWidth', 'FresnelCos', 'FresnelSin',
+        'gamma', 'gammaInc', 'gammaNoise', 'gammln', 'gammp', 'gammq', 'Gauss',
+        'Gauss1D', 'Gauss2D', 'gcd', 'GetDefaultFontSize',
+        'GetDefaultFontStyle', 'GetKeyState', 'GetRTError', 'gnoise',
+        'GrepString', 'hcsr', 'hermite', 'hermiteGauss', 'HyperG0F1',
+        'HyperG1F1', 'HyperG2F1', 'HyperGNoise', 'HyperGPFQ', 'IgorVersion',
+        'ilim', 'imag', 'Inf', 'Integrate1D', 'interp', 'Interp2D', 'Interp3D',
+        'inverseERF', 'inverseERFC', 'ItemsInList', 'jlim', 'Laguerre',
+        'LaguerreA', 'LaguerreGauss', 'leftx', 'LegendreA', 'limit', 'ln',
+        'log', 'logNormalNoise', 'lorentzianNoise', 'magsqr', 'MandelbrotPoint',
+        'MarcumQ', 'MatrixDet', 'MatrixDot', 'MatrixRank', 'MatrixTrace', 'max',
+        'mean', 'min', 'mod', 'ModDate', 'NaN', 'norm', 'NumberByKey',
+        'numpnts', 'numtype', 'NumVarOrDefault', 'NVAR_Exists', 'p2rect',
+        'ParamIsDefault', 'pcsr', 'Pi', 'PixelFromAxisVal', 'pnt2x',
+        'poissonNoise', 'poly', 'poly2D', 'PolygonArea', 'qcsr', 'r2polar',
+        'real', 'rightx', 'round', 'sawtooth', 'ScreenResolution', 'sec',
+        'SelectNumber', 'sign', 'sin', 'sinc', 'sinh', 'SphericalBessJ',
+        'SphericalBessJD', 'SphericalBessY', 'SphericalBessYD',
+        'SphericalHarmonics', 'sqrt', 'StartMSTimer', 'StatsBetaCDF',
+        'StatsBetaPDF', 'StatsBinomialCDF', 'StatsBinomialPDF',
+        'StatsCauchyCDF', 'StatsCauchyPDF', 'StatsChiCDF', 'StatsChiPDF',
+        'StatsCMSSDCDF', 'StatsCorrelation', 'StatsDExpCDF', 'StatsDExpPDF',
+        'StatsErlangCDF', 'StatsErlangPDF', 'StatsErrorPDF', 'StatsEValueCDF',
+        'StatsEValuePDF', 'StatsExpCDF', 'StatsExpPDF', 'StatsFCDF',
+        'StatsFPDF', 'StatsFriedmanCDF', 'StatsGammaCDF', 'StatsGammaPDF',
+        'StatsGeometricCDF', 'StatsGeometricPDF', 'StatsHyperGCDF',
+        'StatsHyperGPDF', 'StatsInvBetaCDF', 'StatsInvBinomialCDF',
+        'StatsInvCauchyCDF', 'StatsInvChiCDF', 'StatsInvCMSSDCDF',
+        'StatsInvDExpCDF', 'StatsInvEValueCDF', 'StatsInvExpCDF',
+        'StatsInvFCDF', 'StatsInvFriedmanCDF', 'StatsInvGammaCDF',
+        'StatsInvGeometricCDF', 'StatsInvKuiperCDF', 'StatsInvLogisticCDF',
+        'StatsInvLogNormalCDF', 'StatsInvMaxwellCDF', 'StatsInvMooreCDF',
+        'StatsInvNBinomialCDF', 'StatsInvNCChiCDF', 'StatsInvNCFCDF',
+        'StatsInvNormalCDF', 'StatsInvParetoCDF', 'StatsInvPoissonCDF',
+        'StatsInvPowerCDF', 'StatsInvQCDF', 'StatsInvQpCDF',
+        'StatsInvRayleighCDF', 'StatsInvRectangularCDF', 'StatsInvSpearmanCDF',
+        'StatsInvStudentCDF', 'StatsInvTopDownCDF', 'StatsInvTriangularCDF',
+        'StatsInvUsquaredCDF', 'StatsInvVonMisesCDF', 'StatsInvWeibullCDF',
+        'StatsKuiperCDF', 'StatsLogisticCDF', 'StatsLogisticPDF',
+        'StatsLogNormalCDF', 'StatsLogNormalPDF', 'StatsMaxwellCDF',
+        'StatsMaxwellPDF', 'StatsMedian', 'StatsMooreCDF', 'StatsNBinomialCDF',
+        'StatsNBinomialPDF', 'StatsNCChiCDF', 'StatsNCChiPDF', 'StatsNCFCDF',
+        'StatsNCFPDF', 'StatsNCTCDF', 'StatsNCTPDF', 'StatsNormalCDF',
+        'StatsNormalPDF', 'StatsParetoCDF', 'StatsParetoPDF', 'StatsPermute',
+        'StatsPoissonCDF', 'StatsPoissonPDF', 'StatsPowerCDF',
+        'StatsPowerNoise', 'StatsPowerPDF', 'StatsQCDF', 'StatsQpCDF',
+        'StatsRayleighCDF', 'StatsRayleighPDF', 'StatsRectangularCDF',
+        'StatsRectangularPDF', 'StatsRunsCDF', 'StatsSpearmanRhoCDF',
+        'StatsStudentCDF', 'StatsStudentPDF', 'StatsTopDownCDF',
+        'StatsTriangularCDF', 'StatsTriangularPDF', 'StatsTrimmedMean',
+        'StatsUSquaredCDF', 'StatsVonMisesCDF', 'StatsVonMisesNoise',
+        'StatsVonMisesPDF', 'StatsWaldCDF', 'StatsWaldPDF', 'StatsWeibullCDF',
+        'StatsWeibullPDF', 'StopMSTimer', 'str2num', 'stringCRC', 'stringmatch',
+        'strlen', 'strsearch', 'StudentA', 'StudentT', 'sum', 'SVAR_Exists',
+        'TagVal', 'tan', 'tanh', 'ThreadGroupCreate', 'ThreadGroupRelease',
+        'ThreadGroupWait', 'ThreadProcessorCount', 'ThreadReturnValue', 'ticks',
+        'trunc', 'Variance', 'vcsr', 'WaveCRC', 'WaveDims', 'WaveExists',
+        'WaveMax', 'WaveMin', 'WaveRefsEqual', 'WaveType', 'WhichListItem',
+        'WinType', 'WNoise', 'x', 'x2pnt', 'xcsr', 'y', 'z', 'zcsr', 'ZernikeR',
+    ]
+    functions += [
+        'AddListItem', 'AnnotationInfo', 'AnnotationList', 'AxisInfo',
+        'AxisList', 'CaptureHistory', 'ChildWindowList', 'CleanupName',
+        'ContourInfo', 'ContourNameList', 'ControlNameList', 'CsrInfo',
+        'CsrWave', 'CsrXWave', 'CTabList', 'DataFolderDir', 'date',
+        'DDERequestString', 'FontList', 'FuncRefInfo', 'FunctionInfo',
+        'FunctionList', 'FunctionPath', 'GetDataFolder', 'GetDefaultFont',
+        'GetDimLabel', 'GetErrMessage', 'GetFormula',
+        'GetIndependentModuleName', 'GetIndexedObjName', 'GetIndexedObjNameDFR',
+        'GetRTErrMessage', 'GetRTStackInfo', 'GetScrapText', 'GetUserData',
+        'GetWavesDataFolder', 'GrepList', 'GuideInfo', 'GuideNameList', 'Hash',
+        'IgorInfo', 'ImageInfo', 'ImageNameList', 'IndexedDir', 'IndexedFile',
+        'JulianToDate', 'LayoutInfo', 'ListMatch', 'LowerStr', 'MacroList',
+        'NameOfWave', 'note', 'num2char', 'num2istr', 'num2str',
+        'OperationList', 'PadString', 'ParseFilePath', 'PathList', 'PICTInfo',
+        'PICTList', 'PossiblyQuoteName', 'ProcedureText', 'RemoveByKey',
+        'RemoveEnding', 'RemoveFromList', 'RemoveListItem',
+        'ReplaceNumberByKey', 'ReplaceString', 'ReplaceStringByKey',
+        'Secs2Date', 'Secs2Time', 'SelectString', 'SortList',
+        'SpecialCharacterInfo', 'SpecialCharacterList', 'SpecialDirPath',
+        'StringByKey', 'StringFromList', 'StringList', 'StrVarOrDefault',
+        'TableInfo', 'TextFile', 'ThreadGroupGetDF', 'time', 'TraceFromPixel',
+        'TraceInfo', 'TraceNameList', 'UniqueName', 'UnPadString', 'UpperStr',
+        'VariableList', 'WaveInfo', 'WaveList', 'WaveName', 'WaveUnits',
+        'WinList', 'WinName', 'WinRecreation', 'XWaveName',
+        'ContourNameToWaveRef', 'CsrWaveRef', 'CsrXWaveRef',
+        'ImageNameToWaveRef', 'NewFreeWave', 'TagWaveRef', 'TraceNameToWaveRef',
+        'WaveRefIndexed', 'XWaveRefFromTrace', 'GetDataFolderDFR',
+        'GetWavesDataFolderDFR', 'NewFreeDataFolder', 'ThreadGroupGetDFR',
+    ]
+
+    tokens = {
+        'root': [
+            (r'//.*$', Comment.Single),
+            (r'"([^"\\]|\\.)*"', String),
+            # Flow Control.
+            (r'\b(%s)\b' % '|'.join(flowControl), Keyword),
+            # Types.
+            (r'\b(%s)\b' % '|'.join(types), Keyword.Type),
+            # Built-in operations.
+            (r'\b(%s)\b' % '|'.join(operations), Name.Class),
+            # Built-in functions.
+            (r'\b(%s)\b' % '|'.join(functions), Name.Function),
+            # Compiler directives.
+            (r'^#(include|pragma|define|ifdef|ifndef|endif)',
+             Name.Decorator),
+            (r'[^a-zA-Z"/]+', Text),
+            (r'.', Text),
+        ],
+    }

pygments/lexers/other.py

 from pygments.lexer import RegexLexer, include, bygroups, using, \
      this, combined, ExtendedRegexLexer
 from pygments.token import Error, Punctuation, Literal, Token, \
+<<<<<<< local
      Text, Comment, Operator, Keyword, Name, String, Number, Generic, Other, \
+=======
+     Text, Comment, Operator, Keyword, Name, String, Number, Generic, \
+>>>>>>> other
      Whitespace
 from pygments.util import get_bool_opt
 from pygments.lexers.web import HtmlLexer
     """
     name = 'MOOCode'
     filenames = ['*.moo']
-    aliases = ['moocode']
+    aliases = ['moocode', 'moo']
     mimetypes = ['text/x-moocode']
 
     tokens = {
     """
     name = 'Smalltalk'
     filenames = ['*.st']
-    aliases = ['smalltalk', 'squeak']
+    aliases = ['smalltalk', 'squeak', 'st']
     mimetypes = ['text/x-smalltalk']
 
     tokens = {
     *New in Pygments 1.4.*
     """
     name = 'PostScript'
-    aliases = ['postscript']
+    aliases = ['postscript', 'postscr']
     filenames = ['*.ps', '*.eps']
     mimetypes = ['application/postscript']
 
     *New in Pygments 1.4.*
     """
     name = 'autohotkey'
-    aliases = ['ahk']
+    aliases = ['ahk', 'autohotkey']
     filenames = ['*.ahk', '*.ahkl']
     mimetypes = ['text/x-autohotkey']
 
     """
 
     name = 'Protocol Buffer'
-    aliases = ['protobuf']
+    aliases = ['protobuf', 'proto']
     filenames = ['*.proto']
 
     tokens = {
 
         if FocusMasterLexer._HEADER_PATTERN.match(text):
             result = 0.8
-        
+
         assert 0.0 <= result <= 1.0
         return result
 
 
         if FocusAccessLexer._HEADER_PATTERN.match(text):
             result = 0.8
-        
+
         assert 0.0 <= result <= 1.0
         return result
 
 
     *New in Pygments 1.7.*
     """
-    name = 'REXX'
+    name = 'Rexx'
     aliases = ['rexx', 'ARexx', 'arexx']
     filenames = ['*.rexx', '*.rex', '*.rx', '*.arexx']
     mimetypes = ['text/x-rexx']
             (r"'", String, 'string_single'),
             (r'[0-9]+(\.[0-9]+)?(e[+-]?[0-9])?', Number),
             (r'([a-z_][a-z0-9_]*)(\s*)(:)(\s*)(procedure)\b',
-             bygroups(Name.Function, Whitespace, Operator, Whitespace, Keyword.Declaration)),
+             bygroups(Name.Function, Whitespace, Operator, Whitespace,
+                      Keyword.Declaration)),
             (r'([a-z_][a-z0-9_]*)(\s*)(:)',
              bygroups(Name.Label, Whitespace, Operator)),
             include('function'),
              r'max|min|overlay|pos|queued|random|reverse|right|sign|'
              r'sourceline|space|stream|strip|substr|subword|symbol|time|'
              r'trace|translate|trunc|value|verify|word|wordindex|'
-             r'wordlength|wordpos|words|x2b|x2c|x2d|xrange)(\s*)([(])',
+             r'wordlength|wordpos|words|x2b|x2c|x2d|xrange)(\s*)(\()',
              bygroups(Name.Builtin, Whitespace, Operator)),
         ],
         'keyword': [
              ur'¬>>|¬>|¬|\.|,)', Operator),
         ],
         'string_double': [
-            (r'[^"\n]', String),
+            (r'[^"\n]+', String),
             (r'""', String),
             (r'"', String, '#pop'),
-            (r'', Text, '#pop'),  # Linefeed also terminates strings.
+            (r'\n', Text, '#pop'),  # Stray linefeed also terminates strings.
         ],
         'string_single': [
             (r'[^\'\n]', String),
             (r'\'\'', String),
             (r'\'', String, '#pop'),
-            (r'', Text, '#pop'),  # Linefeed also terminates strings.
+            (r'\n', Text, '#pop'),  # Stray linefeed also terminates strings.
         ],
         'comment': [
+            (r'[^*]+', Comment.Multiline),
             (r'\*/', Comment.Multiline, '#pop'),
-            (r'(.|\n)', Comment.Multiline),
+            (r'\*', Comment.Multiline),
         ]
     }
 
-    _ADDRESS_COMMAND_REGEX = re.compile(r'\s*address\s+command\b', re.IGNORECASE)
-    _ADDRESS_REGEX = re.compile(r'\s*address\s+', re.IGNORECASE)
-    _DO_WHILE_REGEX = re.compile(r'\s*do\s+while\b', re.IGNORECASE)
-    _IF_THEN_DO_REGEX = re.compile(r'\s*if\b.+\bthen\s+do\s*$', re.IGNORECASE)
-    _PROCEDURE_REGEX = re.compile(r'([a-z_][a-z0-9_]*)(\s*)(:)(\s*)(procedure)\b', re.IGNORECASE)
-    _ELSE_DO_REGEX = re.compile(r'\s*else\s+do\s*$', re.IGNORECASE)
-    _PARSE_ARG_REGEX = re.compile(r'\s*parse\s+(upper\s+)?(arg|value)\b', re.IGNORECASE)
-    _REGEXS = [
-        _ADDRESS_COMMAND_REGEX,
-        _ADDRESS_REGEX,
-        _DO_WHILE_REGEX,
-        _ELSE_DO_REGEX,
-        _IF_THEN_DO_REGEX,
-        _PROCEDURE_REGEX,
-        _PARSE_ARG_REGEX,
-    ]
+    _c = lambda s: re.compile(s, re.MULTILINE)
+    _ADDRESS_COMMAND_PATTERN = _c(r'^\s*address\s+command\b')
+    _ADDRESS_PATTERN = _c(r'^\s*address\s+')
+    _DO_WHILE_PATTERN = _c(r'^\s*do\s+while\b')
+    _IF_THEN_DO_PATTERN = _c(r'^\s*if\b.+\bthen\s+do\s*$')
+    _PROCEDURE_PATTERN = _c(r'^\s*([a-z_][a-z0-9_]*)(\s*)(:)(\s*)(procedure)\b')
+    _ELSE_DO_PATTERN = _c(r'\belse\s+do\s*$')
+    _PARSE_ARG_PATTERN = _c(r'^\s*parse\s+(upper\s+)?(arg|value)\b')
+    PATTERNS_AND_WEIGHTS = (
+        (_ADDRESS_COMMAND_PATTERN, 0.2),
+        (_ADDRESS_PATTERN, 0.05),
+        (_DO_WHILE_PATTERN, 0.1),
+        (_ELSE_DO_PATTERN, 0.1),
+        (_IF_THEN_DO_PATTERN, 0.1),
+        (_PROCEDURE_PATTERN, 0.5),
+        (_PARSE_ARG_PATTERN, 0.2),
+    )
 
     def analyse_text(text):
         """
-        Check for inital comment.
+        Check for inital comment and patterns that distinguish Rexx from other
+        C-like languages.
         """
-        result = 0.0
         if re.search(r'/\*\**\s*rexx', text, re.IGNORECASE):
             # Header matches MVS Rexx requirements, this is certainly a Rexx
             # script.
-            result = 1.0
+            return 1.0
         elif text.startswith('/*'):
             # Header matches general Rexx requirements; the source code might
             # still be any language using C comments such as C++, C# or Java.
-            result = 0.01
-
-            # Check if lines match certain regular expressions and
-            # collect the respective counts in a dictionary.
-            regexCount = len(RexxLexer._REGEXS)
-            regexToCountMap = {}
-            for regex in RexxLexer._REGEXS:
-                regexToCountMap[regex] = 0
-            for line in (text.split('\n'))[1:]:
-                regexIndex = 0
-                lineHasAnyRegex = False
-                while not lineHasAnyRegex and (regexIndex < regexCount):
-                    regexToCheck = RexxLexer._REGEXS[regexIndex]
-                    if regexToCheck.match(line) is not None:
-                        regexToCountMap[regexToCheck] = \
-                            regexToCountMap[regexToCheck] + 1
-                        lineHasAnyRegex = True
-                    else:
-                        regexIndex += 1
-            # Evaluate the findings.
-            if regexToCountMap[RexxLexer._PROCEDURE_REGEX] > 0:
-                result += 0.5
-            elif regexToCountMap[RexxLexer._ADDRESS_COMMAND_REGEX] > 0:
-                result += 0.2
-            elif regexToCountMap[RexxLexer._ADDRESS_REGEX] > 0:
-                result += 0.05
-            if regexToCountMap[RexxLexer._DO_WHILE_REGEX] > 0:
-                result += 0.1
-            if regexToCountMap[RexxLexer._ELSE_DO_REGEX] > 0:
-                result += 0.1
-            if regexToCountMap[RexxLexer._PARSE_ARG_REGEX] > 0:
-                result += 0.2
-            if regexToCountMap[RexxLexer._IF_THEN_DO_REGEX] > 0:
-                result += 0.1
-            result = min(result, 1.0)
-        assert 0.0 <= result <= 1.0
-        return result
+            lowerText = text.lower()
+            result = sum(weight
+                         for (pattern, weight) in RexxLexer.PATTERNS_AND_WEIGHTS
+                         if pattern.search(lowerText)) + 0.01
+            return min(result, 1.0)

pygments/lexers/shell.py

         'data': [
             (r'(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
             (r"(?s)\$?'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
-            (r';', Text),
+            (r';', Punctuation),
+            (r'&', Punctuation),
+            (r'\|', Punctuation),
             (r'\s+', Text),
-            (r'[^=\s\[\]{}()$"\'`\\<]+', Text),
+            (r'[^=\s\[\]{}()$"\'`\\<&|;]+', Text),
             (r'\d+(?= |\Z)', Number),
             (r'\$#?(\w+|.)', Name.Variable),
             (r'<', Text),
     *New in Pygments 0.7.*
     """
     name = 'Batchfile'
-    aliases = ['bat']
+    aliases = ['bat', 'dosbatch', 'winbatch']
     filenames = ['*.bat', '*.cmd']
     mimetypes = ['application/x-dos-batch']
 
         'root': [
             # we need to count pairs of parentheses for correct highlight
             # of '$(...)' blocks in strings
-            (r'\(', Punctuation, '#push'),
-            (r'\)', Punctuation, '#pop'),
+            (r'\(', Punctuation, 'child'),
             (r'\s+', Text),
             (r'^(\s*#[#\s]*)(\.(?:%s))([^\n]*$)' % '|'.join(commenthelp),
              bygroups(Comment, String.Doc, Comment)),
             (r'\w+', Name),
             (r'[.,;@{}\[\]$()=+*/\\&%!~?^`|<>-]|::', Punctuation),
         ],
+        'child': [
+            (r'\)', Punctuation, '#pop'),
+            include('root'),
+        ],
         'multline': [
             (r'[^#&.]+', Comment.Multiline),
             (r'#(>|&gt;)', Comment.Multiline, '#pop'),
         'string': [
             (r"`[0abfnrtv'\"\$]", String.Escape),
             (r'[^$`"]+', String.Double),
-            (r'\$\(', Punctuation, 'root'),
+            (r'\$\(', Punctuation, 'child'),
             (r'""', String.Double),
             (r'[`$]', String.Double),
             (r'"', String.Double, '#pop'),
         ],
         'heredoc-double': [
             (r'\n"@', String.Heredoc, '#pop'),
-            (r'\$\(', Punctuation, 'root'),
+            (r'\$\(', Punctuation, 'child'),
             (r'[^@\n]+"]', String.Heredoc),
             (r".", String.Heredoc),
         ]

pygments/lexers/sql.py

              r'DIAGNOSTICS|DICTIONARY|DISCONNECT|DISPATCH|DISTINCT|DO|'
              r'DOMAIN|DROP|DYNAMIC|DYNAMIC_FUNCTION|DYNAMIC_FUNCTION_CODE|'
              r'EACH|ELSE|ENCODING|ENCRYPTED|END|END-EXEC|EQUALS|ESCAPE|EVERY|'
-             r'EXCEPT|ESCEPTION|EXCLUDING|EXCLUSIVE|EXEC|EXECUTE|EXISTING|'
+             r'EXCEPTION|EXCEPT|EXCLUDING|EXCLUSIVE|EXEC|EXECUTE|EXISTING|'
              r'EXISTS|EXPLAIN|EXTERNAL|EXTRACT|FALSE|FETCH|FINAL|FIRST|FOR|'
              r'FORCE|FOREIGN|FORTRAN|FORWARD|FOUND|FREE|FREEZE|FROM|FULL|'
              r'FUNCTION|G|GENERAL|GENERATED|GET|GLOBAL|GO|GOTO|GRANT|GRANTED|'

pygments/lexers/templates.py

     """
 
     name = 'HTML+Cheetah'
-    aliases = ['html+cheetah', 'html+spitfire']
+    aliases = ['html+cheetah', 'html+spitfire', 'htmlcheetah']
     mimetypes = ['text/html+cheetah', 'text/html+spitfire']
 
     def __init__(self, **options):
     """
 
     name = 'HTML+Django/Jinja'
-    aliases = ['html+django', 'html+jinja']
+    aliases = ['html+django', 'html+jinja', 'htmldjango']
     alias_filenames = ['*.html', '*.htm', '*.xhtml']
     mimetypes = ['text/html+django', 'text/html+jinja']
 

pygments/lexers/text.py

            'RstLexer', 'VimLexer', 'GettextLexer', 'SquidConfLexer',
            'DebianControlLexer', 'DarcsPatchLexer', 'YamlLexer',
            'LighttpdConfLexer', 'NginxConfLexer', 'CMakeLexer', 'HttpLexer',
-           'PyPyLogLexer', 'RegeditLexer', 'HxmlLexer']
+           'PyPyLogLexer', 'RegeditLexer', 'HxmlLexer', 'EbnfLexer']
 
 
 class IniLexer(RegexLexer):
     """
 
     name = 'INI'
-    aliases = ['ini', 'cfg']
+    aliases = ['ini', 'cfg', 'dosini']
     filenames = ['*.ini', '*.cfg']
     mimetypes = ['text/x-ini']
 
     """
 
     name = 'Properties'
-    aliases = ['properties']
+    aliases = ['properties', 'jproperties']
     filenames = ['*.properties']
     mimetypes = ['text/x-java-properties']
 
     """
 
     name = 'Debian Sourcelist'
-    aliases = ['sourceslist', 'sources.list']
+    aliases = ['sourceslist', 'sources.list', 'debsources']
     filenames = ['sources.list']
     mimetype = ['application/x-debian-sourceslist']
 
     *New in Pygments 0.9.*
     """
     name = 'Debian Control file'
-    aliases = ['control']
+    aliases = ['control', 'debcontrol']
     filenames = ['control']
 
     tokens = {
             # r'VTK_MAKE_INSTANTIATOR|VTK_WRAP_JAVA|VTK_WRAP_PYTHON|'
             # r'VTK_WRAP_TCL|WHILE|WRITE_FILE|'
             # r'COUNTARGS)\b', Name.Builtin, 'args'),
-            (r'\b([A-Za-z_]+)([ \t]*)(\()', bygroups(Name.Builtin, Text,
+            (r'\b(\w+)([ \t]*)(\()', bygroups(Name.Builtin, Text,
                                                      Punctuation), 'args'),
             include('keywords'),
             include('ws')
             (r'#.*', Comment.Single)
         ]
     }
+
+
+class EbnfLexer(RegexLexer):
+    """
+    Lexer for `ISO/IEC 14977 EBNF
+    <http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form>`_
+    grammars.
+
+    *New in Pygments 1.7.*
+    """
+
+    name = 'EBNF'
+    aliases = ['ebnf']
+    filenames = ['*.ebnf']
+    mimetypes = ['text/x-ebnf']
+
+    tokens = {
+        'root': [
+            include('whitespace'),
+            include('comment_start'),
+            include('identifier'),
+            (r'=', Operator, 'production'),
+        ],
+        'production': [
+            include('whitespace'),
+            include('comment_start'),
+            include('identifier'),
+            (r'"[^"]*"', String.Double),
+            (r"'[^']*'", String.Single),
+            (r'(\?[^?]*\?)', Name.Entity),
+            (r'[\[\]{}(),|]', Punctuation),
+            (r'-', Operator),
+            (r';', Punctuation, '#pop'),
+        ],
+        'whitespace': [
+            (r'\s+', Text),
+          ],
+        'comment_start': [
+            (r'\(\*', Comment.Multiline, 'comment'),
+          ],
+        'comment': [
+            (r'[^*)]', Comment.Multiline),
+            include('comment_start'),
+            (r'\*\)', Comment.Multiline, '#pop'),
+            (r'[*)]', Comment.Multiline),
+          ],
+        'identifier': [
+            (r'([a-zA-Z][a-zA-Z0-9 \-]*)', Keyword),
+          ],
+    }

pygments/lexers/web.py

             ('<![^>]*>', Comment.Preproc),
             (r'<\s*script\s*', Name.Tag, ('script-content', 'tag')),
             (r'<\s*style\s*', Name.Tag, ('style-content', 'tag')),
-            (r'<\s*[a-zA-Z0-9:]+', Name.Tag, 'tag'),
-            (r'<\s*/\s*[a-zA-Z0-9:]+\s*>', Name.Tag),
+            # note: this allows tag names not used in HTML like <x:with-dash>,
+            # this is to support yet-unknown template engines and the like
+            (r'<\s*[\w:.-]+', Name.Tag, 'tag'),
+            (r'<\s*/\s*[\w:.-]+\s*>', Name.Tag),
         ],
         'comment': [
             ('[^-]+', Comment),
 
     name = 'XML'
     aliases = ['xml']
-    filenames = ['*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl']
+    filenames = ['*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd',
+                 '*.wsdl', '*.wsf']
     mimetypes = ['text/xml', 'application/xml', 'image/svg+xml',
                  'application/rss+xml', 'application/atom+xml']
 
         }
 
 
-class HaxeLexer(RegexLexer):
+class HaxeLexer(ExtendedRegexLexer):
     """
-    For haXe source code (http://haxe.org/).
+    For Haxe source code (http://haxe.org/).
 
     *New in Pygments 1.3.*
     """
 
-    name = 'haXe'
-    aliases = ['hx', 'haXe']
-    filenames = ['*.hx']
-    mimetypes = ['text/haxe']
-
-    ident = r'(?:[a-zA-Z_][a-zA-Z0-9_]*)'
-    typeid = r'(?:(?:[a-z0-9_\.])*[A-Z_][A-Za-z0-9_]*)'
-    key_prop = r'(?:default|null|never)'
-    key_decl_mod = r'(?:public|private|override|static|inline|extern|dynamic)'
+    name = 'Haxe'
+    aliases = ['hx', 'Haxe', 'haxe', 'haXe', 'hxsl']
+    filenames = ['*.hx', '*.hxsl']
+    mimetypes = ['text/haxe', 'text/x-haxe', 'text/x-hx']
+
+    # keywords extracted from lexer.mll in the haxe compiler source
+    keyword = (r'(?:function|class|static|var|if|else|while|do|for|'
+               r'break|return|continue|extends|implements|import|'
+               r'switch|case|default|public|private|try|untyped|'
+               r'catch|new|this|throw|extern|enum|in|interface|'
+               r'cast|override|dynamic|typedef|package|'
+               r'inline|using|null|true|false|abstract)\b')
+
+    # idtype in lexer.mll
+    typeid = r'_*[A-Z][_a-zA-Z0-9]*'
+
+    # combined ident and dollar and idtype
+    ident = r'(?:_*[a-z][_a-zA-Z0-9]*|_+[0-9][_a-zA-Z0-9]*|' + typeid + \
+        '|_+|\$[_a-zA-Z0-9]+)'
+
+    binop = (r'(?:%=|&=|\|=|\^=|\+=|\-=|\*=|/=|<<=|>\s*>\s*=|>\s*>\s*>\s*=|==|'
+             r'!=|<=|>\s*=|&&|\|\||<<|>>>|>\s*>|\.\.\.|<|>|%|&|\||\^|\+|\*|'
+             r'/|\-|=>|=)')
+
+    # ident except keywords
+    ident_no_keyword = r'(?!' + keyword + ')' + ident
 
     flags = re.DOTALL | re.MULTILINE
 
+    preproc_stack = []
+
+    def preproc_callback(self, match, ctx):
+        proc = match.group(2)
+
+        if proc == 'if':
+            # store the current stack
+            self.preproc_stack.append(ctx.stack[:])
+        elif proc in ['else', 'elseif']:
+            # restore the stack back to right before #if
+            if self.preproc_stack: ctx.stack = self.preproc_stack[-1][:]
+        elif proc == 'end':
+            # remove the saved stack of previous #if
+            if self.preproc_stack: self.preproc_stack.pop()
+
+        # #if and #elseif should follow by an expr
+        if proc in ['if', 'elseif']:
+            ctx.stack.append('preproc-expr')
+
+        # #error can be optionally follow by the error msg
+        if proc in ['error']:
+            ctx.stack.append('preproc-error')
+
+        yield match.start(), Comment.Preproc, '#' + proc
+        ctx.pos = match.end()
+
+
     tokens = {
         'root': [
-            include('whitespace'),
-            include('comments'),
-            (key_decl_mod, Keyword.Declaration),
-            include('enumdef'),
-            include('typedef'),
-            include('classdef'),
-            include('imports'),
-        ],
-
-        # General constructs
-        'comments': [
-            (r'//.*?\n', Comment.Single),
+            include('spaces'),
+            include('meta'),
+            (r'(?:package)\b', Keyword.Namespace, ('semicolon', 'package')),
+            (r'(?:import)\b', Keyword.Namespace, ('semicolon', 'import')),
+            (r'(?:using)\b', Keyword.Namespace, ('semicolon', 'using')),
+            (r'(?:extern|private)\b', Keyword.Declaration),
+            (r'(?:abstract)\b', Keyword.Declaration, 'abstract'),
+            (r'(?:class|interface)\b', Keyword.Declaration, 'class'),
+            (r'(?:enum)\b', Keyword.Declaration, 'enum'),
+            (r'(?:typedef)\b', Keyword.Declaration, 'typedef'),
+
+            # top-level expression
+            # although it is not supported in haxe, but it is common to write
+            # expression in web pages the positive lookahead here is to prevent
+            # an infinite loop at the EOF
+            (r'(?=.)', Text, 'expr-statement'),
+        ],
+
+        # space/tab/comment/preproc
+        'spaces': [
+            (r'\s+', Text),
+            (r'//[^\n\r]*', Comment.Single),
             (r'/\*.*?\*/', Comment.Multiline),
-            (r'#[^\n]*', Comment.Preproc),
-        ],
-        'whitespace': [
-            include('comments'),
-            (r'\s+', Text),
-        ],
-        'codekeywords': [
-            (r'\b(if|else|while|do|for|in|break|continue|'
-             r'return|switch|case|try|catch|throw|null|trace|'
-             r'new|this|super|untyped|cast|callback|here)\b',
-             Keyword.Reserved),
-        ],
-        'literals': [
-            (r'0[xX][0-9a-fA-F]+', Number.Hex),
-            (r'[0-9]+', Number.Integer),
-            (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
-            (r"'(\\\\|\\'|[^'])*'", String.Single),
-            (r'"(\\\\|\\"|[^"])*"', String.Double),
-            (r'~/([^\n])*?/[gisx]*', String.Regex),
-            (r'\b(true|false|null)\b', Keyword.Constant),
-        ],
-        'codeblock': [
-          include('whitespace'),
-          include('new'),
-          include('case'),
-          include('anonfundef'),
-          include('literals'),
-          include('vardef'),
-          include('codekeywords'),
-          (r'[();,\[\]]', Punctuation),
-          (r'(?:=|\+=|-=|\*=|/=|%=|&=|\|=|\^=|<<=|>>=|>>>=|\|\||&&|'
-           r'\.\.\.|==|!=|>|<|>=|<=|\||&|\^|<<|>>>|>>|\+|\-|\*|/|%|'
-           r'!|\+\+|\-\-|~|\.|\?|\:)',
-           Operator),
-          (ident, Name),
-
-          (r'}', Punctuation,'#pop'),
-          (r'{', Punctuation,'#push'),
-        ],
-
-        # Instance/Block level constructs
-        'propertydef': [
-            (r'(\()(' + key_prop + ')(,)(' + key_prop + ')(\))',
-             bygroups(Punctuation, Keyword.Reserved, Punctuation,
-                      Keyword.Reserved, Punctuation)),
-        ],
+            (r'(#)(if|elseif|else|end|error)\b', preproc_callback),
+        ],
+
+        'string-single-interpol': [
+            (r'\$\{', String.Interpol, ('string-interpol-close', 'expr')),
+            (r'\$\$', String.Escape),
+            (r'\$(?=' + ident + ')', String.Interpol, 'ident'),
+            include('string-single'),
+        ],
+
+        'string-single': [
+            (r"'", String.Single, '#pop'),
+            (r'\\.', String.Escape),
+            (r'.', String.Single),
+        ],
+
+        'string-double': [
+            (r'"', String.Double, '#pop'),
+            (r'\\.', String.Escape),
+            (r'.', String.Double),
+        ],
+
+        'string-interpol-close': [
+            (r'\$'+ident, String.Interpol),
+            (r'\}', String.Interpol, '#pop'),
+        ],
+
+        'package': [
+            include('spaces'),
+            (ident, Name.Namespace),
+            (r'\.', Punctuation, 'import-ident'),
+            (r'', Text, '#pop'),
+        ],
+
+        'import': [
+            include('spaces'),
+            (ident, Name.Namespace),
+            (r'\*', Keyword), # wildcard import
+            (r'\.', Punctuation, 'import-ident'),
+            (r'in', Keyword.Namespace, 'ident'),
+            (r'', Text, '#pop'),
+        ],
+
+        'import-ident': [
+            include('spaces'),
+            (r'\*', Keyword, '#pop'), # wildcard import
+            (ident, Name.Namespace, '#pop'),
+        ],
+
+        'using': [
+            include('spaces'),
+            (ident, Name.Namespace),
+            (r'\.', Punctuation, 'import-ident'),
+            (r'', Text, '#pop'),
+        ],
+
+        'preproc-error': [
+            (r'\s+', Comment.Preproc),
+            (r"'", String.Single, ('#pop', 'string-single')),
+            (r'"', String.Double, ('#pop', 'string-double')),
+            (r'', Text, '#pop'),
+        ],
+
+        'preproc-expr': [
+            (r'\s+', Comment.Preproc),
+            (r'\!', Comment.Preproc),
+            (r'\(', Comment.Preproc, ('#pop', 'preproc-parenthesis')),
+
+            (ident, Comment.Preproc, '#pop'),
+            (r"'", String.Single, ('#pop', 'string-single')),
+            (r'"', String.Double, ('#pop', 'string-double')),
+        ],
+
+        'preproc-parenthesis': [
+            (r'\s+', Comment.Preproc),
+            (r'\)', Comment.Preproc, '#pop'),
+            ('', Text, 'preproc-expr-in-parenthesis'),
+        ],
+
+        'preproc-expr-chain': [
+            (r'\s+', Comment.Preproc),
+            (binop, Comment.Preproc, ('#pop', 'preproc-expr-in-parenthesis')),
+            (r'', Text, '#pop'),
+        ],
+
+        # same as 'preproc-expr' but able to chain 'preproc-expr-chain'
+        'preproc-expr-in-parenthesis': [
+            (r'\s+', Comment.Preproc),
+            (r'\!', Comment.Preproc),
+            (r'\(', Comment.Preproc,
+             ('#pop', 'preproc-expr-chain', 'preproc-parenthesis')),
+
+            (ident, Comment.Preproc, ('#pop', 'preproc-expr-chain')),
+            (r"'", String.Single,
+             ('#pop', 'preproc-expr-chain', 'string-single')),
+            (r'"', String.Double,
+             ('#pop', 'preproc-expr-chain', 'string-double')),
+        ],
+
+        'abstract' : [
+            include('spaces'),
+            (r'', Text, ('#pop', 'abstract-body', 'abstract-relation',
+                    'abstract-opaque', 'type-param-constraint', 'type-name')),
+        ],
+
+        'abstract-body' : [
+            include('spaces'),
+            (r'\{', Punctuation, ('#pop', 'class-body')),
+        ],
+
+        'abstract-opaque' : [
+            include('spaces'),
+            (r'\(', Punctuation, ('#pop', 'parenthesis-close', 'type')),
+            (r'', Text, '#pop'),
+        ],
+
+        'abstract-relation': [
+            include('spaces'),
+            (r'(?:to|from)', Keyword.Declaration, 'type'),
+            (r',', Punctuation),
+            (r'', Text, '#pop'),
+        ],
+
+        'meta': [
+            include('spaces'),
+            (r'@', Name.Decorator, ('meta-body', 'meta-ident', 'meta-colon')),
+        ],
+
+        # optional colon
+        'meta-colon': [
+            include('spaces'),
+            (r':', Name.Decorator, '#pop'),
+            (r'', Text, '#pop'),
+        ],
+
+        # same as 'ident' but set token as Name.Decorator instead of Name
+        'meta-ident': [
+            include('spaces'),
+            (ident, Name.Decorator, '#pop'),
+        ],
+
+        'meta-body': [
+            include('spaces'),
+            (r'\(', Name.Decorator, ('#pop', 'meta-call')),
+            (r'', Text, '#pop'),
+        ],
+
+        'meta-call': [
+            include('spaces'),
+            (r'\)', Name.Decorator, '#pop'),
+            (r'', Text, ('#pop', 'meta-call-sep', 'expr')),
+        ],
+
+        'meta-call-sep': [
+            include('spaces'),
+            (r'\)', Name.Decorator, '#pop'),
+            (r',', Punctuation, ('#pop', 'meta-call')),
+        ],
+
+        'typedef': [
+            include('spaces'),
+            (r'', Text, ('#pop', 'typedef-body', 'type-param-constraint',
+                         'type-name')),
+        ],
+
+        'typedef-body': [
+            include('spaces'),
+            (r'=', Operator, ('#pop', 'optional-semicolon', 'type')),
+        ],
+
+        'enum': [
+            include('spaces'),
+            (r'', Text, ('#pop', 'enum-body', 'bracket-open',
+                         'type-param-constraint', 'type-name')),
+        ],
+
+        'enum-body': [
+            include('spaces'),
+            include('meta'),
+            (r'\}', Punctuation, '#pop'),
+            (ident_no_keyword, Name, ('enum-member', 'type-param-constraint')),
+        ],
+
+        'enum-member': [
+            include('spaces'),
+            (r'\(', Punctuation,
+             ('#pop', 'semicolon', 'flag', 'function-param')),
+            (r'', Punctuation, ('#pop', 'semicolon', 'flag')),
+        ],
+
+        'class': [
+            include('spaces'),
+            (r'', Text, ('#pop', 'class-body', 'bracket-open', 'extends',
+                         'type-param-constraint', 'type-name')),
+        ],
+
+        'extends': [
+            include('spaces'),
+            (r'(?:extends|implements)\b', Keyword.Declaration, 'type'),
+            (r',', Punctuation), # the comma is made optional here, since haxe2
+                                 # requires the comma but haxe3 does not allow it
+            (r'', Text, '#pop'),
+        ],
+
+        'bracket-open': [
+            include('spaces'),
+            (r'\{', Punctuation, '#pop'),
+        ],
+
+        'bracket-close': [
+            include('spaces'),
+            (r'\}', Punctuation, '#pop'),
+        ],
+
+        'class-body': [
+            include('spaces'),
+            include('meta'),
+            (r'\}', Punctuation, '#pop'),
+            (r'(?:static|public|private|override|dynamic|inline|macro)\b',
+             Keyword.Declaration),
+            (r'', Text, 'class-member'),
+        ],
+
+        'class-member': [
+            include('spaces'),
+            (r'(var)\b', Keyword.Declaration,
+             ('#pop', 'optional-semicolon', 'prop')),
+            (r'(function)\b', Keyword.Declaration,
+             ('#pop', 'optional-semicolon', 'class-method')),
+        ],
+
+        # local function, anonymous or not
+        'function-local': [
+            include('spaces'),
+            (r'(' + ident_no_keyword + ')?', Name.Function,
+             ('#pop', 'expr', 'flag', 'function-param',
+              'parenthesis-open', 'type-param-constraint')),
+        ],
+
+        'optional-expr': [
+            include('spaces'),
+            include('expr'),
+            (r'', Text, '#pop'),
+        ],
+
+        'class-method': [
+            include('spaces'),
+            (ident, Name.Function, ('#pop', 'optional-expr', 'flag',
+                                    'function-param', 'parenthesis-open',
+                                    'type-param-constraint')),
+        ],
+
+        # function arguments
+        'function-param': [
+            include('spaces'),
+            (r'\)', Punctuation, '#pop'),
+            (r'\?', Punctuation),
+            (ident_no_keyword, Name,
+             ('#pop', 'function-param-sep', 'assign', 'flag')),
+        ],
+
+        'function-param-sep': [
+            include('spaces'),
+            (r'\)', Punctuation, '#pop'),
+            (r',', Punctuation, ('#pop', 'function-param')),
+        ],
+
+        # class property
+        # eg. var prop(default, null):String;
+        'prop': [
+            include('spaces'),
+            (ident_no_keyword, Name, ('#pop', 'assign', 'flag', 'prop-get-set')),
+        ],
+
+        'prop-get-set': [
+            include('spaces'),
+            (r'\(', Punctuation, ('#pop', 'parenthesis-close',
+                                  'prop-get-set-opt', 'comma', 'prop-get-set-opt')),
+            (r'', Text, '#pop'),
+        ],
+
+        'prop-get-set-opt': [
+            include('spaces'),
+            (r'(?:default|null|never|dynamic|get|set)\b', Keyword, '#pop'),
+            (ident_no_keyword, Text, '#pop'), #custom getter/setter
+        ],
+
+        'expr-statement': [
+            include('spaces'),
+            # makes semicolon optional here, just to avoid checking the last
+            # one is bracket or not.
+            (r'', Text, ('#pop', 'optional-semicolon', 'expr')),
+        ],
+
+        'expr': [
+            include('spaces'),
+            (r'@', Name.Decorator, ('#pop', 'optional-expr', 'meta-body',
+                                    'meta-ident', 'meta-colon')),
+            (r'(?:\+\+|\-\-|~(?!/)|!|\-)', Operator),
+            (r'\(', Punctuation, ('#pop', 'expr-chain', 'parenthesis')),
+            (r'(?:inline)\b', Keyword.Declaration),
+            (r'(?:function)\b', Keyword.Declaration, ('#pop', 'expr-chain',
+                                                      'function-local')),
+            (r'\{', Punctuation, ('#pop', 'expr-chain', 'bracket')),
+            (r'(?:true|false|null)\b', Keyword.Constant, ('#pop', 'expr-chain')),
+            (r'(?:this)\b', Keyword, ('#pop', 'expr-chain')),
+            (r'(?:cast)\b', Keyword, ('#pop', 'expr-chain', 'cast')),
+            (r'(?:try)\b', Keyword, ('#pop', 'catch', 'expr')),
+            (r'(?:var)\b', Keyword.Declaration, ('#pop', 'var')),
+            (r'(?:new)\b', Keyword, ('#pop', 'expr-chain', 'new')),
+            (r'(?:switch)\b', Keyword, ('#pop', 'switch')),
+            (r'(?:if)\b', Keyword, ('#pop', 'if')),
+            (r'(?:do)\b', Keyword, ('#pop', 'do')),
+            (r'(?:while)\b', Keyword, ('#pop', 'while')),
+            (r'(?:for)\b', Keyword, ('#pop', 'for')),
+            (r'(?:untyped|throw)\b', Keyword),
+            (r'(?:return)\b', Keyword, ('#pop', 'optional-expr')),
+            (r'(?:macro)\b', Keyword, ('#pop', 'macro')),
+            (r'(?:continue|break)\b', Keyword, '#pop'),
+            (r'(?:\$\s*[a-z]\b|\$(?!'+ident+'))', Name, ('#pop', 'dollar')),
+            (ident_no_keyword, Name, ('#pop', 'expr-chain')),
+
+            # Float
+            (r'\.[0-9]+', Number.Float, ('#pop', 'expr-chain')),
+            (r'[0-9]+[eE][\+\-]?[0-9]+', Number.Float, ('#pop', 'expr-chain')),
+            (r'[0-9]+\.[0-9]*[eE][\+\-]?[0-9]+', Number.Float, ('#pop', 'expr-chain')),
+            (r'[0-9]+\.[0-9]+', Number.Float, ('#pop', 'expr-chain')),
+            (r'[0-9]+\.(?!' + ident + '|\.\.)', Number.Float, ('#pop', 'expr-chain')),
+
+            # Int
+            (r'0x[0-9a-fA-F]+', Number.Hex, ('#pop', 'expr-chain')),
+            (r'[0-9]+', Number.Integer, ('#pop', 'expr-chain')),
+
+            # String
+            (r"'", String.Single, ('#pop', 'expr-chain', 'string-single-interpol')),
+            (r'"', String.Double, ('#pop', 'expr-chain', 'string-double')),
+
+            # EReg
+            (r'~/(\\\\|\\/|[^/\n])*/[gimsu]*', String.Regex, ('#pop', 'expr-chain')),
+
+            # Array
+            (r'\[', Punctuation, ('#pop', 'expr-chain', 'array-decl')),
+        ],
+
+        'expr-chain': [
+            include('spaces'),
+            (r'(?:\+\+|\-\-)', Operator),
+            (binop, Operator, ('#pop', 'expr')),
+            (r'(?:in)\b', Keyword, ('#pop', 'expr')),
+            (r'\?', Operator, ('#pop', 'expr', 'ternary', 'expr')),
+            (r'(\.)(' + ident_no_keyword + ')', bygroups(Punctuation, Name)),
+            (r'\[', Punctuation, 'array-access'),
+            (r'\(', Punctuation, 'call'),
+            (r'', Text, '#pop'),
+        ],
+
+        # macro reification
+        'macro': [
+            include('spaces'),
+            (r':', Punctuation, ('#pop', 'type')),
+            (r'', Text, ('#pop', 'expr')),
+        ],
+
+        # cast can be written as "cast expr" or "cast(expr, type)"
+        'cast': [
+            include('spaces'),
+            (r'\(', Punctuation, ('#pop', 'parenthesis-close',
+                                  'cast-type', 'expr')),
+            (r'', Text, ('#pop', 'expr')),
+        ],
+
+        # optionally give a type as the 2nd argument of cast()
+        'cast-type': [
+            include('spaces'),
+            (r',', Punctuation, ('#pop', 'type')),
+            (r'', Text, '#pop'),
+        ],
+
+        'catch': [
+            include('spaces'),
+            (r'(?:catch)\b', Keyword, ('expr', 'function-param',
+                                       'parenthesis-open')),
+            (r'', Text, '#pop'),
+        ],
+
+        # do-while loop
+        'do': [
+            include('spaces'),
+            (r'', Punctuation, ('#pop', 'do-while', 'expr')),
+        ],
+
+        # the while after do
+        'do-while': [
+            include('spaces'),
+            (r'(?:while)\b', Keyword, ('#pop', 'parenthesis',
+                                       'parenthesis-open')),
+        ],
+
+        'while': [
+            include('spaces'),
+            (r'\(', Punctuation, ('#pop', 'expr', 'parenthesis')),
+        ],
+
+        'for': [