class HaskellLexer(RegexLexer): """
A Haskell lexer based on the lexemes defined in the Haskell 98 Report. """
name = 'Haskell'
url = 'https://www.haskell.org/'
aliases = ['haskell', 'hs']
filenames = ['*.hs']
mimetypes = ['text/x-haskell']
version_added = '0.8'
class CryptolLexer(RegexLexer): """
FIXME: A Cryptol2 lexer based on the lexemes defined in the Haskell 98 Report. """
name = 'Cryptol'
aliases = ['cryptol', 'cry']
filenames = ['*.cry']
mimetypes = ['text/x-cryptol']
url = 'https://www.cryptol.net'
version_added = '2.0'
def get_tokens_unprocessed(self, text):
stack = ['root'] for index, token, value in \
RegexLexer.get_tokens_unprocessed(self, text, stack): if token is Name and value in self.EXTRA_KEYWORDS: yield index, Name.Builtin, value else: yield index, token, value
class LiterateLexer(Lexer): """
Base classfor lexers of literate file formats based on LaTeX or Bird-style
(prefixing each code line with">").
Additional options accepted:
`litstyle` If given, must be ``"bird"`` or ``"latex"``. Ifnot given, the style is autodetected: if the first non-whitespace character in the source is a backslash or percent character, LaTeX is assumed, else Bird. """
code = ''
insertions = [] if style == 'bird': # bird-style for match in line_re.finditer(text):
line = match.group()
m = self.bird_re.match(line) if m:
insertions.append((len(code),
[(0, Comment.Special, m.group(1))]))
code += m.group(2) else:
insertions.append((len(code), [(0, Text, line)])) else: # latex-style from pygments.lexers.markup import TexLexer
lxlexer = TexLexer(**self.options)
codelines = 0
latex = '' for match in line_re.finditer(text):
line = match.group() if codelines: if line.lstrip().startswith('\\end{code}'):
codelines = 0
latex += line else:
code += line elif line.lstrip().startswith('\\begin{code}'):
codelines = 1
latex += line
insertions.append((len(code),
list(lxlexer.get_tokens_unprocessed(latex))))
latex = '' else:
latex += line
insertions.append((len(code),
list(lxlexer.get_tokens_unprocessed(latex)))) yieldfrom do_insertions(insertions, self.baselexer.get_tokens_unprocessed(code))
class LiterateHaskellLexer(LiterateLexer): """ For Literate Haskell (Bird-style or LaTeX) source.
Additional options accepted:
`litstyle` If given, must be ``"bird"`` or ``"latex"``. Ifnot given, the style is autodetected: if the first non-whitespace character in the source is a backslash or percent character, LaTeX is assumed, else Bird. """
name = 'Literate Haskell'
aliases = ['literate-haskell', 'lhaskell', 'lhs']
filenames = ['*.lhs']
mimetypes = ['text/x-literate-haskell']
url = 'https://wiki.haskell.org/Literate_programming'
version_added = '0.9'
class LiterateIdrisLexer(LiterateLexer): """ For Literate Idris (Bird-style or LaTeX) source.
Additional options accepted:
`litstyle` If given, must be ``"bird"`` or ``"latex"``. Ifnot given, the style is autodetected: if the first non-whitespace character in the source is a backslash or percent character, LaTeX is assumed, else Bird. """
name = 'Literate Idris'
aliases = ['literate-idris', 'lidris', 'lidr']
filenames = ['*.lidr']
mimetypes = ['text/x-literate-idris']
url = 'https://idris2.readthedocs.io/en/latest/reference/literate.html'
version_added = '2.0'
class LiterateAgdaLexer(LiterateLexer): """ For Literate Agda source.
Additional options accepted:
`litstyle` If given, must be ``"bird"`` or ``"latex"``. Ifnot given, the style is autodetected: if the first non-whitespace character in the source is a backslash or percent character, LaTeX is assumed, else Bird. """
name = 'Literate Agda'
aliases = ['literate-agda', 'lagda']
filenames = ['*.lagda']
mimetypes = ['text/x-literate-agda']
url = 'https://agda.readthedocs.io/en/latest/tools/literate-programming.html'
version_added = '2.0'
class LiterateCryptolLexer(LiterateLexer): """ For Literate Cryptol (Bird-style or LaTeX) source.
Additional options accepted:
`litstyle` If given, must be ``"bird"`` or ``"latex"``. Ifnot given, the style is autodetected: if the first non-whitespace character in the source is a backslash or percent character, LaTeX is assumed, else Bird. """
name = 'Literate Cryptol'
aliases = ['literate-cryptol', 'lcryptol', 'lcry']
filenames = ['*.lcry']
mimetypes = ['text/x-literate-cryptol']
url = 'https://www.cryptol.net'
version_added = '2.0'
# main lexer
tokens = { 'root': [
include('whitespace'),
# go into type mode
(r'::?' + sboundary, tokenType, 'type'),
(r'(alias)(\s+)([a-z]\w*)?', bygroups(Keyword, Whitespace, tokenTypeDef), 'alias-type'),
(r'(struct)(\s+)([a-z]\w*)?', bygroups(Keyword, Whitespace, tokenTypeDef), 'struct-type'),
((r'({})'.format('|'.join(typeStartKeywords))) +
r'(\s+)([a-z]\w*)?', bygroups(Keyword, Whitespace, tokenTypeDef), 'type'),
# special sequences of tokens (we use ?: for non-capturing group as # required by 'bygroups')
(r'(module)(\s+)(interface(?=\s))?(\s+)?((?:[a-z]\w*/)*[a-z]\w*)',
bygroups(Keyword, Whitespace, Keyword, Whitespace, Name.Namespace)),
(r'(import)(\s+)((?:[a-z]\w*/)*[a-z]\w*)'
r'(?:(\s*)(=)(\s*)(qualified)?(\s*)'
r'((?:[a-z]\w*/)*[a-z]\w*))?',
bygroups(Keyword, Whitespace, Name.Namespace, Whitespace, Keyword, Whitespace,
Keyword, Whitespace, Name.Namespace)),
# literals. No check for literal characters with len > 1
(r'[0-9]+\.[0-9]+([eE][\-+]?[0-9]+)?', Number.Float),
(r'0[xX][0-9a-fA-F]+', Number.Hex),
(r'[0-9]+', Number.Integer),
# type started by alias 'alias-type': [
(r'=', Keyword),
include('type')
],
# type started by struct 'struct-type': [
(r'(?=\((?!,*\)))', Punctuation, '#pop'),
include('type')
],
# type started by colon 'type': [
(r'[(\[<]', tokenType, 'type-nested'),
include('type-content')
],
# type nested in brackets: can contain parameters, comma etc. 'type-nested': [
(r'[)\]>]', tokenType, '#pop'),
(r'[(\[<]', tokenType, 'type-nested'),
(r',', tokenType),
(r'([a-z]\w*)(\s*)(:)(?!:)',
bygroups(Name, Whitespace, tokenType)), # parameter name
include('type-content')
],
# shared contents of a type 'type-content': [
include('whitespace'),
# keywords
(r'({})'.format('|'.join(typekeywords)) + boundary, Keyword),
(r'(?=(({})'.format('|'.join(keywords)) + boundary + '))',
Keyword, '#pop'), # need to match because names overlap...
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.