summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-01-10 10:25:10 +0100
committerGeorg Brandl <georg@python.org>2014-01-10 10:25:10 +0100
commitf60dfb674795e7ae28172862d3be80a74415d525 (patch)
tree05ade539575969415c5d2d005e7596ba2ade2440
parent6c5d522553c3ab80e81731b795e91d9b844eceb5 (diff)
parent1cb557b279e3dc22da13dbda9a1ec2698cd0238a (diff)
downloadpygments-f60dfb674795e7ae28172862d3be80a74415d525.tar.gz
Merged in tioui/pygments-main-new (pull request #273)
Modification of the Eiffel lexer pull request (#227)
-rw-r--r--AUTHORS1
-rw-r--r--pygments/lexers/_mapping.py1
-rw-r--r--pygments/lexers/compiled.py43
-rw-r--r--tests/examplefiles/example.e124
4 files changed, 168 insertions, 1 deletions
diff --git a/AUTHORS b/AUTHORS
index bc0f4dae..8bd0c3b2 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -155,5 +155,6 @@ Other contributors, listed alphabetically, are:
* Enrique Zamudio -- Ceylon lexer
* Alex Zimin -- Nemerle lexer
* Rob Zimmerman -- Kal lexer
+* Louis Marchand -- Eiffel lexer
Many thanks for all contributions!
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index 15fdbf8a..de97ad0c 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -98,6 +98,7 @@ LEXERS = {
'ECLLexer': ('pygments.lexers.other', 'ECL', ('ecl',), ('*.ecl',), ('application/x-ecl',)),
'ECLexer': ('pygments.lexers.compiled', 'eC', ('ec',), ('*.ec', '*.eh'), ('text/x-echdr', 'text/x-ecsrc')),
'EbnfLexer': ('pygments.lexers.text', 'EBNF', ('ebnf',), ('*.ebnf',), ('text/x-ebnf',)),
+ 'EiffelLexer': ('pygments.lexers.compiled', 'Eiffel', ('eiffel',), ('*.e',), ('text/x-eiffel',)),
'ElixirConsoleLexer': ('pygments.lexers.functional', 'Elixir iex session', ('iex',), (), ('text/x-elixir-shellsession',)),
'ElixirLexer': ('pygments.lexers.functional', 'Elixir', ('elixir', 'ex', 'exs'), ('*.ex', '*.exs'), ('text/x-elixir',)),
'ErbLexer': ('pygments.lexers.templates', 'ERB', ('erb',), (), ('application/x-ruby-templating',)),
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index 4325da83..a4b88d3c 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -31,7 +31,7 @@ __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer',
'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer', 'SwigLexer',
'DylanLidLexer', 'DylanConsoleLexer', 'CobolLexer',
'CobolFreeformatLexer', 'LogosLexer', 'ClayLexer', 'PikeLexer',
- 'ChapelLexer']
+ 'ChapelLexer', 'EiffelLexer']
class CFamilyLexer(RegexLexer):
@@ -3855,3 +3855,44 @@ class ChapelLexer(RegexLexer):
(r'[a-zA-Z_][a-zA-Z0-9_$]*', Name.Function, '#pop'),
],
}
+
+class EiffelLexer(RegexLexer):
+ """
+ For `Eiffel <http://www.eiffel.com>`_ source code.
+ """
+ name = 'Eiffel'
+ aliases = ['eiffel']
+ filenames = ['*.e']
+ mimetypes = ['text/x-eiffel']
+ tokens = {
+ 'root': [
+ (r'[^\S\n]+', Text),
+ (r'--.*?\n', Comment.Single),
+ (r'[^\S\n]+', Text),
+ # Please note thant keyword and operator are case insensitive.
+ (r'(?i)(true|false|void|current|result|precursor)\b', Keyword.Constant),
+ (r'(?i)(and(\s+then)?|not|xor|implies|or(\s+else)?)\b', Operator.Word),
+ (r'(?i)\b(across|agent|alias|all|as|assign|attached|attribute|check|'
+ r'class|convert|create|debug|deferred|detachable|do|else|elseif|'
+ r'end|ensure|expanded|export|external|feature|from|frozen|if|'
+ r'inherit|inspect|invariant|like|local|loop|none|note|obsolete|'
+ r'old|once|only|redefine|rename|require|rescue|retry|select|'
+ r'separate|then|undefine|until|variant|when)\b',Keyword.Reserved),
+ (r'"\[(([^\]%]|\n)|%(.|\n)|\][^"])*?\]"', String),
+ (r'"([^"%\n]|%.)*?"', String),
+ include('numbers'),
+ (r"'([^'%]|%'|%%)'", String.Char),
+ (r"(//|\\\\|>=|<=|:=|/=|~|/~|[\\\?!#%&@|+/\-=\>\*$<|^\[\]])", Operator),
+ (r"([{}():;,.])", Punctuation),
+ (r'([a-z][a-zA-Z0-9_]*)|([A-Z][A-Z0-9_]*[a-z][a-zA-Z0-9_]*)', Name),
+ (r'([A-Z][A-Z0-9_]*)', Name.Class),
+ (r'\n+', Text),
+ ],
+ 'numbers' : [
+ (r'0[xX][a-fA-F0-9]+', Number.Hex),
+ (r'0[bB][0-1]+', Number.Bin),
+ (r'0[cC][0-7]+', Number.Oct),
+ (r'([0-9]+\.[0-9]*)|([0-9]*\.[0-9]+)', Number.Float),
+ (r'[0-9]+', Number.Integer),
+ ],
+ }
diff --git a/tests/examplefiles/example.e b/tests/examplefiles/example.e
new file mode 100644
index 00000000..2e43954b
--- /dev/null
+++ b/tests/examplefiles/example.e
@@ -0,0 +1,124 @@
+note
+ description : "[
+ This is use to have almost every language element."
+
+ That way, I can correctly test the lexer. %]"
+
+ Don't try to understand what it does. It's not even compilling.
+ ]"
+ date : "August 6, 2013"
+ revision : "0.1"
+
+class
+ SAMPLE
+
+inherit
+ ARGUMENTS
+ rename
+ Command_line as Caller_command,
+ command_name as Application_name
+ undefine
+ out
+ end
+ ANY
+ export
+ {ANY} out
+ redefine
+ out
+ end
+
+
+
+create
+ make
+
+convert
+ as_boolean: {BOOLEAN}
+
+feature {NONE} -- Initialization
+
+ make
+ -- Run application.
+ local
+ i1_:expanded INTEGER
+ f_1:REAL_64
+ l_char:CHARACTER_8
+ do
+ l_char:='!'
+ l_char:='%''
+ l_char:='%%'
+ i1_:=80 - 0x2F0C // 0C70 \\ 0b10110 * 1;
+ f_1:=0.1 / .567
+ f_1:=34.
+ f_1:=12345.67890
+ inspect i1_
+ when 1 then
+ io.output.put_integer (i1_) -- Comment
+ else
+ io.output.put_real (f_1.truncated_to_real)
+ end
+ io.output.put_string (CuRrEnt.out) -- Comment
+ (agent funct_1).call([1,2,"Coucou"])
+ end
+
+feature -- Access
+
+ funct_1(x,y:separate INTEGER;a_text:READABLE_STRING_GENERAL):detachable BOOLEAN
+ obsolete "This function is obsolete"
+ require
+ Is_Attached: AttAched a_text
+ local
+ l_list:LIST[like x]
+ do
+ if (NOT a_text.is_empty=TrUe or elSe ((x<0 aNd x>10) oR (y>0 and then y<10))) xor True thEn
+ ResuLT := FalSe
+ elseif (acROss l_list as la_list SoMe la_list.item<0 end) implies a_text.is_boolean then
+ ResuLT := FalSe
+ else
+ Result := TruE
+ eND
+ from
+ l_list.start
+ until
+ l_list.exhausted
+ loop
+ l_list.forth
+ variant
+ l_list.count - l_list.index
+ end
+ check Current /= Void end
+ debug print("%"Here%"%N") end
+ ensure
+ Is_Cool_Not_Change: is_cool = old is_cool
+ end
+
+ is_cool:BOOLEAN
+ attribute
+ Result:=False
+ end
+
+ froZen c_malloc: POINTER is
+ exTErnal
+ "C inline use <stdlib.h>"
+ alIAs
+ "malloc (1)"
+ end
+
+ as_boolean:BOOLEAN
+ do
+ Result:=True
+ rescue
+ retry
+ end
+
+feature {ANY} -- The redefine feature
+
+ out:STRING_8
+ once
+ reSUlt:=PrecursOr {ANY}
+ Result := "Hello Worl"+('d').out
+ end
+
+invariant
+ Always_Cool: is_cool
+end