codekingpro/portable-devtools
114k
1"""2 pygments.lexers.eiffel3 ~~~~~~~~~~~~~~~~~~~~~~4 5 Lexer for the Eiffel language.6 7 :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.8 :license: BSD, see LICENSE for details.9"""10 11from pygments.lexer import RegexLexer, include, words, bygroups12from pygments.token import Comment, Operator, Keyword, Name, String, Number, \13 Punctuation, Whitespace14 15__all__ = ['EiffelLexer']16 17 18class EiffelLexer(RegexLexer):19 """20 For Eiffel source code.21 """22 name = 'Eiffel'23 url = 'https://www.eiffel.com'24 aliases = ['eiffel']25 filenames = ['*.e']26 mimetypes = ['text/x-eiffel']27 version_added = '2.0'28 29 tokens = {30 'root': [31 (r'[^\S\n]+', Whitespace),32 (r'--.*?$', Comment.Single),33 (r'[^\S\n]+', Whitespace),34 # Please note that keyword and operator are case insensitive.35 (r'(?i)(true|false|void|current|result|precursor)\b', Keyword.Constant),36 (r'(?i)(not|xor|implies|or)\b', Operator.Word),37 (r'(?i)(and)(?:(\s+)(then))?\b',38 bygroups(Operator.Word, Whitespace, Operator.Word)),39 (r'(?i)(or)(?:(\s+)(else))?\b',40 bygroups(Operator.Word, Whitespace, Operator.Word)),41 (words((42 'across', 'agent', 'alias', 'all', 'as', 'assign', 'attached',43 'attribute', 'check', 'class', 'convert', 'create', 'debug',44 'deferred', 'detachable', 'do', 'else', 'elseif', 'end', 'ensure',45 'expanded', 'export', 'external', 'feature', 'from', 'frozen', 'if',46 'inherit', 'inspect', 'invariant', 'like', 'local', 'loop', 'none',47 'note', 'obsolete', 'old', 'once', 'only', 'redefine', 'rename',48 'require', 'rescue', 'retry', 'select', 'separate', 'then',49 'undefine', 'until', 'variant', 'when'), prefix=r'(?i)\b', suffix=r'\b'),50 Keyword.Reserved),51 (r'"\[([^\]%]|%(.|\n)|\][^"])*?\]"', String),52 (r'"([^"%\n]|%.)*?"', String),53 include('numbers'),54 (r"'([^'%]|%'|%%)'", String.Char),55 (r"(//|\\\\|>=|<=|:=|/=|~|/~|[\\?!#%&@|+/\-=>*$<^\[\]])", Operator),56 (r"([{}():;,.])", Punctuation),57 (r'([a-z]\w*)|([A-Z][A-Z0-9_]*[a-z]\w*)', Name),58 (r'([A-Z][A-Z0-9_]*)', Name.Class),59 (r'\n+', Whitespace),60 ],61 'numbers': [62 (r'0[xX][a-fA-F0-9]+', Number.Hex),63 (r'0[bB][01]+', Number.Bin),64 (r'0[cC][0-7]+', Number.Oct),65 (r'([0-9]+\.[0-9]*)|([0-9]*\.[0-9]+)', Number.Float),66 (r'[0-9]+', Number.Integer),67 ],68 }69 