How to use the djangoql.lexer.DjangoQLLexer function in djangoql

To help you get started, we’ve selected a few djangoql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ivelum / djangoql / djangoql / parser.py View on Github external
def __init__(self, debug=False, **kwargs):
        self.default_lexer = DjangoQLLexer()
        self.tokens = self.default_lexer.tokens
        kwargs['debug'] = debug
        self.yacc = yacc.yacc(module=self, **kwargs)
github ivelum / djangoql / djangoql / parser.py View on Github external
from __future__ import unicode_literals

import re
from decimal import Decimal

import ply.yacc as yacc

from .ast import *  # noqa
from .compat import binary_type, text_type
from .exceptions import DjangoQLParserError
from .lexer import DjangoQLLexer


unescape_pattern = re.compile(
    '(' +  DjangoQLLexer.re_escaped_char + '|' +
    DjangoQLLexer.re_escaped_unicode + ')'
)


def unescape_repl(m):
    contents = m.group(1)
    if len(contents) == 2:
        return contents[1]
    else:
        return contents.encode('utf8').decode('unicode_escape')


def unescape(value):
    if isinstance(value, binary_type):
        value = value.decode('utf8')
    return re.sub(unescape_pattern, unescape_repl, value)
github ivelum / djangoql / djangoql / parser.py View on Github external
from __future__ import unicode_literals

import re
from decimal import Decimal

import ply.yacc as yacc

from .ast import *  # noqa
from .compat import binary_type, text_type
from .exceptions import DjangoQLParserError
from .lexer import DjangoQLLexer


unescape_pattern = re.compile(
    '(' +  DjangoQLLexer.re_escaped_char + '|' +
    DjangoQLLexer.re_escaped_unicode + ')'
)


def unescape_repl(m):
    contents = m.group(1)
    if len(contents) == 2:
        return contents[1]
    else:
        return contents.encode('utf8').decode('unicode_escape')


def unescape(value):
    if isinstance(value, binary_type):
        value = value.decode('utf8')
    return re.sub(unescape_pattern, unescape_repl, value)