Skip to content
This repository
Browse code

Merge pull request #8 from tmm1/update-pygments

Update Pygments to db34feabe4b8
  • Loading branch information...
commit b6d4f8776bfd3625faf7682dd49c5c572d5095e9 2 parents 2e6fb9a + e4ce855
Joshua Peek josh authored

Showing 20 changed files with 2,238 additions and 228 deletions. Show diff stats Hide diff stats

  1. +3 0  vendor/pygments-main/AUTHORS
  2. +5 0 vendor/pygments-main/CHANGES
  3. +1 1  vendor/pygments-main/REVISION
  4. +1 1  vendor/pygments-main/docs/src/lexerdevelopment.txt
  5. +1 1  vendor/pygments-main/docs/src/styles.txt
  6. +1 1  vendor/pygments-main/pygments/cmdline.py
  7. +1 1  vendor/pygments-main/pygments/formatters/latex.py
  8. +4 1 vendor/pygments-main/pygments/lexers/_mapping.py
  9. +21 29 vendor/pygments-main/pygments/lexers/agile.py
  10. +327 3 vendor/pygments-main/pygments/lexers/functional.py
  11. +400 7 vendor/pygments-main/pygments/lexers/math.py
  12. +210 170 vendor/pygments-main/pygments/lexers/other.py
  13. +1 1  vendor/pygments-main/pygments/lexers/postgres.py
  14. +6 4 vendor/pygments-main/pygments/lexers/pypylog.py
  15. +45 8 vendor/pygments-main/pygments/lexers/web.py
  16. +156 0 vendor/pygments-main/tests/examplefiles/example.sml
  17. +675 0 vendor/pygments-main/tests/examplefiles/intsyn.fun
  18. +286 0 vendor/pygments-main/tests/examplefiles/intsyn.sig
  19. +1 0  vendor/pygments-main/tests/examplefiles/psql_session.txt
  20. +93 0 vendor/pygments-main/tests/examplefiles/test.nim
3  vendor/pygments-main/AUTHORS
@@ -39,6 +39,7 @@ Other contributors, listed alphabetically, are:
39 39 * Matthew Harrison -- SVG formatter
40 40 * Steven Hazel -- Tcl lexer
41 41 * Aslak Hellesøy -- Gherkin lexer
  42 +* Jordi Gutiérrez Hermoso -- Octave lexer
42 43 * David Hess, Fish Software, Inc. -- Objective-J lexer
43 44 * Varun Hiremath -- Debian control lexer
44 45 * Ben Hollis -- Mason lexer
@@ -78,6 +79,7 @@ Other contributors, listed alphabetically, are:
78 79 * Ken Schutte -- Matlab lexers
79 80 * Tassilo Schweyer -- Io, MOOCode lexers
80 81 * Joerg Sieker -- ABAP lexer
  82 +* Robert Simmons -- Standard ML lexer
81 83 * Kirill Simonov -- YAML lexer
82 84 * Steve Spigarelli -- XQuery lexer
83 85 * Jerome St-Louis -- eC lexer
@@ -90,6 +92,7 @@ Other contributors, listed alphabetically, are:
90 92 * Dietmar Winkler -- Modelica lexer
91 93 * Nils Winter -- Smalltalk lexer
92 94 * Davy Wybiral -- Clojure lexer
  95 +* Diego Zamboni -- CFengine3 lexer
93 96 * Alex Zimin -- Nemerle lexer
94 97
95 98 Many thanks for all contributions!
5 vendor/pygments-main/CHANGES
@@ -21,6 +21,9 @@ Version 1.5
21 21 * PostgreSQL (#660)
22 22 * DTD
23 23 * Gosu
  24 + * Octave (PR#22)
  25 + * Standard ML (PR#14)
  26 + * CFengine3 (#601)
24 27
25 28 - In the LaTeX formatter, escape special &, < and > chars (#648).
26 29
@@ -41,6 +44,8 @@ Version 1.5
41 44
42 45 - Fix generic type highlighting in ActionScript 3 (#666).
43 46
  47 +- Fixes to the Clojure lexer (PR#9).
  48 +
44 49
45 50 Version 1.4
46 51 -----------
2  vendor/pygments-main/REVISION
... ... @@ -1 +1 @@
1   -456992e7ff81
  1 +db34feabe4b8
2  vendor/pygments-main/docs/src/lexerdevelopment.txt
@@ -121,7 +121,7 @@ sections, comments and key = value pairs:
121 121 }
122 122
123 123 The lexer first looks for whitespace, comments and section names. And later it
124   -looks for a line that looks like a key, value pair, seperated by an ``'='``
  124 +looks for a line that looks like a key, value pair, separated by an ``'='``
125 125 sign, and optional whitespace.
126 126
127 127 The `bygroups` helper makes sure that each group is yielded with a different
2  vendor/pygments-main/docs/src/styles.txt
@@ -85,7 +85,7 @@ Here a small overview of all allowed styles:
85 85 ``bold``
86 86 render text as bold
87 87 ``nobold``
88   - don't render text as bold (to prevent subtokens behing highlighted bold)
  88 + don't render text as bold (to prevent subtokens being highlighted bold)
89 89 ``italic``
90 90 render text italic
91 91 ``noitalic``
2  vendor/pygments-main/pygments/cmdline.py
@@ -219,7 +219,7 @@ def main(args=sys.argv):
219 219 return 0
220 220
221 221 if opts.pop('-V', None) is not None:
222   - print 'Pygments version %s, (c) 2006-2008 by Georg Brandl.' % __version__
  222 + print 'Pygments version %s, (c) 2006-2011 by Georg Brandl.' % __version__
223 223 return 0
224 224
225 225 # handle ``pygmentize -L``
2  vendor/pygments-main/pygments/formatters/latex.py
@@ -286,7 +286,7 @@ def get_style_defs(self, arg=''):
286 286 cp = self.commandprefix
287 287 styles = []
288 288 for name, definition in self.cmd2def.iteritems():
289   - styles.append(r'\def\%s@tok@%s{%s}' % (cp, name, definition))
  289 + styles.append(r'\expandafter\def\csname %s@tok@%s\endcsname{%s}' % (cp, name, definition))
290 290 return STYLE_TEMPLATE % {'cp': self.commandprefix,
291 291 'styles': '\n'.join(styles)}
292 292
5 vendor/pygments-main/pygments/lexers/_mapping.py
@@ -46,6 +46,7 @@
46 46 'CObjdumpLexer': ('pygments.lexers.asm', 'c-objdump', ('c-objdump',), ('*.c-objdump',), ('text/x-c-objdump',)),
47 47 'CSharpAspxLexer': ('pygments.lexers.dotnet', 'aspx-cs', ('aspx-cs',), ('*.aspx', '*.asax', '*.ascx', '*.ashx', '*.asmx', '*.axd'), ()),
48 48 'CSharpLexer': ('pygments.lexers.dotnet', 'C#', ('csharp', 'c#'), ('*.cs',), ('text/x-csharp',)),
  49 + 'Cfengine3Lexer': ('pygments.lexers.other', 'CFEngine3', ('cfengine3', 'cf3'), ('*.cf',), ()),
49 50 'CheetahHtmlLexer': ('pygments.lexers.templates', 'HTML+Cheetah', ('html+cheetah', 'html+spitfire'), (), ('text/html+cheetah', 'text/html+spitfire')),
50 51 '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')),
51 52 'CheetahLexer': ('pygments.lexers.templates', 'Cheetah', ('cheetah', 'spitfire'), ('*.tmpl', '*.spt'), ('application/x-cheetah', 'application/x-spitfire')),
@@ -135,7 +136,7 @@
135 136 'MakoXmlLexer': ('pygments.lexers.templates', 'XML+Mako', ('xml+mako',), (), ('application/xml+mako',)),
136 137 'MaqlLexer': ('pygments.lexers.other', 'MAQL', ('maql',), ('*.maql',), ('text/x-gooddata-maql', 'application/x-gooddata-maql')),
137 138 'MasonLexer': ('pygments.lexers.templates', 'Mason', ('mason',), ('*.m', '*.mhtml', '*.mc', '*.mi', 'autohandler', 'dhandler'), ('application/x-mason',)),
138   - 'MatlabLexer': ('pygments.lexers.math', 'Matlab', ('matlab', 'octave'), ('*.m',), ('text/matlab',)),
  139 + 'MatlabLexer': ('pygments.lexers.math', 'Matlab', ('matlab',), ('*.m',), ('text/matlab',)),
139 140 'MatlabSessionLexer': ('pygments.lexers.math', 'Matlab session', ('matlabsession',), (), ()),
140 141 'MiniDLexer': ('pygments.lexers.agile', 'MiniD', ('minid',), ('*.md',), ('text/x-minidsrc',)),
141 142 'ModelicaLexer': ('pygments.lexers.other', 'Modelica', ('modelica',), ('*.mo',), ('text/x-modelica',)),
@@ -160,6 +161,7 @@
160 161 'ObjectiveJLexer': ('pygments.lexers.web', 'Objective-J', ('objective-j', 'objectivej', 'obj-j', 'objj'), ('*.j',), ('text/x-objective-j',)),
161 162 'OcamlLexer': ('pygments.lexers.compiled', 'OCaml', ('ocaml',), ('*.ml', '*.mli', '*.mll', '*.mly'), ('text/x-ocaml',)),
162 163 'OcamlLexer': ('pygments.lexers.functional', 'OCaml', ('ocaml',), ('*.ml', '*.mli', '*.mll', '*.mly'), ('text/x-ocaml',)),
  164 + 'OctaveLexer': ('pygments.lexers.math', 'Octave', ('octave',), ('*.m',), ('text/octave',)),
163 165 'OocLexer': ('pygments.lexers.compiled', 'Ooc', ('ooc',), ('*.ooc',), ('text/x-ooc',)),
164 166 'PerlLexer': ('pygments.lexers.agile', 'Perl', ('perl', 'pl'), ('*.pl', '*.pm'), ('text/x-perl', 'application/x-perl')),
165 167 'PhpLexer': ('pygments.lexers.web', 'PHP', ('php', 'php3', 'php4', 'php5'), ('*.php', '*.php[345]'), ('text/x-php',)),
@@ -194,6 +196,7 @@
194 196 'RubyConsoleLexer': ('pygments.lexers.agile', 'Ruby irb session', ('rbcon', 'irb'), (), ('text/x-ruby-shellsession',)),
195 197 'RubyLexer': ('pygments.lexers.agile', 'Ruby', ('rb', 'ruby', 'duby'), ('*.rb', '*.rbw', 'Rakefile', '*.rake', '*.gemspec', '*.rbx', '*.duby'), ('text/x-ruby', 'application/x-ruby')),
196 198 'SLexer': ('pygments.lexers.math', 'S', ('splus', 's', 'r'), ('*.S', '*.R'), ('text/S-plus', 'text/S', 'text/R')),
  199 + 'SMLLexer': ('pygments.lexers.functional', 'Standard ML', ('sml',), ('*.sml', '*.sig', '*.fun'), ('text/x-standardml', 'application/x-standardml')),
197 200 'SassLexer': ('pygments.lexers.web', 'Sass', ('sass', 'SASS'), ('*.sass',), ('text/x-sass',)),
198 201 'ScalaLexer': ('pygments.lexers.compiled', 'Scala', ('scala',), ('*.scala',), ('text/x-scala',)),
199 202 'ScamlLexer': ('pygments.lexers.web', 'Scaml', ('scaml', 'SCAML'), ('*.scaml',), ('text/x-scaml',)),
50 vendor/pygments-main/pygments/lexers/agile.py
@@ -13,7 +13,7 @@
13 13
14 14 from pygments.lexer import Lexer, RegexLexer, ExtendedRegexLexer, \
15 15 LexerContext, include, combined, do_insertions, bygroups, using, this
16   -from pygments.token import Error, Text, Other, \
  16 +from pygments.token import Error, Text, Whitespace, Other, \
17 17 Comment, Operator, Keyword, Name, String, Number, Generic, Punctuation
18 18 from pygments.util import get_bool_opt, get_list_opt, shebang_matches
19 19 from pygments import unistring as uni
@@ -1367,13 +1367,11 @@ class ClojureLexer(RegexLexer):
1367 1367
1368 1368 keywords = [
1369 1369 'fn', 'def', 'defn', 'defmacro', 'defmethod', 'defmulti', 'defn-',
1370   - 'defstruct',
1371   - 'if', 'cond',
1372   - 'let', 'for'
  1370 + 'defstruct', 'if', 'cond', 'let', 'for'
1373 1371 ]
1374 1372 builtins = [
1375 1373 '.', '..',
1376   - '*', '+', '-', '->', '..', '/', '<', '<=', '=', '==', '>', '>=',
  1374 + '*', '+', '-', '->', '/', '<', '<=', '=', '==', '>', '>=',
1377 1375 'accessor', 'agent', 'agent-errors', 'aget', 'alength', 'all-ns',
1378 1376 'alter', 'and', 'append-child', 'apply', 'array-map', 'aset',
1379 1377 'aset-boolean', 'aset-byte', 'aset-char', 'aset-double', 'aset-float',
@@ -1389,13 +1387,13 @@ class ClojureLexer(RegexLexer):
1389 1387 'double', 'down', 'drop', 'drop-while', 'edit', 'end?', 'ensure',
1390 1388 'eval', 'every?', 'false?', 'ffirst', 'file-seq', 'filter', 'find',
1391 1389 'find-doc', 'find-ns', 'find-var', 'first', 'float', 'flush',
1392   - 'fnseq', 'frest', 'gensym', 'get', 'get-proxy-class',
  1390 + 'fnseq', 'frest', 'gensym', 'get-proxy-class', 'get',
1393 1391 'hash-map', 'hash-set', 'identical?', 'identity', 'if-let', 'import',
1394 1392 'in-ns', 'inc', 'index', 'insert-child', 'insert-left', 'insert-right',
1395 1393 'inspect-table', 'inspect-tree', 'instance?', 'int', 'interleave',
1396 1394 'intersection', 'into', 'into-array', 'iterate', 'join', 'key', 'keys',
1397 1395 'keyword', 'keyword?', 'last', 'lazy-cat', 'lazy-cons', 'left',
1398   - 'lefts', 'line-seq', 'list', 'list*', 'load', 'load-file',
  1396 + 'lefts', 'line-seq', 'list*', 'list', 'load', 'load-file',
1399 1397 'locking', 'long', 'loop', 'macroexpand', 'macroexpand-1',
1400 1398 'make-array', 'make-node', 'map', 'map-invert', 'map?', 'mapcat',
1401 1399 'max', 'max-key', 'memfn', 'merge', 'merge-with', 'meta', 'min',
@@ -1426,7 +1424,14 @@ class ClojureLexer(RegexLexer):
1426 1424 # valid names for identifiers
1427 1425 # well, names can only not consist fully of numbers
1428 1426 # but this should be good enough for now
1429   - valid_name = r'[a-zA-Z0-9!$%&*+,/:<=>?@^_~-]+'
  1427 +
  1428 + # TODO / should divide keywords/symbols into namespace/rest
  1429 + # but that's hard, so just pretend / is part of the name
  1430 + valid_name = r'[\w!$%*+,<=>?/.-]+'
  1431 +
  1432 + def _multi_escape(entries):
  1433 + return '|'.join([re.escape(entry) + '(?![\\w-!$%*+,<=>?/.-])'
  1434 + for entry in entries])
1430 1435
1431 1436 tokens = {
1432 1437 'root' : [
@@ -1435,42 +1440,29 @@ class ClojureLexer(RegexLexer):
1435 1440 (r';.*$', Comment.Single),
1436 1441
1437 1442 # whitespaces - usually not relevant
1438   - (r'\s+', Text),
  1443 + (r'[,\s]+', Whitespace),
1439 1444
1440 1445 # numbers
1441 1446 (r'-?\d+\.\d+', Number.Float),
1442 1447 (r'-?\d+', Number.Integer),
1443   - # support for uncommon kinds of numbers -
1444   - # have to figure out what the characters mean
1445   - #(r'(#e|#i|#b|#o|#d|#x)[\d.]+', Number),
  1448 + (r'0x-?[abcdef\d]+', Number.Hex),
1446 1449
1447 1450 # strings, symbols and characters
1448 1451 (r'"(\\\\|\\"|[^"])*"', String),
1449 1452 (r"'" + valid_name, String.Symbol),
1450   - (r"\\([()/'\".'_!§$%& ?;=#+-]{1}|[a-zA-Z0-9]+)", String.Char),
  1453 + (r"\\(.|[a-z]+)", String.Char),
1451 1454
1452   - # constants
1453   - (r'(#t|#f)', Name.Constant),
  1455 + # keywords
  1456 + (r':' + valid_name, Name.Constant),
1454 1457
1455 1458 # special operators
1456   - (r"('|#|`|,@|,|\.)", Operator),
  1459 + (r'~@|[`\'#^~&]', Operator),
1457 1460
1458 1461 # highlight the keywords
1459   - ('(%s)' % '|'.join([
1460   - re.escape(entry) + ' ' for entry in keywords]),
1461   - Keyword
1462   - ),
1463   -
1464   - # first variable in a quoted string like
1465   - # '(this is syntactic sugar)
1466   - (r"(?<='\()" + valid_name, Name.Variable),
1467   - (r"(?<=#\()" + valid_name, Name.Variable),
  1462 + (_multi_escape(keywords), Keyword),
1468 1463
1469 1464 # highlight the builtins
1470   - ("(?<=\()(%s)" % '|'.join([
1471   - re.escape(entry) + ' ' for entry in builtins]),
1472   - Name.Builtin
1473   - ),
  1465 + (_multi_escape(builtins), Name.Builtin),
1474 1466
1475 1467 # the remaining functions
1476 1468 (r'(?<=\()' + valid_name, Name.Function),
330 vendor/pygments-main/pygments/lexers/functional.py
@@ -13,11 +13,12 @@
13 13
14 14 from pygments.lexer import Lexer, RegexLexer, bygroups, include, do_insertions
15 15 from pygments.token import Text, Comment, Operator, Keyword, Name, \
16   - String, Number, Punctuation, Literal, Generic
  16 + String, Number, Punctuation, Literal, Generic, Error
17 17
18 18
19   -__all__ = ['SchemeLexer', 'CommonLispLexer', 'HaskellLexer', 'LiterateHaskellLexer',
20   - 'OcamlLexer', 'ErlangLexer', 'ErlangShellLexer']
  19 +__all__ = ['SchemeLexer', 'CommonLispLexer', 'HaskellLexer',
  20 + 'LiterateHaskellLexer', 'SMLLexer', 'OcamlLexer', 'ErlangLexer',
  21 + 'ErlangShellLexer']
21 22
22 23
23 24 class SchemeLexer(RegexLexer):
@@ -515,6 +516,329 @@ def get_tokens_unprocessed(self, text):
515 516 yield item
516 517
517 518
  519 +class SMLLexer(RegexLexer):
  520 + """
  521 + For the Standard ML language.
  522 +
  523 + *New in Pygments 1.5.*
  524 + """
  525 +
  526 + name = 'Standard ML'
  527 + aliases = ['sml']
  528 + filenames = ['*.sml', '*.sig', '*.fun',]
  529 + mimetypes = ['text/x-standardml', 'application/x-standardml']
  530 +
  531 + alphanumid_reserved = [
  532 + # Core
  533 + 'abstype', 'and', 'andalso', 'as', 'case', 'datatype', 'do', 'else',
  534 + 'end', 'exception', 'fn', 'fun', 'handle', 'if', 'in', 'infix',
  535 + 'infixr', 'let', 'local', 'nonfix', 'of', 'op', 'open', 'orelse',
  536 + 'raise', 'rec', 'then', 'type', 'val', 'with', 'withtype', 'while',
  537 + # Modules
  538 + 'eqtype', 'functor', 'include', 'sharing', 'sig', 'signature',
  539 + 'struct', 'structure', 'where',
  540 + ]
  541 +
  542 + symbolicid_reserved = [
  543 + # Core
  544 + ':', '\|', '=', '=>', '->', '#',
  545 + # Modules
  546 + ':>',
  547 + ]
  548 +
  549 + nonid_reserved = [ '(', ')', '[', ']', '{', '}', ',', ';', '...', '_' ]
  550 +
  551 + alphanumid_re = r"[a-zA-Z][a-zA-Z0-9_']*"
  552 + symbolicid_re = r"[!%&$#+\-/:<=>?@\\~`^|*]+"
  553 +
  554 + # A character constant is a sequence of the form #s, where s is a string
  555 + # constant denoting a string of size one character. This setup just parses
  556 + # the entire string as either a String.Double or a String.Char (depending
  557 + # on the argument), even if the String.Char is an erronous
  558 + # multiple-character string.
  559 + def stringy (whatkind):
  560 + return [
  561 + (r'[^"\\]', whatkind),
  562 + (r'\\[\\\"abtnvfr]', String.Escape),
  563 + (r'\\\^[@-^]', String.Escape),
  564 + (r'\\[0-9]{3}', String.Escape),
  565 + (r'\\u[0-9a-fA-F]{4}', String.Escape),
  566 + (r'\\\s+\\', String.Interpol),
  567 + (r'"', whatkind, '#pop'),
  568 + ]
  569 +
  570 + # Callbacks for distinguishing tokens and reserved words
  571 + def long_id_callback(self, match):
  572 + if match.group(1) in self.alphanumid_reserved: token = Error
  573 + else: token = Name.Namespace
  574 + yield match.start(1), token, match.group(1)
  575 + yield match.start(2), Punctuation, match.group(2)
  576 +
  577 + def end_id_callback(self, match):
  578 + if match.group(1) in self.alphanumid_reserved: token = Error
  579 + elif match.group(1) in self.symbolicid_reserved: token = Error
  580 + else: token = Name
  581 + yield match.start(1), token, match.group(1)
  582 +
  583 + def id_callback(self, match):
  584 + str = match.group(1)
  585 + if str in self.alphanumid_reserved: token = Keyword.Reserved
  586 + elif str in self.symbolicid_reserved: token = Punctuation
  587 + else: token = Name
  588 + yield match.start(1), token, str
  589 +
  590 + tokens = {
  591 + # Whitespace and comments are (almost) everywhere
  592 + 'whitespace': [
  593 + (r'\s+', Text),
  594 + (r'\(\*', Comment.Multiline, 'comment'),
  595 + ],
  596 +
  597 + 'delimiters': [
  598 + # This lexer treats these delimiters specially:
  599 + # Delimiters define scopes, and the scope is how the meaning of
  600 + # the `|' is resolved - is it a case/handle expression, or function
  601 + # definition by cases? (This is not how the Definition works, but
  602 + # it's how MLton behaves, see http://mlton.org/SMLNJDeviations)
  603 + (r'\(|\[|{', Punctuation, 'main'),
  604 + (r'\)|\]|}', Punctuation, '#pop'),
  605 + (r'\b(let|if|local)\b(?!\')', Keyword.Reserved, ('main', 'main')),
  606 + (r'\b(struct|sig|while)\b(?!\')', Keyword.Reserved, 'main'),
  607 + (r'\b(do|else|end|in|then)\b(?!\')', Keyword.Reserved, '#pop'),
  608 + ],
  609 +
  610 + 'core': [
  611 + # Punctuation that doesn't overlap symbolic identifiers
  612 + (r'(%s)' % '|'.join([re.escape(z) for z in nonid_reserved]),
  613 + Punctuation),
  614 +
  615 + # Special constants: strings, floats, numbers in decimal and hex
  616 + (r'#"', String.Char, 'char'),
  617 + (r'"', String.Double, 'string'),
  618 + (r'~?0x[0-9a-fA-F]+', Number.Hex),
  619 + (r'0wx[0-9a-fA-F]+', Number.Hex),
  620 + (r'0w\d+', Number.Integer),
  621 + (r'~?\d+\.\d+[eE]~?\d+', Number.Float),
  622 + (r'~?\d+\.\d+', Number.Float),
  623 + (r'~?\d+[eE]~?\d+', Number.Float),
  624 + (r'~?\d+', Number.Integer),
  625 +
  626 + # Labels
  627 + (r'#\s*[1-9][0-9]*', Name.Label),
  628 + (r'#\s*(%s)' % alphanumid_re, Name.Label),
  629 + (r'#\s+(%s)' % symbolicid_re, Name.Label),
  630 + # Some reserved words trigger a special, local lexer state change
  631 + (r'\b(datatype|abstype)\b(?!\')', Keyword.Reserved, 'dname'),
  632 + (r'(?=\b(exception)\b(?!\'))', Text, ('ename')),
  633 + (r'\b(functor|include|open|signature|structure)\b(?!\')',
  634 + Keyword.Reserved, 'sname'),
  635 + (r'\b(type|eqtype)\b(?!\')', Keyword.Reserved, 'tname'),
  636 +
  637 + # Regular identifiers, long and otherwise
  638 + (r'\'[0-9a-zA-Z_\']*', Name.Decorator),
  639 + (r'(%s)(\.)' % alphanumid_re, long_id_callback, "dotted"),
  640 + (r'(%s)' % alphanumid_re, id_callback),
  641 + (r'(%s)' % symbolicid_re, id_callback),
  642 + ],
  643 + 'dotted': [
  644 + (r'(%s)(\.)' % alphanumid_re, long_id_callback),
  645 + (r'(%s)' % alphanumid_re, end_id_callback, "#pop"),
  646 + (r'(%s)' % symbolicid_re, end_id_callback, "#pop"),
  647 + (r'\s+', Error),
  648 + (r'\S+', Error),
  649 + ],
  650 +
  651 +
  652 + # Main parser (prevents errors in files that have scoping errors)
  653 + 'root': [ (r'', Text, 'main') ],
  654 +
  655 + # In this scope, I expect '|' to not be followed by a function name,
  656 + # and I expect 'and' to be followed by a binding site
  657 + 'main': [
  658 + include('whitespace'),
  659 +
  660 + # Special behavior of val/and/fun
  661 + (r'\b(val|and)\b(?!\')', Keyword.Reserved, 'vname'),
  662 + (r'\b(fun)\b(?!\')', Keyword.Reserved,
  663 + ('#pop', 'main-fun', 'fname')),
  664 +
  665 + include('delimiters'),
  666 + include('core'),
  667 + (r'\S+', Error),
  668 + ],
  669 +
  670 + # In this scope, I expect '|' and 'and' to be followed by a function
  671 + 'main-fun': [
  672 + include('whitespace'),
  673 +
  674 + (r'\s', Text),
  675 + (r'\(\*', Comment.Multiline, 'comment'),
  676 +
  677 + # Special behavior of val/and/fun
  678 + (r'\b(fun|and)\b(?!\')', Keyword.Reserved, 'fname'),
  679 + (r'\b(val)\b(?!\')', Keyword.Reserved,
  680 + ('#pop', 'main', 'vname')),
  681 +
  682 + # Special behavior of '|' and '|'-manipulating keywords
  683 + (r'\|', Punctuation, 'fname'),
  684 + (r'\b(case|handle)\b(?!\')', Keyword.Reserved,
  685 + ('#pop', 'main')),
  686 +
  687 + include('delimiters'),
  688 + include('core'),
  689 + (r'\S+', Error),
  690 + ],
  691 +
  692 + # Character and string parsers
  693 + 'char': stringy(String.Char),
  694 + 'string': stringy(String.Double),
  695 +
  696 + 'breakout': [
  697 + (r'(?=\b(%s)\b(?!\'))' % '|'.join(alphanumid_reserved), Text, '#pop'),
  698 + ],
  699 +
  700 + # Dealing with what comes after module system keywords
  701 + 'sname': [
  702 + include('whitespace'),
  703 + include('breakout'),
  704 +
  705 + (r'(%s)' % alphanumid_re, Name.Namespace),
  706 + (r'', Text, '#pop'),
  707 + ],
  708 +
  709 + # Dealing with what comes after the 'fun' (or 'and' or '|') keyword
  710 + 'fname': [
  711 + include('whitespace'),
  712 + (r'\'[0-9a-zA-Z_\']*', Name.Decorator),
  713 + (r'\(', Punctuation, 'tyvarseq'),
  714 +
  715 + (r'(%s)' % alphanumid_re, Name.Function, '#pop'),
  716 + (r'(%s)' % symbolicid_re, Name.Function, '#pop'),
  717 +
  718 + # Ignore interesting function declarations like "fun (x + y) = ..."
  719 + (r'', Text, '#pop'),
  720 + ],
  721 +
  722 + # Dealing with what comes after the 'val' (or 'and') keyword
  723 + 'vname': [
  724 + include('whitespace'),
  725 + (r'\'[0-9a-zA-Z_\']*', Name.Decorator),
  726 + (r'\(', Punctuation, 'tyvarseq'),
  727 +
  728 + (r'(%s)(\s*)(=(?!%s))' % (alphanumid_re, symbolicid_re),
  729 + bygroups(Name.Variable, Text, Punctuation), '#pop'),
  730 + (r'(%s)(\s*)(=(?!%s))' % (symbolicid_re, symbolicid_re),
  731 + bygroups(Name.Variable, Text, Punctuation), '#pop'),
  732 + (r'(%s)' % alphanumid_re, Name.Variable, '#pop'),
  733 + (r'(%s)' % symbolicid_re, Name.Variable, '#pop'),
  734 +
  735 + # Ignore interesting patterns like 'val (x, y)'
  736 + (r'', Text, '#pop'),
  737 + ],
  738 +
  739 + # Dealing with what comes after the 'type' (or 'and') keyword
  740 + 'tname': [
  741 + include('whitespace'),
  742 + include('breakout'),
  743 +
  744 + (r'\'[0-9a-zA-Z_\']*', Name.Decorator),
  745 + (r'\(', Punctuation, 'tyvarseq'),
  746 + (r'=(?!%s)' % symbolicid_re, Punctuation, ('#pop', 'typbind')),
  747 +
  748 + (r'(%s)' % alphanumid_re, Keyword.Type),
  749 + (r'(%s)' % symbolicid_re, Keyword.Type),
  750 + (r'\S+', Error, '#pop'),
  751 + ],
  752 +
  753 + # A type binding includes most identifiers
  754 + 'typbind': [
  755 + include('whitespace'),
  756 +
  757 + (r'\b(and)\b(?!\')', Keyword.Reserved, ('#pop', 'tname')),
  758 +
  759 + include('breakout'),
  760 + include('core'),
  761 + (r'\S+', Error, '#pop'),
  762 + ],
  763 +
  764 + # Dealing with what comes after the 'datatype' (or 'and') keyword
  765 + 'dname': [
  766 + include('whitespace'),
  767 + include('breakout'),
  768 +
  769 + (r'\'[0-9a-zA-Z_\']*', Name.Decorator),
  770 + (r'\(', Punctuation, 'tyvarseq'),
  771 + (r'(=)(\s*)(datatype)',
  772 + bygroups(Punctuation, Text, Keyword.Reserved), '#pop'),
  773 + (r'=(?!%s)' % symbolicid_re, Punctuation,
  774 + ('#pop', 'datbind', 'datcon')),
  775 +
  776 + (r'(%s)' % alphanumid_re, Keyword.Type),
  777 + (r'(%s)' % symbolicid_re, Keyword.Type),
  778 + (r'\S+', Error, '#pop'),
  779 + ],
  780 +
  781 + # common case - A | B | C of int
  782 + 'datbind': [
  783 + include('whitespace'),
  784 +
  785 + (r'\b(and)\b(?!\')', Keyword.Reserved, ('#pop', 'dname')),
  786 + (r'\b(withtype)\b(?!\')', Keyword.Reserved, ('#pop', 'tname')),
  787 + (r'\b(of)\b(?!\')', Keyword.Reserved),
  788 +
  789 + (r'(\|)(\s*)(%s)' % alphanumid_re,
  790 + bygroups(Punctuation, Text, Name.Class)),
  791 + (r'(\|)(\s+)(%s)' % symbolicid_re,
  792 + bygroups(Punctuation, Text, Name.Class)),
  793 +
  794 + include('breakout'),
  795 + include('core'),
  796 + (r'\S+', Error),
  797 + ],
  798 +
  799 + # Dealing with what comes after an exception
  800 + 'ename': [
  801 + include('whitespace'),
  802 +
  803 + (r'(exception|and)\b(\s+)(%s)' % alphanumid_re,
  804 + bygroups(Keyword.Reserved, Text, Name.Class)),
  805 + (r'(exception|and)\b(\s*)(%s)' % symbolicid_re,
  806 + bygroups(Keyword.Reserved, Text, Name.Class)),
  807 + (r'\b(of)\b(?!\')', Keyword.Reserved),
  808 +
  809 + include('breakout'),
  810 + include('core'),
  811 + (r'\S+', Error),
  812 + ],
  813 +
  814 + 'datcon': [
  815 + include('whitespace'),
  816 + (r'(%s)' % alphanumid_re, Name.Class, '#pop'),
  817 + (r'(%s)' % symbolicid_re, Name.Class, '#pop'),
  818 + (r'\S+', Error, '#pop'),
  819 + ],
  820 +
  821 + # Series of type variables
  822 + 'tyvarseq': [
  823 + (r'\s', Text),
  824 + (r'\(\*', Comment.Multiline, 'comment'),
  825 +
  826 + (r'\'[0-9a-zA-Z_\']*', Name.Decorator),
  827 + (alphanumid_re, Name),
  828 + (r',', Punctuation),
  829 + (r'\)', Punctuation, '#pop'),
  830 + (symbolicid_re, Name),
  831 + ],
  832 +
  833 + 'comment': [
  834 + (r'[^(*)]', Comment.Multiline),
  835 + (r'\(\*', Comment.Multiline, '#push'),
  836 + (r'\*\)', Comment.Multiline, '#pop'),
  837 + (r'[(*)]', Comment.Multiline),
  838 + ],
  839 + }
  840 +
  841 +
518 842 class OcamlLexer(RegexLexer):
519 843 """
520 844 For the OCaml language.
407 vendor/pygments-main/pygments/lexers/math.py
@@ -17,8 +17,8 @@
17 17
18 18 from pygments.lexers.agile import PythonLexer
19 19
20   -__all__ = ['MuPADLexer', 'MatlabLexer', 'MatlabSessionLexer', 'NumPyLexer',
21   - 'RConsoleLexer', 'SLexer']
  20 +__all__ = ['MuPADLexer', 'MatlabLexer', 'MatlabSessionLexer', 'OctaveLexer',
  21 + 'NumPyLexer', 'RConsoleLexer', 'SLexer']
22 22
23 23
24 24 class MuPADLexer(RegexLexer):
@@ -94,13 +94,13 @@ class MuPADLexer(RegexLexer):
94 94
95 95 class MatlabLexer(RegexLexer):
96 96 """
97   - For Matlab (or GNU Octave) source code.
  97 + For Matlab source code.
98 98 Contributed by Ken Schutte <kschutte@csail.mit.edu>.
99 99
100 100 *New in Pygments 0.10.*
101 101 """
102 102 name = 'Matlab'
103   - aliases = ['matlab', 'octave']
  103 + aliases = ['matlab']
104 104 filenames = ['*.m']
105 105 mimetypes = ['text/matlab']
106 106
@@ -195,11 +195,12 @@ def analyse_text(text):
195 195 return 0.9
196 196 return 0.1
197 197
  198 +
198 199 line_re = re.compile('.*?\n')
199 200
200 201 class MatlabSessionLexer(Lexer):
201 202 """
202   - For Matlab (or GNU Octave) sessions. Modeled after PythonConsoleLexer.
  203 + For Matlab sessions. Modeled after PythonConsoleLexer.
203 204 Contributed by Ken Schutte <kschutte@csail.mit.edu>.
204 205
205 206 *New in Pygments 0.10.*
@@ -246,12 +247,404 @@ def get_tokens_unprocessed(self, text):
246 247 yield item
247 248
248 249
  250 +class OctaveLexer(RegexLexer):
  251 + """
  252 + For GNU Octave source code.
  253 +
  254 + *New in Pygments 1.5.*
  255 + """
  256 + name = 'Octave'
  257 + aliases = ['octave']
  258 + filenames = ['*.m']
  259 + mimetypes = ['text/octave']
  260 +
  261 + # These lists are generated automatically.
  262 + # Run the following in bash shell:
  263 + #
  264 + # First dump all of the Octave manual into a plain text file:
  265 + #
  266 + # $ info octave --subnodes -o octave-manual
  267 + #
  268 + # Now grep through it:
  269 +
  270 + # for i in \
  271 + # "Built-in Function" "Command" "Function File" \
  272 + # "Loadable Function" "Mapping Function";
  273 + # do
  274 + # perl -e '@name = qw('"$i"');
  275 + # print lc($name[0]),"_kw = [\n"';
  276 + #
  277 + # perl -n -e 'print "\"$1\",\n" if /-- '"$i"': .* (\w*) \(/;' \
  278 + # octave-manual | sort | uniq ;
  279 + # echo "]" ;
  280 + # echo;
  281 + # done
  282 +
  283 + # taken from Octave Mercurial changeset 8cc154f45e37 (30-jan-2011)
  284 +
  285 + builtin_kw = [ "addlistener", "addpath", "addproperty", "all",
  286 + "and", "any", "argnames", "argv", "assignin",
  287 + "atexit", "autoload",
  288 + "available_graphics_toolkits", "beep_on_error",
  289 + "bitand", "bitmax", "bitor", "bitshift", "bitxor",
  290 + "cat", "cell", "cellstr", "char", "class", "clc",
  291 + "columns", "command_line_path",
  292 + "completion_append_char", "completion_matches",
  293 + "complex", "confirm_recursive_rmdir", "cputime",
  294 + "crash_dumps_octave_core", "ctranspose", "cumprod",
  295 + "cumsum", "debug_on_error", "debug_on_interrupt",
  296 + "debug_on_warning", "default_save_options",
  297 + "dellistener", "diag", "diff", "disp",
  298 + "doc_cache_file", "do_string_escapes", "double",
  299 + "drawnow", "e", "echo_executing_commands", "eps",
  300 + "eq", "errno", "errno_list", "error", "eval",
  301 + "evalin", "exec", "exist", "exit", "eye", "false",
  302 + "fclear", "fclose", "fcntl", "fdisp", "feof",
  303 + "ferror", "feval", "fflush", "fgetl", "fgets",
  304 + "fieldnames", "file_in_loadpath", "file_in_path",
  305 + "filemarker", "filesep", "find_dir_in_path",
  306 + "fixed_point_format", "fnmatch", "fopen", "fork",
  307 + "formula", "fprintf", "fputs", "fread", "freport",
  308 + "frewind", "fscanf", "fseek", "fskipl", "ftell",
  309 + "functions", "fwrite", "ge", "genpath", "get",
  310 + "getegid", "getenv", "geteuid", "getgid",
  311 + "getpgrp", "getpid", "getppid", "getuid", "glob",
  312 + "gt", "gui_mode", "history_control",
  313 + "history_file", "history_size",
  314 + "history_timestamp_format_string", "home",
  315 + "horzcat", "hypot", "ifelse",
  316 + "ignore_function_time_stamp", "inferiorto",
  317 + "info_file", "info_program", "inline", "input",
  318 + "intmax", "intmin", "ipermute",
  319 + "is_absolute_filename", "isargout", "isbool",
  320 + "iscell", "iscellstr", "ischar", "iscomplex",
  321 + "isempty", "isfield", "isfloat", "isglobal",
  322 + "ishandle", "isieee", "isindex", "isinteger",
  323 + "islogical", "ismatrix", "ismethod", "isnull",
  324 + "isnumeric", "isobject", "isreal",
  325 + "is_rooted_relative_filename", "issorted",
  326 + "isstruct", "isvarname", "kbhit", "keyboard",
  327 + "kill", "lasterr", "lasterror", "lastwarn",
  328 + "ldivide", "le", "length", "link", "linspace",
  329 + "logical", "lstat", "lt", "make_absolute_filename",
  330 + "makeinfo_program", "max_recursion_depth", "merge",
  331 + "methods", "mfilename", "minus", "mislocked",
  332 + "mkdir", "mkfifo", "mkstemp", "mldivide", "mlock",
  333 + "mouse_wheel_zoom", "mpower", "mrdivide", "mtimes",
  334 + "munlock", "nargin", "nargout",
  335 + "native_float_format", "ndims", "ne", "nfields",
  336 + "nnz", "norm", "not", "numel", "nzmax",
  337 + "octave_config_info", "octave_core_file_limit",
  338 + "octave_core_file_name",
  339 + "octave_core_file_options", "ones", "or",
  340 + "output_max_field_width", "output_precision",
  341 + "page_output_immediately", "page_screen_output",
  342 + "path", "pathsep", "pause", "pclose", "permute",
  343 + "pi", "pipe", "plus", "popen", "power",
  344 + "print_empty_dimensions", "printf",
  345 + "print_struct_array_contents", "prod",
  346 + "program_invocation_name", "program_name",
  347 + "putenv", "puts", "pwd", "quit", "rats", "rdivide",
  348 + "readdir", "readlink", "read_readline_init_file",
  349 + "realmax", "realmin", "rehash", "rename",
  350 + "repelems", "re_read_readline_init_file", "reset",
  351 + "reshape", "resize", "restoredefaultpath",
  352 + "rethrow", "rmdir", "rmfield", "rmpath", "rows",
  353 + "save_header_format_string", "save_precision",
  354 + "saving_history", "scanf", "set", "setenv",
  355 + "shell_cmd", "sighup_dumps_octave_core",
  356 + "sigterm_dumps_octave_core", "silent_functions",
  357 + "single", "size", "size_equal", "sizemax",
  358 + "sizeof", "sleep", "source", "sparse_auto_mutate",
  359 + "split_long_rows", "sprintf", "squeeze", "sscanf",
  360 + "stat", "stderr", "stdin", "stdout", "strcmp",
  361 + "strcmpi", "string_fill_char", "strncmp",
  362 + "strncmpi", "struct", "struct_levels_to_print",
  363 + "strvcat", "subsasgn", "subsref", "sum", "sumsq",
  364 + "superiorto", "suppress_verbose_help_message",
  365 + "symlink", "system", "tic", "tilde_expand",
  366 + "times", "tmpfile", "tmpnam", "toc", "toupper",
  367 + "transpose", "true", "typeinfo", "umask", "uminus",
  368 + "uname", "undo_string_escapes", "unlink", "uplus",
  369 + "upper", "usage", "usleep", "vec", "vectorize",
  370 + "vertcat", "waitpid", "warning", "warranty",
  371 + "whos_line_format", "yes_or_no", "zeros",
  372 + "inf", "Inf", "nan", "NaN"]
  373 +
  374 + command_kw = [ "close", "load", "who", "whos", ]
  375 +
  376 + function_kw = [ "accumarray", "accumdim", "acosd", "acotd",
  377 + "acscd", "addtodate", "allchild", "ancestor",
  378 + "anova", "arch_fit", "arch_rnd", "arch_test",
  379 + "area", "arma_rnd", "arrayfun", "ascii", "asctime",
  380 + "asecd", "asind", "assert", "atand",
  381 + "autoreg_matrix", "autumn", "axes", "axis", "bar",
  382 + "barh", "bartlett", "bartlett_test", "beep",
  383 + "betacdf", "betainv", "betapdf", "betarnd",
  384 + "bicgstab", "bicubic", "binary", "binocdf",
  385 + "binoinv", "binopdf", "binornd", "bitcmp",
  386 + "bitget", "bitset", "blackman", "blanks",
  387 + "blkdiag", "bone", "box", "brighten", "calendar",
  388 + "cast", "cauchy_cdf", "cauchy_inv", "cauchy_pdf",
  389 + "cauchy_rnd", "caxis", "celldisp", "center", "cgs",
  390 + "chisquare_test_homogeneity",
  391 + "chisquare_test_independence", "circshift", "cla",
  392 + "clabel", "clf", "clock", "cloglog", "closereq",
  393 + "colon", "colorbar", "colormap", "colperm",
  394 + "comet", "common_size", "commutation_matrix",
  395 + "compan", "compare_versions", "compass",
  396 + "computer", "cond", "condest", "contour",
  397 + "contourc", "contourf", "contrast", "conv",
  398 + "convhull", "cool", "copper", "copyfile", "cor",
  399 + "corrcoef", "cor_test", "cosd", "cotd", "cov",
  400 + "cplxpair", "cross", "cscd", "cstrcat", "csvread",
  401 + "csvwrite", "ctime", "cumtrapz", "curl", "cut",
  402 + "cylinder", "date", "datenum", "datestr",
  403 + "datetick", "datevec", "dblquad", "deal",
  404 + "deblank", "deconv", "delaunay", "delaunayn",
  405 + "delete", "demo", "detrend", "diffpara", "diffuse",
  406 + "dir", "discrete_cdf", "discrete_inv",
  407 + "discrete_pdf", "discrete_rnd", "display",
  408 + "divergence", "dlmwrite", "dos", "dsearch",
  409 + "dsearchn", "duplication_matrix", "durbinlevinson",
  410 + "ellipsoid", "empirical_cdf", "empirical_inv",
  411 + "empirical_pdf", "empirical_rnd", "eomday",
  412 + "errorbar", "etime", "etreeplot", "example",
  413 + "expcdf", "expinv", "expm", "exppdf", "exprnd",
  414 + "ezcontour", "ezcontourf", "ezmesh", "ezmeshc",
  415 + "ezplot", "ezpolar", "ezsurf", "ezsurfc", "factor",
  416 + "factorial", "fail", "fcdf", "feather", "fftconv",
  417 + "fftfilt", "fftshift", "figure", "fileattrib",
  418 + "fileparts", "fill", "findall", "findobj",
  419 + "findstr", "finv", "flag", "flipdim", "fliplr",
  420 + "flipud", "fpdf", "fplot", "fractdiff", "freqz",
  421 + "freqz_plot", "frnd", "fsolve",
  422 + "f_test_regression", "ftp", "fullfile", "fzero",
  423 + "gamcdf", "gaminv", "gampdf", "gamrnd", "gca",
  424 + "gcbf", "gcbo", "gcf", "genvarname", "geocdf",
  425 + "geoinv", "geopdf", "geornd", "getfield", "ginput",
  426 + "glpk", "gls", "gplot", "gradient",
  427 + "graphics_toolkit", "gray", "grid", "griddata",
  428 + "griddatan", "gtext", "gunzip", "gzip", "hadamard",
  429 + "hamming", "hankel", "hanning", "hggroup",
  430 + "hidden", "hilb", "hist", "histc", "hold", "hot",
  431 + "hotelling_test", "housh", "hsv", "hurst",
  432 + "hygecdf", "hygeinv", "hygepdf", "hygernd",
  433 + "idivide", "ifftshift", "image", "imagesc",
  434 + "imfinfo", "imread", "imshow", "imwrite", "index",
  435 + "info", "inpolygon", "inputname", "interpft",
  436 + "interpn", "intersect", "invhilb", "iqr", "isa",
  437 + "isdefinite", "isdir", "is_duplicate_entry",
  438 + "isequal", "isequalwithequalnans", "isfigure",
  439 + "ishermitian", "ishghandle", "is_leap_year",
  440 + "isletter", "ismac", "ismember", "ispc", "isprime",
  441 + "isprop", "isscalar", "issquare", "isstrprop",
  442 + "issymmetric", "isunix", "is_valid_file_id",
  443 + "isvector", "jet", "kendall",
  444 + "kolmogorov_smirnov_cdf",
  445 + "kolmogorov_smirnov_test", "kruskal_wallis_test",
  446 + "krylov", "kurtosis", "laplace_cdf", "laplace_inv",
  447 + "laplace_pdf", "laplace_rnd", "legend", "legendre",
  448 + "license", "line", "linkprop", "list_primes",
  449 + "loadaudio", "loadobj", "logistic_cdf",
  450 + "logistic_inv", "logistic_pdf", "logistic_rnd",
  451 + "logit", "loglog", "loglogerr", "logm", "logncdf",
  452 + "logninv", "lognpdf", "lognrnd", "logspace",
  453 + "lookfor", "ls_command", "lsqnonneg", "magic",
  454 + "mahalanobis", "manova", "matlabroot",
  455 + "mcnemar_test", "mean", "meansq", "median", "menu",
  456 + "mesh", "meshc", "meshgrid", "meshz", "mexext",
  457 + "mget", "mkpp", "mode", "moment", "movefile",
  458 + "mpoles", "mput", "namelengthmax", "nargchk",
  459 + "nargoutchk", "nbincdf", "nbininv", "nbinpdf",
  460 + "nbinrnd", "nchoosek", "ndgrid", "newplot", "news",
  461 + "nonzeros", "normcdf", "normest", "norminv",
  462 + "normpdf", "normrnd", "now", "nthroot", "null",
  463 + "ocean", "ols", "onenormest", "optimget",
  464 + "optimset", "orderfields", "orient", "orth",
  465 + "pack", "pareto", "parseparams", "pascal", "patch",
  466 + "pathdef", "pcg", "pchip", "pcolor", "pcr",
  467 + "peaks", "periodogram", "perl", "perms", "pie",
  468 + "pink", "planerot", "playaudio", "plot",
  469 + "plotmatrix", "plotyy", "poisscdf", "poissinv",
  470 + "poisspdf", "poissrnd", "polar", "poly",
  471 + "polyaffine", "polyarea", "polyderiv", "polyfit",
  472 + "polygcd", "polyint", "polyout", "polyreduce",
  473 + "polyval", "polyvalm", "postpad", "powerset",
  474 + "ppder", "ppint", "ppjumps", "ppplot", "ppval",
  475 + "pqpnonneg", "prepad", "primes", "print",
  476 + "print_usage", "prism", "probit", "qp", "qqplot",
  477 + "quadcc", "quadgk", "quadl", "quadv", "quiver",
  478 + "qzhess", "rainbow", "randi", "range", "rank",
  479 + "ranks", "rat", "reallog", "realpow", "realsqrt",
  480 + "record", "rectangle_lw", "rectangle_sw",
  481 + "rectint", "refresh", "refreshdata",
  482 + "regexptranslate", "repmat", "residue", "ribbon",
  483 + "rindex", "roots", "rose", "rosser", "rotdim",
  484 + "rref", "run", "run_count", "rundemos", "run_test",
  485 + "runtests", "saveas", "saveaudio", "saveobj",
  486 + "savepath", "scatter", "secd", "semilogx",
  487 + "semilogxerr", "semilogy", "semilogyerr",
  488 + "setaudio", "setdiff", "setfield", "setxor",
  489 + "shading", "shift", "shiftdim", "sign_test",
  490 + "sinc", "sind", "sinetone", "sinewave", "skewness",
  491 + "slice", "sombrero", "sortrows", "spaugment",
  492 + "spconvert", "spdiags", "spearman", "spectral_adf",
  493 + "spectral_xdf", "specular", "speed", "spencer",
  494 + "speye", "spfun", "sphere", "spinmap", "spline",
  495 + "spones", "sprand", "sprandn", "sprandsym",
  496 + "spring", "spstats", "spy", "sqp", "stairs",
  497 + "statistics", "std", "stdnormal_cdf",
  498 + "stdnormal_inv", "stdnormal_pdf", "stdnormal_rnd",
  499 + "stem", "stft", "strcat", "strchr", "strjust",
  500 + "strmatch", "strread", "strsplit", "strtok",
  501 + "strtrim", "strtrunc", "structfun", "studentize",
  502 + "subplot", "subsindex", "subspace", "substr",
  503 + "substruct", "summer", "surf", "surface", "surfc",
  504 + "surfl", "surfnorm", "svds", "swapbytes",
  505 + "sylvester_matrix", "symvar", "synthesis", "table",
  506 + "tand", "tar", "tcdf", "tempdir", "tempname",
  507 + "test", "text", "textread", "textscan", "tinv",
  508 + "title", "toeplitz", "tpdf", "trace", "trapz",
  509 + "treelayout", "treeplot", "triangle_lw",
  510 + "triangle_sw", "tril", "trimesh", "triplequad",
  511 + "triplot", "trisurf", "triu", "trnd", "tsearchn",
  512 + "t_test", "t_test_regression", "type", "unidcdf",
  513 + "unidinv", "unidpdf", "unidrnd", "unifcdf",
  514 + "unifinv", "unifpdf", "unifrnd", "union", "unique",
  515 + "unix", "unmkpp", "unpack", "untabify", "untar",
  516 + "unwrap", "unzip", "u_test", "validatestring",
  517 + "vander", "var", "var_test", "vech", "ver",
  518 + "version", "view", "voronoi", "voronoin",
  519 + "waitforbuttonpress", "wavread", "wavwrite",
  520 + "wblcdf", "wblinv", "wblpdf", "wblrnd", "weekday",
  521 + "welch_test", "what", "white", "whitebg",
  522 + "wienrnd", "wilcoxon_test", "wilkinson", "winter",
  523 + "xlabel", "xlim", "ylabel", "yulewalker", "zip",
  524 + "zlabel", "z_test", ]
  525 +
  526 + loadable_kw = [ "airy", "amd", "balance", "besselh", "besseli",
  527 + "besselj", "besselk", "bessely", "bitpack",
  528 + "bsxfun", "builtin", "ccolamd", "cellfun",
  529 + "cellslices", "chol", "choldelete", "cholinsert",
  530 + "cholinv", "cholshift", "cholupdate", "colamd",
  531 + "colloc", "convhulln", "convn", "csymamd",
  532 + "cummax", "cummin", "daspk", "daspk_options",
  533 + "dasrt", "dasrt_options", "dassl", "dassl_options",
  534 + "dbclear", "dbdown", "dbstack", "dbstatus",
  535 + "dbstop", "dbtype", "dbup", "dbwhere", "det",
  536 + "dlmread", "dmperm", "dot", "eig", "eigs",
  537 + "endgrent", "endpwent", "etree", "fft", "fftn",
  538 + "fftw", "filter", "find", "full", "gcd",
  539 + "getgrent", "getgrgid", "getgrnam", "getpwent",
  540 + "getpwnam", "getpwuid", "getrusage", "givens",
  541 + "gmtime", "gnuplot_binary", "hess", "ifft",
  542 + "ifftn", "inv", "isdebugmode", "issparse", "kron",
  543 + "localtime", "lookup", "lsode", "lsode_options",
  544 + "lu", "luinc", "luupdate", "matrix_type", "max",
  545 + "min", "mktime", "pinv", "qr", "qrdelete",
  546 + "qrinsert", "qrshift", "qrupdate", "quad",
  547 + "quad_options", "qz", "rand", "rande", "randg",
  548 + "randn", "randp", "randperm", "rcond", "regexp",
  549 + "regexpi", "regexprep", "schur", "setgrent",
  550 + "setpwent", "sort", "spalloc", "sparse", "spparms",
  551 + "sprank", "sqrtm", "strfind", "strftime",
  552 + "strptime", "strrep", "svd", "svd_driver", "syl",
  553 + "symamd", "symbfact", "symrcm", "time", "tsearch",
  554 + "typecast", "urlread", "urlwrite", ]
  555 +
  556 + mapping_kw = [ "abs", "acos", "acosh", "acot", "acoth", "acsc",
  557 + "acsch", "angle", "arg", "asec", "asech", "asin",
  558 + "asinh", "atan", "atanh", "beta", "betainc",
  559 + "betaln", "bincoeff", "cbrt", "ceil", "conj", "cos",
  560 + "cosh", "cot", "coth", "csc", "csch", "erf", "erfc",
  561 + "erfcx", "erfinv", "exp", "finite", "fix", "floor",
  562 + "fmod", "gamma", "gammainc", "gammaln", "imag",
  563 + "isalnum", "isalpha", "isascii", "iscntrl",
  564 + "isdigit", "isfinite", "isgraph", "isinf",
  565 + "islower", "isna", "isnan", "isprint", "ispunct",
  566 + "isspace", "isupper", "isxdigit", "lcm", "lgamma",
  567 + "log", "lower", "mod", "real", "rem", "round",
  568 + "roundb", "sec", "sech", "sign", "sin", "sinh",
  569 + "sqrt", "tan", "tanh", "toascii", "tolower", "xor",
  570 + ]
  571 +
  572 + builtin_consts = [ "EDITOR", "EXEC_PATH", "I", "IMAGE_PATH", "NA",
  573 + "OCTAVE_HOME", "OCTAVE_VERSION", "PAGER",
  574 + "PAGER_FLAGS", "SEEK_CUR", "SEEK_END", "SEEK_SET",
  575 + "SIG", "S_ISBLK", "S_ISCHR", "S_ISDIR", "S_ISFIFO",
  576 + "S_ISLNK", "S_ISREG", "S_ISSOCK", "WCONTINUE",
  577 + "WCOREDUMP", "WEXITSTATUS", "WIFCONTINUED",
  578 + "WIFEXITED", "WIFSIGNALED", "WIFSTOPPED", "WNOHANG",
  579 + "WSTOPSIG", "WTERMSIG", "WUNTRACED", ]
  580 +
  581 + tokens = {
  582 + 'root': [
  583 + #We should look into multiline comments
  584 + (r'[%#].*$', Comment),
  585 + (r'^\s*function', Keyword, 'deffunc'),
  586 +
  587 + # from 'iskeyword' on hg changeset 8cc154f45e37
  588 + (r'(__FILE__|__LINE__|break|case|catch|classdef|continue|do|else|'
  589 + r'elseif|end|end_try_catch|end_unwind_protect|endclassdef|'
  590 + r'endevents|endfor|endfunction|endif|endmethods|endproperties|'
  591 + r'endswitch|endwhile|events|for|function|get|global|if|methods|'
  592 + r'otherwise|persistent|properties|return|set|static|switch|try|'
  593 + r'until|unwind_protect|unwind_protect_cleanup|while)\b', Keyword),
  594 +
  595 + ("(" + "|".join( builtin_kw + command_kw
  596 + + function_kw + loadable_kw
  597 + + mapping_kw) + r')\b', Name.Builtin),
  598 +
  599 + ("(" + "|".join(builtin_consts) + r')\b', Name.Constant),
  600 +
  601 + # operators in Octave but not Matlab:
  602 + (r'-=|!=|!|/=|--', Operator),
  603 + # operators:
  604 + (r'-|==|~=|<|>|<=|>=|&&|&|~|\|\|?', Operator),
  605 + # operators in Octave but not Matlab requiring escape for re:
  606 + (r'\*=|\+=|\^=|\/=|\\=|\*\*|\+\+|\.\*\*',Operator),
  607 + # operators requiring escape for re:
  608 + (r'\.\*|\*|\+|\.\^|\.\\|\.\/|\/|\\', Operator),
  609 +
  610 +
  611 + # punctuation:
  612 + (r'\[|\]|\(|\)|\{|\}|:|@|\.|,', Punctuation),
  613 + (r'=|:|;', Punctuation),
  614 +
  615 + (r'"[^"]*"', String),
  616 +
  617 + # quote can be transpose, instead of string:
  618 + # (not great, but handles common cases...)
  619 + (r'(?<=[\w\)\]])\'', Operator),
  620 + (r'(?<![\w\)\]])\'', String, 'string'),
  621 +
  622 + ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
  623 + (r'.', Text),
  624 + ],
  625 + 'string': [
  626 + (r"[^']*'", String, '#pop'),
  627 + ],
  628 + 'deffunc': [
  629 + (r'(\s*)(?:(.+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
  630 + bygroups(Text.Whitespace, Text, Text.Whitespace, Punctuation,
  631 + Text.Whitespace, Name.Function, Punctuation, Text,
  632 + Punctuation, Text.Whitespace), '#pop'),
  633 + ],
  634 + }
  635 +
  636 + def analyse_text(text):
  637 + if re.match('^\s*[%#]', text, re.M): #Comment
  638 + return 0.9
  639 + return 0.1
  640 +
  641 +
249 642 class NumPyLexer(PythonLexer):
250   - '''
  643 + """
251 644 A Python lexer recognizing Numerical Python builtins.
252 645
253 646 *New in Pygments 0.10.*
254   - '''
  647 + """
255 648
256 649 name = 'NumPy'
257 650 aliases = ['numpy']
380 vendor/pygments-main/pygments/lexers/other.py
@@ -12,7 +12,7 @@
12 12 import re
13 13
14 14 from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
15   - this, do_insertions
  15 + this, do_insertions, combined
16 16 from pygments.token import Error, Punctuation, Literal, Token, \
17 17 Text, Comment, Operator, Keyword, Name, String, Number, Generic
18 18 from pygments.util import shebang_matches
@@ -26,7 +26,8 @@
26 26 'BashSessionLexer', 'ModelicaLexer', 'RebolLexer', 'ABAPLexer',
27 27 'NewspeakLexer', 'GherkinLexer', 'AsymptoteLexer',
28 28 'PostScriptLexer', 'AutohotkeyLexer', 'GoodDataCLLexer',
29   - 'MaqlLexer', 'ProtoBufLexer', 'HybrisLexer', 'AwkLexer']
  29 + 'MaqlLexer', 'ProtoBufLexer', 'HybrisLexer', 'AwkLexer',
  30 + 'Cfengine3Lexer']
30 31
31 32 line_re = re.compile('.*?\n')
32 33
@@ -2428,198 +2429,177 @@ class AutohotkeyLexer(RegexLexer):
2428 2429 filenames = ['*.ahk', '*.ahkl']
2429 2430 mimetypes = ['text/x-autohotkey']
2430 2431
2431   - flags = re.IGNORECASE | re.DOTALL | re.MULTILINE
2432   -
2433 2432 tokens = {
2434 2433 'root': [
2435   - include('whitespace'),
2436   - (r'^\(', String, 'continuation'),
2437   - include('comments'),
2438