summaryrefslogtreecommitdiff
path: root/pygments/lexers/esoteric.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/esoteric.py')
-rw-r--r--pygments/lexers/esoteric.py111
1 files changed, 108 insertions, 3 deletions
diff --git a/pygments/lexers/esoteric.py b/pygments/lexers/esoteric.py
index f61b292d..73ea4a4a 100644
--- a/pygments/lexers/esoteric.py
+++ b/pygments/lexers/esoteric.py
@@ -9,11 +9,11 @@
: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 BefungeLexer(RegexLexer):
}
+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 @@ class RedcodeLexer(RegexLexer):
(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),
+ ],
+ }