Skip to content
Snippets Groups Projects
Commit 0c8840b3be04 authored by Nicolas Chauvat's avatar Nicolas Chauvat
Browse files

add pygments lexer to colorize query strings (closes #34252)

parent 3d5a9d57cf95
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@
python-logilab-database (>= 1.6.0)
Conflicts: cubicweb-common (<= 3.13.9)
Provides: ${python:Provides}
Suggests: python-pygments
Description: relationship query language (RQL) utilities
A library providing the base utilities to handle RQL queries,
such as a parser, a type inferencer.
......
# -*- coding: utf-8 -*-
"""
pygments.lexers.rql
~~~~~~~~~~~~~~~~~~~
Lexer for RQL the relation query language
http://www.logilab.org/project/rql
"""
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'(DELETE|SET|INSERT|UNION|DISTINCT|WITH|WHERE|BEING|OR'
r'|AND|NOT|GROUPBY|HAVING|ORDERBY|ASC|DESC|LIMIT|OFFSET'
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',))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment