ThirdParty/Pygments/pygments/lexers/esoteric.py

changeset 4697
c2e9bf425554
parent 4172
4f20dba37ab6
child 5713
6762afd9f963
--- a/ThirdParty/Pygments/pygments/lexers/esoteric.py	Sun Jan 24 16:15:58 2016 +0100
+++ b/ThirdParty/Pygments/pygments/lexers/esoteric.py	Sun Jan 24 19:28:37 2016 +0100
@@ -5,15 +5,15 @@
 
     Lexers for esoteric languages.
 
-    :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
+    :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
     :license: BSD, see LICENSE for details.
 """
 
-from pygments.lexer import RegexLexer, include
+from pygments.lexer import RegexLexer, include, words
 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
-    Number, Punctuation, Error
+    Number, Punctuation, Error, Whitespace
 
-__all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer']
+__all__ = ['BrainfuckLexer', 'BefungeLexer', 'BoogieLexer', 'RedcodeLexer', 'CAmkESLexer']
 
 
 class BrainfuckLexer(RegexLexer):
@@ -78,6 +78,66 @@
     }
 
 
+class CAmkESLexer(RegexLexer):
+    """
+    Basic lexer for the input language for the
+    `CAmkES <https://sel4.systems/CAmkES/>`_ component platform.
+
+    .. versionadded:: 2.1
+    """
+    name = 'CAmkES'
+    aliases = ['camkes', 'idl4']
+    filenames = ['*.camkes', '*.idl4']
+
+    tokens = {
+        'root':[
+            # C pre-processor directive
+            (r'^\s*#.*\n', Comment.Preproc),
+
+            # Whitespace, comments
+            (r'\s+', Text),
+            (r'/\*(.|\n)*?\*/', Comment),
+            (r'//.*\n', Comment),
+
+            (r'[\[\(\){},\.;=\]]', Punctuation),
+
+            (words(('assembly', 'attribute', 'component', 'composition',
+                    'configuration', 'connection', 'connector', 'consumes',
+                    'control', 'dataport', 'Dataport', 'emits', 'event',
+                    'Event', 'from', 'group', 'hardware', 'has', 'interface',
+                    'Interface', 'maybe', 'procedure', 'Procedure', 'provides',
+                    'template', 'to', 'uses'), suffix=r'\b'), Keyword),
+
+            (words(('bool', 'boolean', 'Buf', 'char', 'character', 'double',
+                    'float', 'in', 'inout', 'int', 'int16_6', 'int32_t',
+                    'int64_t', 'int8_t', 'integer', 'mutex', 'out', 'real',
+                    'refin', 'semaphore', 'signed', 'string', 'uint16_t',
+                    'uint32_t', 'uint64_t', 'uint8_t', 'uintptr_t', 'unsigned',
+                    'void'), suffix=r'\b'), Keyword.Type),
+
+            # Recognised attributes
+            (r'[a-zA-Z_]\w*_(priority|domain|buffer)', Keyword.Reserved),
+            (words(('dma_pool', 'from_access', 'to_access'), suffix=r'\b'),
+                Keyword.Reserved),
+
+            # CAmkES-level include
+            (r'import\s+(<[^>]*>|"[^"]*");', Comment.Preproc),
+
+            # C-level include
+            (r'include\s+(<[^>]*>|"[^"]*");', Comment.Preproc),
+
+            # Literals
+            (r'0[xX][\da-fA-F]+', Number.Hex),
+            (r'-?[\d]+', Number),
+            (r'-?[\d]+\.[\d]+', Number.Float),
+            (r'"[^"]*"', String),
+
+            # Identifiers
+            (r'[a-zA-Z_]\w*', Name),
+        ],
+    }
+
+
 class RedcodeLexer(RegexLexer):
     """
     A simple Redcode lexer based on ICWS'94.
@@ -112,3 +172,48 @@
             (r'[-+]?\d+', Number.Integer),
         ],
     }
+
+
+class BoogieLexer(RegexLexer):
+    """
+    For `Boogie <https://boogie.codeplex.com/>`_ source code.
+
+    .. versionadded:: 2.1
+    """
+    name = 'Boogie'
+    aliases = ['boogie']
+    filenames = ['*.bpl']
+
+    tokens = {
+        'root': [
+            # Whitespace and Comments
+            (r'\n', Whitespace),
+            (r'\s+', Whitespace),
+            (r'//[/!](.*?)\n', Comment.Doc),
+            (r'//(.*?)\n', Comment.Single),
+            (r'/\*', Comment.Multiline, 'comment'),
+
+            (words((
+                'axiom', 'break', 'call', 'ensures', 'else', 'exists', 'function',
+                'forall', 'if', 'invariant', 'modifies', 'procedure',  'requires',
+                'then', 'var', 'while'),
+             suffix=r'\b'), Keyword),
+            (words(('const',), suffix=r'\b'), Keyword.Reserved),
+
+            (words(('bool', 'int', 'ref'), suffix=r'\b'), Keyword.Type),
+            include('numbers'),
+            (r"(>=|<=|:=|!=|==>|&&|\|\||[+/\-=>*<\[\]])", Operator),
+            (r"([{}():;,.])", Punctuation),
+            # Identifier
+            (r'[a-zA-Z_]\w*', Name),
+        ],
+        'comment': [
+            (r'[^*/]+', Comment.Multiline),
+            (r'/\*', Comment.Multiline, '#push'),
+            (r'\*/', Comment.Multiline, '#pop'),
+            (r'[*/]', Comment.Multiline),
+        ],
+        'numbers': [
+            (r'[0-9]+', Number.Integer),
+        ],
+    }

eric ide

mercurial