annotate MoinMoin/support/pygments/lexers/functional.py @ 5564:74fa6f714526

upgraded pygments to 1.2.2
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 21 Feb 2010 23:52:54 +0100
parents 0970ed47d2cd
children f76914e77229
rev   line source
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
2 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
3 pygments.lexers.functional
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
5
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
6 Lexers for functional languages.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
7
5564
74fa6f714526 upgraded pygments to 1.2.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5184
diff changeset
8 :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS.
5184
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
9 :license: BSD, see LICENSE for details.
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
10 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
11
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
12 import re
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
13 try:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
14 set
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
15 except NameError:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
16 from sets import Set as set
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
17
5184
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
18 from pygments.lexer import Lexer, RegexLexer, bygroups, include, do_insertions
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
19 from pygments.token import Text, Comment, Operator, Keyword, Name, \
5184
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
20 String, Number, Punctuation, Literal, Generic
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
21
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
22
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
23 __all__ = ['SchemeLexer', 'CommonLispLexer', 'HaskellLexer', 'LiterateHaskellLexer',
5184
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
24 'OcamlLexer', 'ErlangLexer', 'ErlangShellLexer']
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
25
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
26
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
27 class SchemeLexer(RegexLexer):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
28 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
29 A Scheme lexer, parsing a stream and outputting the tokens
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
30 needed to highlight scheme code.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
31 This lexer could be most probably easily subclassed to parse
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
32 other LISP-Dialects like Common Lisp, Emacs Lisp or AutoLisp.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
33
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
34 This parser is checked with pastes from the LISP pastebin
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
35 at http://paste.lisp.org/ to cover as much syntax as possible.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
36
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
37 It supports the full Scheme syntax as defined in R5RS.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
38
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
39 *New in Pygments 0.6.*
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
40 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
41 name = 'Scheme'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
42 aliases = ['scheme', 'scm']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
43 filenames = ['*.scm']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
44 mimetypes = ['text/x-scheme', 'application/x-scheme']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
45
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
46 # list of known keywords and builtins taken form vim 6.4 scheme.vim
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
47 # syntax file.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
48 keywords = [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
49 'lambda', 'define', 'if', 'else', 'cond', 'and', 'or', 'case', 'let',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
50 'let*', 'letrec', 'begin', 'do', 'delay', 'set!', '=>', 'quote',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
51 'quasiquote', 'unquote', 'unquote-splicing', 'define-syntax',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
52 'let-syntax', 'letrec-syntax', 'syntax-rules'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
53 ]
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
54 builtins = [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
55 '*', '+', '-', '/', '<', '<=', '=', '>', '>=', 'abs', 'acos', 'angle',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
56 'append', 'apply', 'asin', 'assoc', 'assq', 'assv', 'atan',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
57 'boolean?', 'caaaar', 'caaadr', 'caaar', 'caadar', 'caaddr', 'caadr',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
58 'caar', 'cadaar', 'cadadr', 'cadar', 'caddar', 'cadddr', 'caddr',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
59 'cadr', 'call-with-current-continuation', 'call-with-input-file',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
60 'call-with-output-file', 'call-with-values', 'call/cc', 'car',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
61 'cdaaar', 'cdaadr', 'cdaar', 'cdadar', 'cdaddr', 'cdadr', 'cdar',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
62 'cddaar', 'cddadr', 'cddar', 'cdddar', 'cddddr', 'cdddr', 'cddr',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
63 'cdr', 'ceiling', 'char->integer', 'char-alphabetic?', 'char-ci<=?',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
64 'char-ci<?', 'char-ci=?', 'char-ci>=?', 'char-ci>?', 'char-downcase',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
65 'char-lower-case?', 'char-numeric?', 'char-ready?', 'char-upcase',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
66 'char-upper-case?', 'char-whitespace?', 'char<=?', 'char<?', 'char=?',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
67 'char>=?', 'char>?', 'char?', 'close-input-port', 'close-output-port',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
68 'complex?', 'cons', 'cos', 'current-input-port', 'current-output-port',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
69 'denominator', 'display', 'dynamic-wind', 'eof-object?', 'eq?',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
70 'equal?', 'eqv?', 'eval', 'even?', 'exact->inexact', 'exact?', 'exp',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
71 'expt', 'floor', 'for-each', 'force', 'gcd', 'imag-part',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
72 'inexact->exact', 'inexact?', 'input-port?', 'integer->char',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
73 'integer?', 'interaction-environment', 'lcm', 'length', 'list',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
74 'list->string', 'list->vector', 'list-ref', 'list-tail', 'list?',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
75 'load', 'log', 'magnitude', 'make-polar', 'make-rectangular',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
76 'make-string', 'make-vector', 'map', 'max', 'member', 'memq', 'memv',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
77 'min', 'modulo', 'negative?', 'newline', 'not', 'null-environment',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
78 'null?', 'number->string', 'number?', 'numerator', 'odd?',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
79 'open-input-file', 'open-output-file', 'output-port?', 'pair?',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
80 'peek-char', 'port?', 'positive?', 'procedure?', 'quotient',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
81 'rational?', 'rationalize', 'read', 'read-char', 'real-part', 'real?',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
82 'remainder', 'reverse', 'round', 'scheme-report-environment',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
83 'set-car!', 'set-cdr!', 'sin', 'sqrt', 'string', 'string->list',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
84 'string->number', 'string->symbol', 'string-append', 'string-ci<=?',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
85 'string-ci<?', 'string-ci=?', 'string-ci>=?', 'string-ci>?',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
86 'string-copy', 'string-fill!', 'string-length', 'string-ref',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
87 'string-set!', 'string<=?', 'string<?', 'string=?', 'string>=?',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
88 'string>?', 'string?', 'substring', 'symbol->string', 'symbol?',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
89 'tan', 'transcript-off', 'transcript-on', 'truncate', 'values',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
90 'vector', 'vector->list', 'vector-fill!', 'vector-length',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
91 'vector-ref', 'vector-set!', 'vector?', 'with-input-from-file',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
92 'with-output-to-file', 'write', 'write-char', 'zero?'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
93 ]
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
94
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
95 # valid names for identifiers
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
96 # well, names can only not consist fully of numbers
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
97 # but this should be good enough for now
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
98 valid_name = r'[a-zA-Z0-9!$%&*+,/:<=>?@^_~|-]+'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
99
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
100 tokens = {
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
101 'root' : [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
102 # the comments - always starting with semicolon
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
103 # and going to the end of the line
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
104 (r';.*$', Comment.Single),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
105
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
106 # whitespaces - usually not relevant
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
107 (r'\s+', Text),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
108
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
109 # numbers
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
110 (r'-?\d+\.\d+', Number.Float),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
111 (r'-?\d+', Number.Integer),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
112 # support for uncommon kinds of numbers -
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
113 # have to figure out what the characters mean
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
114 #(r'(#e|#i|#b|#o|#d|#x)[\d.]+', Number),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
115
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
116 # strings, symbols and characters
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
117 (r'"(\\\\|\\"|[^"])*"', String),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
118 (r"'" + valid_name, String.Symbol),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
119 (r"#\\([()/'\".'_!ยง$%& ?=+-]{1}|[a-zA-Z0-9]+)", String.Char),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
120
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
121 # constants
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
122 (r'(#t|#f)', Name.Constant),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
123
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
124 # special operators
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
125 (r"('|#|`|,@|,|\.)", Operator),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
126
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
127 # highlight the keywords
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
128 ('(%s)' % '|'.join([
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
129 re.escape(entry) + ' ' for entry in keywords]),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
130 Keyword
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
131 ),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
132
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
133 # first variable in a quoted string like
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
134 # '(this is syntactic sugar)
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
135 (r"(?<='\()" + valid_name, Name.Variable),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
136 (r"(?<=#\()" + valid_name, Name.Variable),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
137
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
138 # highlight the builtins
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
139 ("(?<=\()(%s)" % '|'.join([
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
140 re.escape(entry) + ' ' for entry in builtins]),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
141 Name.Builtin
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
142 ),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
143
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
144 # the remaining functions
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
145 (r'(?<=\()' + valid_name, Name.Function),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
146 # find the remaining variables
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
147 (valid_name, Name.Variable),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
148
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
149 # the famous parentheses!
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
150 (r'(\(|\))', Punctuation),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
151 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
152 }
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
153
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
154
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
155 class CommonLispLexer(RegexLexer):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
156 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
157 A Common Lisp lexer.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
158
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
159 *New in Pygments 0.9.*
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
160 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
161 name = 'Common Lisp'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
162 aliases = ['common-lisp', 'cl']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
163 filenames = ['*.cl', '*.lisp', '*.el'] # use for Elisp too
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
164 mimetypes = ['text/x-common-lisp']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
165
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
166 flags = re.IGNORECASE | re.MULTILINE
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
167
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
168 ### couple of useful regexes
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
169
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
170 # characters that are not macro-characters and can be used to begin a symbol
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
171 nonmacro = r'\\.|[a-zA-Z0-9!$%&*+-/<=>?@\[\]^_{}~]'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
172 constituent = nonmacro + '|[#.:]'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
173 terminated = r'(?=[ "()\'\n,;`])' # whitespace or terminating macro characters
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
174
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
175 ### symbol token, reverse-engineered from hyperspec
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
176 # Take a deep breath...
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
177 symbol = r'(\|[^|]+\||(?:%s)(?:%s)*)' % (nonmacro, constituent)
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
178
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
179 def __init__(self, **options):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
180 from pygments.lexers._clbuiltins import BUILTIN_FUNCTIONS, \
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
181 SPECIAL_FORMS, MACROS, LAMBDA_LIST_KEYWORDS, DECLARATIONS, \
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
182 BUILTIN_TYPES, BUILTIN_CLASSES
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
183 self.builtin_function = BUILTIN_FUNCTIONS
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
184 self.special_forms = SPECIAL_FORMS
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
185 self.macros = MACROS
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
186 self.lambda_list_keywords = LAMBDA_LIST_KEYWORDS
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
187 self.declarations = DECLARATIONS
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
188 self.builtin_types = BUILTIN_TYPES
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
189 self.builtin_classes = BUILTIN_CLASSES
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
190 RegexLexer.__init__(self, **options)
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
191
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
192 def get_tokens_unprocessed(self, text):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
193 stack = ['root']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
194 for index, token, value in RegexLexer.get_tokens_unprocessed(self, text, stack):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
195 if token is Name.Variable:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
196 if value in self.builtin_function:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
197 yield index, Name.Builtin, value
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
198 continue
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
199 if value in self.special_forms:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
200 yield index, Keyword, value
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
201 continue
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
202 if value in self.macros:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
203 yield index, Name.Builtin, value
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
204 continue
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
205 if value in self.lambda_list_keywords:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
206 yield index, Keyword, value
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
207 continue
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
208 if value in self.declarations:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
209 yield index, Keyword, value
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
210 continue
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
211 if value in self.builtin_types:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
212 yield index, Keyword.Type, value
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
213 continue
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
214 if value in self.builtin_classes:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
215 yield index, Name.Class, value
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
216 continue
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
217 yield index, token, value
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
218
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
219 tokens = {
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
220 'root' : [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
221 ('', Text, 'body'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
222 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
223 'multiline-comment' : [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
224 (r'#\|', Comment.Multiline, '#push'), # (cf. Hyperspec 2.4.8.19)
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
225 (r'\|#', Comment.Multiline, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
226 (r'[^|#]+', Comment.Multiline),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
227 (r'[|#]', Comment.Multiline),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
228 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
229 'commented-form' : [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
230 (r'\(', Comment.Preproc, '#push'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
231 (r'\)', Comment.Preproc, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
232 (r'[^()]+', Comment.Preproc),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
233 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
234 'body' : [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
235 # whitespace
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
236 (r'\s+', Text),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
237
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
238 # single-line comment
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
239 (r';.*$', Comment.Single),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
240
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
241 # multi-line comment
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
242 (r'#\|', Comment.Multiline, 'multiline-comment'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
243
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
244 # encoding comment (?)
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
245 (r'#\d*Y.*$', Comment.Special),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
246
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
247 # strings and characters
5564
74fa6f714526 upgraded pygments to 1.2.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5184
diff changeset
248 (r'"(\\.|[^"\\])*"', String),
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
249 # quoting
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
250 (r":" + symbol, String.Symbol),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
251 (r"'" + symbol, String.Symbol),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
252 (r"'", Operator),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
253 (r"`", Operator),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
254
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
255 # decimal numbers
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
256 (r'[-+]?\d+\.?' + terminated, Number.Integer),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
257 (r'[-+]?\d+/\d+' + terminated, Number),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
258 (r'[-+]?(\d*\.\d+([defls][-+]?\d+)?|\d+(\.\d*)?[defls][-+]?\d+)' \
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
259 + terminated, Number.Float),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
260
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
261 # sharpsign strings and characters
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
262 (r"#\\." + terminated, String.Char),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
263 (r"#\\" + symbol, String.Char),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
264
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
265 # vector
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
266 (r'#\(', Operator, 'body'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
267
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
268 # bitstring
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
269 (r'#\d*\*[01]*', Literal.Other),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
270
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
271 # uninterned symbol
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
272 (r'#:' + symbol, String.Symbol),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
273
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
274 # read-time and load-time evaluation
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
275 (r'#[.,]', Operator),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
276
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
277 # function shorthand
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
278 (r'#\'', Name.Function),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
279
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
280 # binary rational
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
281 (r'#[bB][+-]?[01]+(/[01]+)?', Number),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
282
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
283 # octal rational
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
284 (r'#[oO][+-]?[0-7]+(/[0-7]+)?', Number.Oct),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
285
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
286 # hex rational
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
287 (r'#[xX][+-]?[0-9a-fA-F]+(/[0-9a-fA-F]+)?', Number.Hex),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
288
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
289 # radix rational
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
290 (r'#\d+[rR][+-]?[0-9a-zA-Z]+(/[0-9a-zA-Z]+)?', Number),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
291
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
292 # complex
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
293 (r'(#[cC])(\()', bygroups(Number, Punctuation), 'body'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
294
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
295 # array
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
296 (r'(#\d+[aA])(\()', bygroups(Literal.Other, Punctuation), 'body'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
297
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
298 # structure
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
299 (r'(#[sS])(\()', bygroups(Literal.Other, Punctuation), 'body'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
300
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
301 # path
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
302 (r'#[pP]?"(\\.|[^"])*"', Literal.Other),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
303
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
304 # reference
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
305 (r'#\d+=', Operator),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
306 (r'#\d+#', Operator),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
307
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
308 # read-time comment
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
309 (r'#+nil' + terminated + '\s*\(', Comment.Preproc, 'commented-form'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
310
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
311 # read-time conditional
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
312 (r'#[+-]', Operator),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
313
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
314 # special operators that should have been parsed already
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
315 (r'(,@|,|\.)', Operator),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
316
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
317 # special constants
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
318 (r'(t|nil)' + terminated, Name.Constant),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
319
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
320 # functions and variables
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
321 (r'\*' + symbol + '\*', Name.Variable.Global),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
322 (symbol, Name.Variable),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
323
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
324 # parentheses
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
325 (r'\(', Punctuation, 'body'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
326 (r'\)', Punctuation, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
327 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
328 }
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
329
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
330
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
331 class HaskellLexer(RegexLexer):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
332 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
333 A Haskell lexer based on the lexemes defined in the Haskell 98 Report.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
334
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
335 *New in Pygments 0.8.*
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
336 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
337 name = 'Haskell'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
338 aliases = ['haskell', 'hs']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
339 filenames = ['*.hs']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
340 mimetypes = ['text/x-haskell']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
341
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
342 reserved = ['case','class','data','default','deriving','do','else',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
343 'if','in','infix[lr]?','instance',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
344 'let','newtype','of','then','type','where','_']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
345 ascii = ['NUL','SOH','[SE]TX','EOT','ENQ','ACK',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
346 'BEL','BS','HT','LF','VT','FF','CR','S[OI]','DLE',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
347 'DC[1-4]','NAK','SYN','ETB','CAN',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
348 'EM','SUB','ESC','[FGRU]S','SP','DEL']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
349
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
350 tokens = {
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
351 'root': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
352 # Whitespace:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
353 (r'\s+', Text),
5184
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
354 #(r'--\s*|.*$', Comment.Doc),
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
355 (r'--(?![!#$%&*+./<=>?@\^|_~]).*?$', Comment.Single),
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
356 (r'{-', Comment.Multiline, 'comment'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
357 # Lexemes:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
358 # Identifiers
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
359 (r'\bimport\b', Keyword.Reserved, 'import'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
360 (r'\bmodule\b', Keyword.Reserved, 'module'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
361 (r'\berror\b', Name.Exception),
5184
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
362 (r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved),
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
363 (r'^[_a-z][\w\']*', Name.Function),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
364 (r'[_a-z][\w\']*', Name),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
365 (r'[A-Z][\w\']*', Keyword.Type),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
366 # Operators
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
367 (r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function), # lambda operator
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
368 (r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
369 (r':[:!#$%&*+.\\/<=>?@^|~-]*', Keyword.Type), # Constructor operators
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
370 (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator), # Other operators
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
371 # Numbers
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
372 (r'\d+[eE][+-]?\d+', Number.Float),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
373 (r'\d+\.\d+([eE][+-]?\d+)?', Number.Float),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
374 (r'0[oO][0-7]+', Number.Oct),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
375 (r'0[xX][\da-fA-F]+', Number.Hex),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
376 (r'\d+', Number.Integer),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
377 # Character/String Literals
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
378 (r"'", String.Char, 'character'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
379 (r'"', String, 'string'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
380 # Special
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
381 (r'\[\]', Keyword.Type),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
382 (r'\(\)', Name.Builtin),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
383 (r'[][(),;`{}]', Punctuation),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
384 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
385 'import': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
386 # Import statements
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
387 (r'\s+', Text),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
388 # after "funclist" state
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
389 (r'\)', Punctuation, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
390 (r'qualified\b', Keyword),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
391 # import X as Y
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
392 (r'([A-Z][a-zA-Z0-9_.]*)(\s+)(as)(\s+)([A-Z][a-zA-Z0-9_.]*)',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
393 bygroups(Name.Namespace, Text, Keyword, Text, Name), '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
394 # import X hiding (functions)
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
395 (r'([A-Z][a-zA-Z0-9_.]*)(\s+)(hiding)(\s+)(\()',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
396 bygroups(Name.Namespace, Text, Keyword, Text, Punctuation), 'funclist'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
397 # import X (functions)
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
398 (r'([A-Z][a-zA-Z0-9_.]*)(\s+)(\()',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
399 bygroups(Name.Namespace, Text, Punctuation), 'funclist'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
400 # import X
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
401 (r'[a-zA-Z0-9_.]+', Name.Namespace, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
402 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
403 'module': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
404 (r'\s+', Text),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
405 (r'([A-Z][a-zA-Z0-9_.]*)(\s+)(\()',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
406 bygroups(Name.Namespace, Text, Punctuation), 'funclist'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
407 (r'[A-Z][a-zA-Z0-9_.]*', Name.Namespace, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
408 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
409 'funclist': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
410 (r'\s+', Text),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
411 (r'[A-Z][a-zA-Z0-9_]*', Keyword.Type),
5184
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
412 (r'[_a-z][\w\']+', Name.Function),
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
413 (r'--.*$', Comment.Single),
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
414 (r'{-', Comment.Multiline, 'comment'),
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
415 (r',', Punctuation),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
416 (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
417 # (HACK, but it makes sense to push two instances, believe me)
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
418 (r'\(', Punctuation, ('funclist', 'funclist')),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
419 (r'\)', Punctuation, '#pop:2'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
420 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
421 'comment': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
422 # Multiline Comments
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
423 (r'[^-{}]+', Comment.Multiline),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
424 (r'{-', Comment.Multiline, '#push'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
425 (r'-}', Comment.Multiline, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
426 (r'[-{}]', Comment.Multiline),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
427 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
428 'character': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
429 # Allows multi-chars, incorrectly.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
430 (r"[^\\']", String.Char),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
431 (r"\\", String.Escape, 'escape'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
432 ("'", String.Char, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
433 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
434 'string': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
435 (r'[^\\"]+', String),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
436 (r"\\", String.Escape, 'escape'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
437 ('"', String, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
438 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
439 'escape': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
440 (r'[abfnrtv"\'&\\]', String.Escape, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
441 (r'\^[][A-Z@\^_]', String.Escape, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
442 ('|'.join(ascii), String.Escape, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
443 (r'o[0-7]+', String.Escape, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
444 (r'x[\da-fA-F]+', String.Escape, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
445 (r'\d+', String.Escape, '#pop'),
5564
74fa6f714526 upgraded pygments to 1.2.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5184
diff changeset
446 (r'\s+\\', String.Escape, '#pop'),
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
447 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
448 }
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
449
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
450
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
451 line_re = re.compile('.*?\n')
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
452 bird_re = re.compile(r'(>[ \t]*)(.*\n)')
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
453
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
454 class LiterateHaskellLexer(Lexer):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
455 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
456 For Literate Haskell (Bird-style or LaTeX) source.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
457
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
458 Additional options accepted:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
459
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
460 `litstyle`
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
461 If given, must be ``"bird"`` or ``"latex"``. If not given, the style
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
462 is autodetected: if the first non-whitespace character in the source
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
463 is a backslash or percent character, LaTeX is assumed, else Bird.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
464
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
465 *New in Pygments 0.9.*
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
466 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
467 name = 'Literate Haskell'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
468 aliases = ['lhs', 'literate-haskell']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
469 filenames = ['*.lhs']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
470 mimetypes = ['text/x-literate-haskell']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
471
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
472 def get_tokens_unprocessed(self, text):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
473 hslexer = HaskellLexer(**self.options)
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
474
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
475 style = self.options.get('litstyle')
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
476 if style is None:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
477 style = (text.lstrip()[0] in '%\\') and 'latex' or 'bird'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
478
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
479 code = ''
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
480 insertions = []
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
481 if style == 'bird':
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
482 # bird-style
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
483 for match in line_re.finditer(text):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
484 line = match.group()
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
485 m = bird_re.match(line)
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
486 if m:
5184
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
487 insertions.append((len(code),
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
488 [(0, Comment.Special, m.group(1))]))
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
489 code += m.group(2)
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
490 else:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
491 insertions.append((len(code), [(0, Text, line)]))
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
492 else:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
493 # latex-style
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
494 from pygments.lexers.text import TexLexer
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
495 lxlexer = TexLexer(**self.options)
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
496
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
497 codelines = 0
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
498 latex = ''
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
499 for match in line_re.finditer(text):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
500 line = match.group()
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
501 if codelines:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
502 if line.lstrip().startswith('\\end{code}'):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
503 codelines = 0
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
504 latex += line
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
505 else:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
506 code += line
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
507 elif line.lstrip().startswith('\\begin{code}'):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
508 codelines = 1
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
509 latex += line
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
510 insertions.append((len(code),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
511 list(lxlexer.get_tokens_unprocessed(latex))))
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
512 latex = ''
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
513 else:
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
514 latex += line
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
515 insertions.append((len(code),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
516 list(lxlexer.get_tokens_unprocessed(latex))))
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
517 for item in do_insertions(insertions, hslexer.get_tokens_unprocessed(code)):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
518 yield item
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
519
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
520
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
521 class OcamlLexer(RegexLexer):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
522 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
523 For the OCaml language.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
524
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
525 *New in Pygments 0.7.*
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
526 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
527
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
528 name = 'OCaml'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
529 aliases = ['ocaml']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
530 filenames = ['*.ml', '*.mli', '*.mll', '*.mly']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
531 mimetypes = ['text/x-ocaml']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
532
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
533 keywords = [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
534 'as', 'assert', 'begin', 'class', 'constraint', 'do', 'done',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
535 'downto', 'else', 'end', 'exception', 'external', 'false',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
536 'for', 'fun', 'function', 'functor', 'if', 'in', 'include',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
537 'inherit', 'initializer', 'lazy', 'let', 'match', 'method',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
538 'module', 'mutable', 'new', 'object', 'of', 'open', 'private',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
539 'raise', 'rec', 'sig', 'struct', 'then', 'to', 'true', 'try',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
540 'type', 'val', 'virtual', 'when', 'while', 'with'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
541 ]
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
542 keyopts = [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
543 '!=','#','&','&&','\(','\)','\*','\+',',','-',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
544 '-\.','->','\.','\.\.',':','::',':=',':>',';',';;','<',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
545 '<-','=','>','>]','>}','\?','\?\?','\[','\[<','\[>','\[\|',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
546 ']','_','`','{','{<','\|','\|]','}','~'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
547 ]
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
548
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
549 operators = r'[!$%&*+\./:<=>?@^|~-]'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
550 word_operators = ['and', 'asr', 'land', 'lor', 'lsl', 'lxor', 'mod', 'or']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
551 prefix_syms = r'[!?~]'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
552 infix_syms = r'[=<>@^|&+\*/$%-]'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
553 primitives = ['unit', 'int', 'float', 'bool', 'string', 'char', 'list', 'array']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
554
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
555 tokens = {
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
556 'escape-sequence': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
557 (r'\\[\"\'ntbr]', String.Escape),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
558 (r'\\[0-9]{3}', String.Escape),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
559 (r'\\x[0-9a-fA-F]{2}', String.Escape),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
560 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
561 'root': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
562 (r'\s+', Text),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
563 (r'false|true|\(\)|\[\]', Name.Builtin.Pseudo),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
564 (r'\b([A-Z][A-Za-z0-9_\']*)(?=\s*\.)',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
565 Name.Namespace, 'dotted'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
566 (r'\b([A-Z][A-Za-z0-9_\']*)', Name.Class),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
567 (r'\(\*', Comment, 'comment'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
568 (r'\b(%s)\b' % '|'.join(keywords), Keyword),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
569 (r'(%s)' % '|'.join(keyopts), Operator),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
570 (r'(%s|%s)?%s' % (infix_syms, prefix_syms, operators), Operator),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
571 (r'\b(%s)\b' % '|'.join(word_operators), Operator.Word),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
572 (r'\b(%s)\b' % '|'.join(primitives), Keyword.Type),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
573
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
574 (r"[^\W\d][\w']*", Name),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
575
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
576 (r'\d[\d_]*', Number.Integer),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
577 (r'0[xX][\da-fA-F][\da-fA-F_]*', Number.Hex),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
578 (r'0[oO][0-7][0-7_]*', Number.Oct),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
579 (r'0[bB][01][01_]*', Number.Binary),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
580 (r'-?\d[\d_]*(.[\d_]*)?([eE][+\-]?\d[\d_]*)', Number.Float),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
581
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
582 (r"'(?:(\\[\\\"'ntbr ])|(\\[0-9]{3})|(\\x[0-9a-fA-F]{2}))'",
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
583 String.Char),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
584 (r"'.'", String.Char),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
585 (r"'", Keyword), # a stray quote is another syntax element
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
586
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
587 (r'"', String.Double, 'string'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
588
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
589 (r'[~?][a-z][\w\']*:', Name.Variable),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
590 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
591 'comment': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
592 (r'[^(*)]+', Comment),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
593 (r'\(\*', Comment, '#push'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
594 (r'\*\)', Comment, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
595 (r'[(*)]', Comment),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
596 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
597 'string': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
598 (r'[^\\"]+', String.Double),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
599 include('escape-sequence'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
600 (r'\\\n', String.Double),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
601 (r'"', String.Double, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
602 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
603 'dotted': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
604 (r'\s+', Text),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
605 (r'\.', Punctuation),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
606 (r'[A-Z][A-Za-z0-9_\']*(?=\s*\.)', Name.Namespace),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
607 (r'[A-Z][A-Za-z0-9_\']*', Name.Class, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
608 (r'[a-z][a-z0-9_\']*', Name, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
609 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
610 }
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
611
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
612
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
613 class ErlangLexer(RegexLexer):
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
614 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
615 For the Erlang functional programming language.
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
616
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
617 Blame Jeremy Thurgood (http://jerith.za.net/).
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
618
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
619 *New in Pygments 0.9.*
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
620 """
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
621
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
622 name = 'Erlang'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
623 aliases = ['erlang']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
624 filenames = ['*.erl', '*.hrl']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
625 mimetypes = ['text/x-erlang']
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
626
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
627 keywords = [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
628 'after', 'begin', 'case', 'catch', 'cond', 'end', 'fun', 'if',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
629 'let', 'of', 'query', 'receive', 'try', 'when',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
630 ]
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
631
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
632 builtins = [ # See erlang(3) man page
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
633 'abs', 'append_element', 'apply', 'atom_to_list', 'binary_to_list',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
634 'bitstring_to_list', 'binary_to_term', 'bit_size', 'bump_reductions',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
635 'byte_size', 'cancel_timer', 'check_process_code', 'delete_module',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
636 'demonitor', 'disconnect_node', 'display', 'element', 'erase', 'exit',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
637 'float', 'float_to_list', 'fun_info', 'fun_to_list',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
638 'function_exported', 'garbage_collect', 'get', 'get_keys',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
639 'group_leader', 'hash', 'hd', 'integer_to_list', 'iolist_to_binary',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
640 'iolist_size', 'is_atom', 'is_binary', 'is_bitstring', 'is_boolean',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
641 'is_builtin', 'is_float', 'is_function', 'is_integer', 'is_list',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
642 'is_number', 'is_pid', 'is_port', 'is_process_alive', 'is_record',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
643 'is_reference', 'is_tuple', 'length', 'link', 'list_to_atom',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
644 'list_to_binary', 'list_to_bitstring', 'list_to_existing_atom',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
645 'list_to_float', 'list_to_integer', 'list_to_pid', 'list_to_tuple',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
646 'load_module', 'localtime_to_universaltime', 'make_tuple', 'md5',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
647 'md5_final', 'md5_update', 'memory', 'module_loaded', 'monitor',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
648 'monitor_node', 'node', 'nodes', 'open_port', 'phash', 'phash2',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
649 'pid_to_list', 'port_close', 'port_command', 'port_connect',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
650 'port_control', 'port_call', 'port_info', 'port_to_list',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
651 'process_display', 'process_flag', 'process_info', 'purge_module',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
652 'put', 'read_timer', 'ref_to_list', 'register', 'resume_process',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
653 'round', 'send', 'send_after', 'send_nosuspend', 'set_cookie',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
654 'setelement', 'size', 'spawn', 'spawn_link', 'spawn_monitor',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
655 'spawn_opt', 'split_binary', 'start_timer', 'statistics',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
656 'suspend_process', 'system_flag', 'system_info', 'system_monitor',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
657 'system_profile', 'term_to_binary', 'tl', 'trace', 'trace_delivered',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
658 'trace_info', 'trace_pattern', 'trunc', 'tuple_size', 'tuple_to_list',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
659 'universaltime_to_localtime', 'unlink', 'unregister', 'whereis'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
660 ]
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
661
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
662 operators = r'(\+|-|\*|/|<|>|=|==|/=|=:=|=/=|=<|>=|\+\+|--|<-|!)'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
663 word_operators = [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
664 'and', 'andalso', 'band', 'bnot', 'bor', 'bsl', 'bsr', 'bxor',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
665 'div', 'not', 'or', 'orelse', 'rem', 'xor'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
666 ]
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
667
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
668 atom_re = r"(?:[a-z][a-zA-Z0-9_]*|'[^\n']*[^\\]')"
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
669
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
670 variable_re = r'(?:[A-Z_][a-zA-Z0-9_]*)'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
671
5184
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
672 escape_re = r'(?:\\(?:[bdefnrstv\'"\\/]|[0-7][0-7]?[0-7]?|\^[a-zA-Z]))'
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
673
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
674 macro_re = r'(?:'+variable_re+r'|'+atom_re+r')'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
675
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
676 base_re = r'(?:[2-9]|[12][0-9]|3[0-6])'
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
677
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
678 tokens = {
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
679 'root': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
680 (r'\s+', Text),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
681 (r'%.*\n', Comment),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
682 ('(' + '|'.join(keywords) + r')\b', Keyword),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
683 ('(' + '|'.join(builtins) + r')\b', Name.Builtin),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
684 ('(' + '|'.join(word_operators) + r')\b', Operator.Word),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
685 (r'^-', Punctuation, 'directive'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
686 (operators, Operator),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
687 (r'"', String, 'string'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
688 (r'<<', Name.Label),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
689 (r'>>', Name.Label),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
690 (r'('+atom_re+')(:)', bygroups(Name.Namespace, Punctuation)),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
691 (r'^('+atom_re+r')(\s*)(\()', bygroups(Name.Function, Text, Punctuation)),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
692 (r'[+-]?'+base_re+r'#[0-9a-zA-Z]+', Number.Integer),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
693 (r'[+-]?\d+', Number.Integer),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
694 (r'[+-]?\d+.\d+', Number.Float),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
695 (r'[][:_@\".{}()|;,]', Punctuation),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
696 (variable_re, Name.Variable),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
697 (atom_re, Name),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
698 (r'\?'+macro_re, Name.Constant),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
699 (r'\$(?:'+escape_re+r'|\\[ %]|[^\\])', String.Char),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
700 (r'#'+atom_re+r'(:?\.'+atom_re+r')?', Name.Label),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
701 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
702 'string': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
703 (escape_re, String.Escape),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
704 (r'"', String, '#pop'),
5184
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
705 (r'~[0-9.*]*[~#+bBcdefginpPswWxX]', String.Interpol),
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
706 (r'[^"\\~]+', String),
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
707 (r'~', String),
4377
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
708 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
709 'directive': [
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
710 (r'(define)(\s*)(\()('+macro_re+r')',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
711 bygroups(Name.Entity, Text, Punctuation, Name.Constant), '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
712 (r'(record)(\s*)(\()('+macro_re+r')',
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
713 bygroups(Name.Entity, Text, Punctuation, Name.Label), '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
714 (atom_re, Name.Entity, '#pop'),
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
715 ],
00b1307bd9c2 Adding Pygments to MoinMoin/support
Radomir Dopieralski <moindev@sheep.art.pl>
parents:
diff changeset
716 }
5184
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
717
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
718
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
719 class ErlangShellLexer(Lexer):
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
720 """
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
721 Shell sessions in erl (for Erlang code).
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
722
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
723 *New in Pygments 1.1.*
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
724 """
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
725 name = 'Erlang erl session'
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
726 aliases = ['erl']
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
727 filenames = ['*.erl-sh']
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
728 mimetypes = ['text/x-erl-shellsession']
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
729
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
730 _prompt_re = re.compile(r'\d+>(?=\s|\Z)')
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
731
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
732 def get_tokens_unprocessed(self, text):
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
733 erlexer = ErlangLexer(**self.options)
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
734
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
735 curcode = ''
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
736 insertions = []
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
737 for match in line_re.finditer(text):
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
738 line = match.group()
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
739 m = self._prompt_re.match(line)
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
740 if m is not None:
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
741 end = m.end()
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
742 insertions.append((len(curcode),
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
743 [(0, Generic.Prompt, line[:end])]))
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
744 curcode += line[end:]
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
745 else:
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
746 if curcode:
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
747 for item in do_insertions(insertions,
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
748 erlexer.get_tokens_unprocessed(curcode)):
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
749 yield item
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
750 curcode = ''
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
751 insertions = []
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
752 if line.startswith('*'):
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
753 yield match.start(), Generic.Traceback, line
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
754 else:
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
755 yield match.start(), Generic.Output, line
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
756 if curcode:
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
757 for item in do_insertions(insertions,
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
758 erlexer.get_tokens_unprocessed(curcode)):
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
759 yield item
0970ed47d2cd updated pygments to 1.1.1+ ( http://dev.pocoo.org/hg/pygments-main/rev/948f8885af16 )
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4377
diff changeset
760