# Path: reggata/errors.py
# class LexError(Exception):
#     def __init__(self, msg=None, cause=None):
#         super(LexError, self).__init__(msg)
#         self.cause = cause


import ply.lex as lex
import re
from PyQt4.QtCore import QCoreApplication
from reggata.errors import LexError

    # String should not match with any of keywords
    t.type = reserved.get(t.value, 'STRING')

    if t.type == 'STRING' \
    and t.value.startswith('"') \
    and t.value.endswith('"') \
    and not t.value.endswith(r'\"'):
        t.value = t.value.replace(r"\\", "\\") # Replace \\ with \
        t.value = t.value.replace(r'\"', r'"') # Replace \" with "
        t.value = t.value[1:-1] # Remove quotes from begining and the end. "abc" becomes just abc
    return t

# This tokens should be taken into account in regexp of STRING token...
t_LPAREN  = r'\('
t_RPAREN  = r'\)'
t_COLON = r':'
t_EQUAL = r'='
t_GREATER = r'>'
t_GREATER_EQ = r'>='
t_LESS = r'<'
t_LESS_EQ = r'<='
t_LIKE = r'~'

# A string containing ignored characters (spaces and tabs)
t_ignore  = ' \t\n\r'


# Error handling rule
def t_error(t):

# Path: reggata/errors.py
# class LexError(Exception):
#     def __init__(self, msg=None, cause=None):
#         super(LexError, self).__init__(msg)
#         self.cause = cause


# Path: reggata/parsers/query_tokens.py
import ply.lex as lex
import re
from PyQt4.QtCore import QCoreApplication
from reggata.errors import LexError


    # String should not match with any of keywords
    t.type = reserved.get(t.value, 'STRING')

    if t.type == 'STRING' \
    and t.value.startswith('"') \
    and t.value.endswith('"') \
    and not t.value.endswith(r'\"'):
        t.value = t.value.replace(r"\\", "\\") # Replace \\ with \
        t.value = t.value.replace(r'\"', r'"') # Replace \" with "
        t.value = t.value[1:-1] # Remove quotes from begining and the end. "abc" becomes just abc
    return t

# This tokens should be taken into account in regexp of STRING token...
t_LPAREN  = r'\('
t_RPAREN  = r'\)'
t_COLON = r':'
t_EQUAL = r'='
t_GREATER = r'>'
t_GREATER_EQ = r'>='
t_LESS = r'<'
t_LESS_EQ = r'<='
t_LIKE = r'~'

# A string containing ignored characters (spaces and tabs)
t_ignore  = ' \t\n\r'


# Error handling rule
def t_error(t):

    raise LexError("Lexical error in '{}'".format(t.value[0]))