aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Pygments/py3/pygments/lexers/rita.py
blob: f8f517b9ed58f2114103aa8e87a676688dd65d5f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
    pygments.lexers.rita
    ~~~~~~~~~~~~~~~~~~~~

    Lexers for RITA language

    :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

import re

from pygments.lexer import RegexLexer, include, bygroups, using, this, \
    inherit, words
from pygments.token import Comment, Operator, Keyword, Name, Literal, Punctuation, Text, Whitespace

__all__ = ['RitaLexer']


class RitaLexer(RegexLexer):
    """
    Lexer for `RITA <https://github.com/zaibacu/rita-dsl>`_

     .. versionadded:: 2.11
    """
    name = 'Rita'
    filenames = ['*.rita']
    aliases = ['rita']
    mimetypes = ['text/rita']

    tokens = {
        'root': [
            (r'\n', Whitespace),
            (r'\s+', Whitespace),
            (r'#(.*?)\n', Comment.Single),
            (r'@(.*?)\n', Operator),  # Yes, whole line as an operator
            (r'"(\w|\d|\s|(\\")|[\'_\-./,\?\!])+?"', Literal),
            (r'\'(\w|\d|\s|(\\\')|["_\-./,\?\!])+?\'', Literal),
            (r'([A-Z_]+)', Keyword),
            (r'([a-z0-9_]+)', Name),
            (r'((->)|[!?+*|=])', Operator),
            (r'[\(\),\{\}]', Punctuation)
        ]
    }