Commits

Anonymous committed aada238

Adding preliminary ECL lexer

  • Participants
  • Parent commits db34fea

Comments (0)

Files changed (2)

pygments/lexers/_mapping.py

     'DuelLexer': ('pygments.lexers.web', 'Duel', ('duel', 'Duel Engine', 'Duel View', 'JBST', 'jbst', 'JsonML+BST'), ('*.duel', '*.jbst'), ('text/x-duel', 'text/x-jbst')),
     'DylanLexer': ('pygments.lexers.compiled', 'Dylan', ('dylan',), ('*.dylan', '*.dyl'), ('text/x-dylan',)),
     'ECLexer': ('pygments.lexers.compiled', 'eC', ('ec',), ('*.ec', '*.eh'), ('text/x-echdr', 'text/x-ecsrc')),
+    'ECLLexer': ('pygments.lexers.other', 'ECL', ('ecl',), ('*.ecl'), ('text/x-ecl')),
     'ErbLexer': ('pygments.lexers.templates', 'ERB', ('erb',), (), ('application/x-ruby-templating',)),
     'ErlangLexer': ('pygments.lexers.functional', 'Erlang', ('erlang',), ('*.erl', '*.hrl'), ('text/x-erlang',)),
     'ErlangShellLexer': ('pygments.lexers.functional', 'Erlang erl session', ('erl',), ('*.erl-sh',), ('text/x-erl-shellsession',)),

pygments/lexers/other.py

            'NewspeakLexer', 'GherkinLexer', 'AsymptoteLexer',
            'PostScriptLexer', 'AutohotkeyLexer', 'GoodDataCLLexer',
            'MaqlLexer', 'ProtoBufLexer', 'HybrisLexer', 'AwkLexer',
-           'Cfengine3Lexer']
+           'Cfengine3Lexer', 'ECLLexer']
 
 line_re  = re.compile('.*?\n')
 
     }
 
 
+class ECLLexer(RegexLexer):
+    """
+    Lexer for the declarative big-data `ECL <http://hpccsystems.com/community/docs/ecl-language-reference/html>`_
+    language.
+
+    *New in Pygments 0.7.*
+    """
+    name = 'ECL'
+    aliases = ['ecl']
+    filenames = ['*.ecl']
+    mimetypes = ['application/x-ecl']
+
+    flags = re.IGNORECASE
+
+    tokens = {
+        'root': [
+            include('whitespace'),
+            include('statements'),
+        ],
+        'whitespace': [
+            (r'\s+', Text),
+            (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
+            (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
+        ],
+        'statements': [
+            include('types'),
+            include('keywords'),
+            (r'"', String, 'string'),
+            (r'\'', String, 'string'),
+            (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
+            (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
+            (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
+            (r'0[0-7]+[LlUu]*', Number.Oct),
+            (r'\d+[LlUu]*', Number.Integer),
+            (r'\*/', Error),
+            (r'[~!%^&*+=|?:<>/-]+', Operator),
+            (r'[{}()\[\],.;]', Punctuation),
+            ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+        ],
+        'types': [
+            (r'(STRING|INTEGER|UNSIGNED)\d+', Keyword.Type),
+            (r'(REAL)', Keyword.Type),
+        ],
+        'keywords': [
+            (r'(DATASET|OUTPUT|INDEX|BUILD|SEQUENTIAL|TABLE)', Keyword.Reserved),
+            (r'(OVERRITE|FLAT)', Keyword.Reserved),
+            (r'(RECORD|END)', Keyword.Declaration),
+        ],
+        'string': [
+            (r'"', String, '#pop'),
+            (r'\'', String, '#pop'),
+        ],
+    }
+
+
+
 class SqliteConsoleLexer(Lexer):
     """
     Lexer for example sessions using sqlite3.