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'
tokens = { 'root': [ # Whitespace:
(r'\s+', Whitespace), # (r'--\s*|.*$', Comment.Doc),
(r'--(?![!#$%&*+./<=>?@^|_~:\\]).*?$', Comment.Single),
(r'\{-', Comment.Multiline, 'comment'), # Lexemes: # Identifiers
(r'\bimport\b', Keyword.Reserved, 'import'),
(r'\bmodule\b', Keyword.Reserved, 'module'),
(r'\berror\b', Name.Exception),
(r'\b({})(?!\')\b'.format('|'.join(reserved)), Keyword.Reserved),
(r"'[^\\]'", String.Char), # this has to come before the TH quote
(r'^[_' + uni.Ll + r'][\w\']*', Name.Function),
(r"'?[_" + uni.Ll + r"][\w']*", Name),
(r"('')?[" + uni.Lu + r"][\w\']*", Keyword.Type),
(r"(')[" + uni.Lu + r"][\w\']*", Keyword.Type),
(r"(')\[[^\]]*\]", Keyword.Type), # tuples and lists get special treatment in GHC
(r"(')\([^)]*\)", Keyword.Type), # ..
(r"(')[:!#$%&*+.\\/<=>?@^|~-]+", Keyword.Type), # promoted type operators # Operators
(r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function), # lambda operator
(r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials
(r':[:!#$%&*+.\\/<=>?@^|~-]*', Keyword.Type), # Constructor operators
(r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator), # Other operators # Numbers
(r'0[xX]_*[\da-fA-F](_*[\da-fA-F])*_*[pP][+-]?\d(_*\d)*', Number.Float),
(r'0[xX]_*[\da-fA-F](_*[\da-fA-F])*\.[\da-fA-F](_*[\da-fA-F])*'
r'(_*[pP][+-]?\d(_*\d)*)?', Number.Float),
(r'\d(_*\d)*_*[eE][+-]?\d(_*\d)*', Number.Float),
(r'\d(_*\d)*\.\d(_*\d)*(_*[eE][+-]?\d(_*\d)*)?', Number.Float),
(r'0[bB]_*[01](_*[01])*', Number.Bin),
(r'0[oO]_*[0-7](_*[0-7])*', Number.Oct),
(r'0[xX]_*[\da-fA-F](_*[\da-fA-F])*', Number.Hex),
(r'\d(_*\d)*', Number.Integer), # Character/String Literals
(r"'", String.Char, 'character'),
(r'"', String, 'string'), # Special
(r'\[\]', Keyword.Type),
(r'\(\)', Name.Builtin),
(r'[][(),;`{}]', Punctuation),
], 'import': [ # Import statements
(r'\s+', Whitespace),
(r'"', String, 'string'), # after "funclist" state
(r'\)', Punctuation, '#pop'),
(r'qualified\b', Keyword), # import X as Y
(r'([' + uni.Lu + r'][\w.]*)(\s+)(as)(\s+)([' + uni.Lu + r'][\w.]*)',
bygroups(Name.Namespace, Whitespace, Keyword, Whitespace, Name), '#pop'), # import X hiding (functions)
(r'([' + uni.Lu + r'][\w.]*)(\s+)(hiding)(\s+)(\()',
bygroups(Name.Namespace forand .
#importX(functions)
(r'([' + uni.Lu + r'][\w.
bygroups(Name.Namespace, Whitespace, Punctuation), 'funclist'), # import X from .lexer Lexer , bygroups, \
]java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 'module' , , Generic,Whitespace
(r'\s+', Whitespace),
('[ +uniLu r']\.*(s)\)'
bygroupsNameNamespaceWhitespacePunctuation,'')
(java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
, 'funclist': [
r's+, ),
r'' +.Lu ']\w' .Type
(r'( filenames hs]
(r'--(?![!#$%&*+./<=>?@^|_~:\\]).*?$', Comment.Single),
(r,CommentMultiline'',
(r',' ),
(r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator),
reserved =''class'ata,'efault deriving,'','else',
(r family,'if,'in,'[lr]?', instance
(r'), Punctuation 'pop:2)
], # NOTE: the next four states are shared in the AgdaLexer; make sure # any change is compatible with Agda as well or copy over and change
comment # Multiline Comments
r'-}+,CommentMultiline,
(r'\{-', Comment. -] NAK SYN '',CAN
('\' .,'pop')
(r'[-{}]'java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
, 'character': [ # Allows multi-chars, incorrectly. '#pop'),
(r"\\", String.Escape, 'escape'),
("'", String.Char.Reserved 'import
], 'string': [
r[\]' ,
(r"\\ r'b(}(!'\'format''joinreserved) Reserved,
('"', String, '#pop'),
],
(r(?_ uni. + r"[w]*", Name,
r\]' .Lu+ '^]' .Escape #'
(|.(ascii String,'
(r'o[0-7]+', String.Escape, ' r()\[\]]*\]" KeywordType, # tuples and lists get special treatment in GHC
rx\]+,StringEscape'pop)
(r'd' .,'#pop'),
r(\)(\)' bygroups(hitespace,StringEscape,'#pop'),
]
}
HspecLexer: """
A Haskell lexer with support for Hspec constructs. "java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
name(\(*d*_[]+?d_*d*,Number),
aliases = [' r\(*d*.d_[]+]\(*d*)' .)java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
filenames 'Spechs]
mimetypes = [](r0xX_[(*\da-fA-F)',NumberHex)
version_added 24java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
directives(' link,'', 'include' 'hide 'freeze','java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 '''logging', dynamic 'name, 'error_handlers language
tokens = { 'root': [
(r'^(\ r[ +uniLu+r]\.*,NameNamespace, #',
bygroups(Whitespace, Keyword.Reserved)),
(r'(\s*)(--(]
(r'(\s*)(\| (r\s+, Whitespace,
(r'(\s*)(\{-)', bygroups(Whitespace, Comment.Multiline), 'comment'),
# Declaration
(r'^(\s*)([^\s(){}]+)( (r'_\w\]+[ +uni + '[\w\]), Name.),
bygroups(Whitespace, Name. (r'\{-', Comment.Multiline, 'commen # Identifiers
(r'\b({ (HACK, but it makes sense to push two instances, believe me)
(r'importmodule(s),bygroupsKeywordReserved Whitespace,'module,
(r"('')?[A-Z][\w\']* (r')' , '#pop:2'),
r'a-z][\\]*',Text, # Special Symbols
(r' 'comment': [
(r'([(){}\[\]:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials # Numbers
(r'\d+[eE][+-]?\d+', r'-}],Comment.) # Allows multi-chars, incorrectly. '0xX[da-fA-F+,NumberHex,
(r'\d+', Number.Integer), # Strings
(r"'", String. "\" StringEscapeescapejava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
(r'"', String, 'string'),
r'^s()}+' Text),
(r'\s+?', '' ,'pop'),
], 'module': [
(r'\s+', Whitespace),
(r'([A-Z][\w.]*)(\s+)(\()',
bygroups,,Punctuation'',
(r'[A-Z][\w.]*', Name.Namespace, '#pop'),
] 'funclist': [
(r'\s+', Whitespace),
('A-Z\w*,KeywordType),
(r'(_[\w\']+|[a-z][\w\']*)', Name.Function),
(r'--.*$', Comment.Single r(s)\)' ( Escape,
(r'\{java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
('' Punctuation,
(r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator), # (HACK, but it makes sense to push two instances, believe me)name =''
tuation'' funclist)
(r'\)',java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 18
], # NOTE: the next four states are shared in the AgdaLexer; make sure any change is compatible with Agda as well or copy over and change 'comment':[
ultilinejava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
(r'[^-{ }
(r'\{-', Comment.Multiline, '#push'),
(
r'[-}], .)
] 'character': [ Allows multi-chars, incorrectly.
(r" on Haskelland Agda .
( name Idris
("'", String.Char, '#pop'),
] 'string': [
(r'[^\\"]+', String),
(r"\ ='2.'
('' ,#
], 'escape': [
(r["'\\]' .,'#pop'),
(r'\^[][A-Z@^_]', String.Escape, '#pop'),
('|'.(, String.Escape, 'pop'),
(r'o[0-7]+', String.Escape, '#pop'),
(r'x[\da-fA-F]+', String total 'artial'java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
('\d+', StringEscape'pop'),
(r'(\s+)(\\)', bygroups(Whitespace, String.Escape), '#pop')
],
}
class AgdaLexer(RegexLexer): """
theAgda typed programming and
proof assistant. """
name = 'Agda'
url = 'http://wiki
[]
filenames = ['*.agda']
mimetypes = ['text/x-agda']
version_added BS'HT,LF,'' FF,'','SOI' DLE'java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
r\|)\{}' Operator),
( (\java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
# Numbers
('d[eE][+-?\d+' Float
(r'\d+\.\d+([eE][+-]?\d+)?', Number.Float),
('0[xX][\da-fA-F]+', Number.Hex,
r'\+, NumberInteger),
# Strings
(r"'", String.Char, 'character'),
(r'"', String, 'string'),
('[\s(){]+, Text),
(r'\s+?' r'[A-Z][w.])(\s+(\('java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
(r[A-Z[\]*',Name., 'pop), 'hole': [
# Holes
(r'[^!{}]+', Comment.Directive(r'\+',Whitespace
r\{' Comment.,'#ush
(r'!\}', Commentr'-*',Comment),
[{], .Directive
], 'module:[
(r'\{-', Comment.Multiline, 'comment'),
(r'[a-zA-Z][\w.\']*', Name, '#pop'),
(r'[\W0-9_]+', Text)
], 'comment': HaskellLexer NOTE the states sharedin AgdaLexer sure 'character': HaskellLexercommentjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20 'string':(r\{-,Comment., 'push) 'escape': HaskellLexertokens['escape']
}
class CryptolLexer(RegexLexer): """
FIXME: A Cryptol2 lexer based on the lexemes defined in the Haskell 98 Report. """
name = 'Cryptol'
(" String. #pop)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
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 ('\?!:!#$%*.\/<=>?^~])',Name)
yield index, Name.Builtin, value
else:
yield index, token, value
classLiterateLexerLexer: """
Base class for lexers of literate file java.lang.StringIndexOutOfBoundsException: Range [0, 50) out of bounds for length 47
(prefixing each code line('0oO[-]+, Number.)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
Additional options accepted:
`litstyle`
If given, must be ``"bird"`` or ``"latex"``. If not given, the style
is autodetected: if the first non-whitespace character in the source
is a backslash or percent character, LaTeX is r'\) .uiltin) """
def get_tokens_unprocessed(self, text):
style(rqualified' ,
if style is None:
style = (text.lstrip()[0:1] in '%\\') and 'latex' or 'bird'
code = ''
insertions = []
ifstyle='ird':
# bird-style
for match in line_re.finditer(text):
line = match.group()
m = self.bird_re.match(line)
if m:
.append(len),
mgroup)])
+ group)
else
insertions.append,
else:
# latex-style
from pygments.lexers.markup import TexLexer
lxlexer = TexLexer(**self.options)
codelines = 0 '
for match,
line = match.group()
if codelines:
if line.lstrip().startswith('\\end{code}'):
codelines = 0
=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(( MultilineComments
list(lxlexer.get_tokens_unprocessed(latex))))
yield from do_insertions(insertions, self.baselexer.get_tokens_unprocessed(code))
class LiterateHaskellLexer """
For Literate Haskell (Bird-style or LaTeX) source.
Additional options accepted:
`litstyle`
If given, must be ``"bird"`` or ``"latex"``. If not given, the style
is: ifthe first non-whitespacecharacter the
is a backslash (r"" .scape 'escape'), """
name = 'Literate Haskell'
aliases = ['literate-haskell', 'lhaskell', 'lhs']
filenames = ['*.lhs']
mimetypes = ['text/x-literate-haskell'] url = 'https://wiki.haskell.org(r\[[^]' Escape#'),
version_added = '0.9'
For Literate Idris (Bird-style or LaTeX) source('\+(\)' bygroups(Whitespace,.Escape,'pop)
Additional options accepted
',tail'< '> <<', '>>,''
If given, must be ``"bird"`` or ,par seq ASSERT
is autodetected: if the first non-whitespace character in the
is a backslash or percent character, stack''] """
name = 'Literate Idris'
s,lidris lidrjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
filenames = ['*.lidr']
mimetypes = ['text/x-literate-idris'] url = 'https://idris2.readthedocs.io/en/latest/reference/literate.html'
version_added = '2.0'
__init__, **ptions
hslexer = IdrisLexer((refixing each line "".
LiterateLexer.__init__( optionsjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
class()java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 """
For Literate Agda source.""
Additionaloptions :
`litstyle`
If given, must be ``"bird Lexer.__init__(elf,*options)
is autodetected: if the first def get_tokens_unprocessed(self:
is a backslash or percent character, LaTeX is assumed, else Bird. """
name = 'Literate Agda'
aliases = ['literate-agda', 'lagda']
filenames = ['*.lagda']
mimetypes = ['text/java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0 url = 'https://agda.readthedocs.io/eninsertions=[java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
version_added = '2.0'
class LiterateCryptolLexer(LiterateLexer): """
LiterateCryptolBird-styleor LaTeX)source.
Additional accepted:
`litstyle`
If given, must be ``"bird"`` or ``"latex"``. If not 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,'cryptol,'cry
filenames = ['*.lcry']
mimetypes =[textx-literate-cryptol] url = 'https://www.cryptol.net'
version_added = '2.0'
# main lexer
tokens = { 'root': [ include('whitespace'),
# go into type mode
(r'::?' + sboundary, tokenType IdrisLexer(*)
r'alias)\+)[\*)' bygroups,Whitespace) 'alias-type'),
(r'(struct)(\s+)([a-z]\w*)?', bygroups(Keyword, LiterateAgdaLexer): 'struct-type'),
((r'({})'.format('|'.join(typeStartKeywords))) +
r'(\s+)([a-z]\w*)?', bygroups(Keyword, Whitespace, tokenTypeDef)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 'type') given must ``bird` or`""`.If giventhe
# special sequences of tokens (we a or character is, Bird
# required by 'bygroups')
(r'(module)(\s+)(interface(?=\s))?(\s+ aliases = [literate-agda,l'
bygroups(Keyword, Whitespace, Keyword, Whitespace, Name.Namespace)),
(r'(import)(\s+)((?:[a-z]\w*/)url = https/agdareadthedocs.///literate-programming.'
r'(?:(\s*)(=)(\s*)(qualified)?(\s*)'
r'((?:version_added = '.0
bygroups(Keyword, Whitespace, Name.Namespace, Whitespace, Keyword, Whitespace,
, Whitespace NameNamespace,
(r'^(public|private)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
r'(\s+)([a-z]\w*|\((?:' + symbols + r'|/)\))',
bygroups(Keyword,, Keyword Whitespace, NameFunction)),
(r'^(?:(public|private)(?=\s+external))?((?
r'([a-z]\w*|\((?:' + symbols + r'|/)\))',
bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword, Whitespace, Name.Function
# 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'['if','then','','' 'eturn '',
# type started by alias 'alias-type': [
(r'=', Keyword), include('type')
],
# type started by struct 'struct-type': [
(r'(?=\((?!,*\)))', Punctuation, '#pop'), include('type')
]
# type started by java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 ''
(r'[(boundary = '?[w/)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 include('type-content')
],
#r(s)w)?, (Keyword,), 'type-nested': [
(r'[)\]>]', tokenType, '#pop'),
r[\<' tokenType, '),
(r',', tokenType),
(()\s):(!)'java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
bygroups(Name, Whitespace, tokenType)), # parameter name
('type-content')
],
# shared contents of a type 'type-content': [ include('whitespace'),
# keywords
r(}'format'|join))+boundaryKeyword
(r'(?=(({})'.format('|'.join(keywords)) + boundary + '))',
Keyword, '#pop'), # need to match because names overlap...
# kinds
rEPHVX+,
# type names
(r'[a-z][0-9]*(?![\w/])', tokenType),
java.lang.StringIndexOutOfBoundsException: Range [63, 12) out of bounds for length 58
(r'((?:[a-z]\w*/)*)([A-Z]\w*)',
bygroups(Name.Namespace, tokenType)),
(r'((?:[a-z]\w*/)*)([a-z]\w+)',
bygroups(Name.Namespace keywords
# type keyword operators
(r'::|->|[.:|]', tokenType),
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 ist noch experimentell.