ThirdParty/Pygments/pygments/lexers/functional.py

changeset 684
2f29a0b6e1c7
parent 0
de9c2efb9d02
child 808
8f85926125ef
equal deleted inserted replaced
682:91114a975eda 684:2f29a0b6e1c7
3 pygments.lexers.functional 3 pygments.lexers.functional
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for functional languages. 6 Lexers for functional languages.
7 7
8 :copyright: Copyright 2006-2009 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 try:
14 set
15 except NameError:
16 from sets import Set as set
17 13
18 from pygments.lexer import Lexer, RegexLexer, bygroups, include, do_insertions 14 from pygments.lexer import Lexer, RegexLexer, bygroups, include, do_insertions
19 from pygments.token import Text, Comment, Operator, Keyword, Name, \ 15 from pygments.token import Text, Comment, Operator, Keyword, Name, \
20 String, Number, Punctuation, Literal, Generic 16 String, Number, Punctuation, Literal, Generic
21 17
243 239
244 # encoding comment (?) 240 # encoding comment (?)
245 (r'#\d*Y.*$', Comment.Special), 241 (r'#\d*Y.*$', Comment.Special),
246 242
247 # strings and characters 243 # strings and characters
248 (r'"(\\.|[^"])*"', String), 244 (r'"(\\.|[^"\\])*"', String),
249 # quoting 245 # quoting
250 (r":" + symbol, String.Symbol), 246 (r":" + symbol, String.Symbol),
251 (r"'" + symbol, String.Symbol), 247 (r"'" + symbol, String.Symbol),
252 (r"'", Operator), 248 (r"'", Operator),
253 (r"`", Operator), 249 (r"`", Operator),
441 (r'\^[][A-Z@\^_]', String.Escape, '#pop'), 437 (r'\^[][A-Z@\^_]', String.Escape, '#pop'),
442 ('|'.join(ascii), String.Escape, '#pop'), 438 ('|'.join(ascii), String.Escape, '#pop'),
443 (r'o[0-7]+', String.Escape, '#pop'), 439 (r'o[0-7]+', String.Escape, '#pop'),
444 (r'x[\da-fA-F]+', String.Escape, '#pop'), 440 (r'x[\da-fA-F]+', String.Escape, '#pop'),
445 (r'\d+', String.Escape, '#pop'), 441 (r'\d+', String.Escape, '#pop'),
446 (r'\n\s+\\', String.Escape, '#pop'), 442 (r'\s+\\', String.Escape, '#pop'),
447 ], 443 ],
448 } 444 }
449 445
450 446
451 line_re = re.compile('.*?\n') 447 line_re = re.compile('.*?\n')
472 def get_tokens_unprocessed(self, text): 468 def get_tokens_unprocessed(self, text):
473 hslexer = HaskellLexer(**self.options) 469 hslexer = HaskellLexer(**self.options)
474 470
475 style = self.options.get('litstyle') 471 style = self.options.get('litstyle')
476 if style is None: 472 if style is None:
477 style = (text.lstrip()[0] in '%\\') and 'latex' or 'bird' 473 style = (text.lstrip()[0:1] in '%\\') and 'latex' or 'bird'
478 474
479 code = '' 475 code = ''
480 insertions = [] 476 insertions = []
481 if style == 'bird': 477 if style == 'bird':
482 # bird-style 478 # bird-style

eric ide

mercurial