author Julien Cristau <julien.cristau@logilab.fr>
Mon, 04 Jan 2016 16:30:42 +0100
changeset 793 b8465dbebf6f
parent 761 d9762b5a4604
child 826 c993c0593d6c
permissions -rw-r--r--
[pkg] add missing build-dependencies, and don't try to run tests pybuild doesn't seem to find any tests. We should fix that, but, later.

# -*- coding: utf-8 -*-

    Lexer for RQL the relation query language


import re

from pygments.lexer import RegexLexer, _mapping
from pygments.token import Punctuation, \
     Text, Comment, Operator, Keyword, Name, String, Number

__all__ = ['RqlLexer']

class RqlLexer(RegexLexer):
    Lexer for Relation Query Language.

    name = 'RQL'
    aliases = ['rql']
    filenames = ['*.rql']
    mimetypes = ['text/x-rql']

    flags = re.IGNORECASE
    tokens = {
        'root': [
            (r'\s+', Text),
             r'|TODAY|NOW|TRUE|FALSE|NULL|EXISTS)\b', Keyword),
            (r'[+*/<>=%-]', Operator),
            (r'(Any|is|instance_of)\b', Name.Builtin),
            (r'[0-9]+', Number.Integer),
            (r'[A-Z_][A-Z0-9_]*\??', Name),
            (r"'(''|[^'])*'", String.Single),
            (r'"(""|[^"])*"', String.Single),
            (r'[;:()\[\],\.]', Punctuation)

_mapping.LEXERS['RqlLexer'] = ('rql.pygments_ext', 'RQL', ('rql',), ('*.rql',), ('text/x-rql',))