# Path: reggata/parsers/query_tokens.py
# ALL_OPERATOR = QCoreApplication.translate("parsers", 'all', None, QCoreApplication.UnicodeUTF8)
# AND_OPERATOR = QCoreApplication.translate("parsers", 'and', None, QCoreApplication.UnicodeUTF8)
# OR_OPERATOR = QCoreApplication.translate("parsers", 'or', None, QCoreApplication.UnicodeUTF8)
# NOT_OPERATOR = QCoreApplication.translate("parsers", 'not', None, QCoreApplication.UnicodeUTF8)
# USER_KEYWORD = QCoreApplication.translate("parsers", 'user', None, QCoreApplication.UnicodeUTF8)
# PATH_KEYWORD = QCoreApplication.translate("parsers", 'path', None, QCoreApplication.UnicodeUTF8)
# TITLE_KEYWORD = QCoreApplication.translate("parsers", 'title', None, QCoreApplication.UnicodeUTF8)
# def t_STRING(t):
# def t_error(t):
# def needs_quote(string):
# def build_lexer():
# 
# Path: reggata/errors.py
# class YaccError(Exception):
#     def __init__(self, msg=None, cause=None):
#         super(YaccError, self).__init__(msg)
#         self.cause = cause
# 
# Path: reggata/consts.py
# DEBUG = False
# METADATA_DIR = ".reggata"
# DB_FILE = "database.sqlite3"
# USER_CONFIG_DIR = os.path.join(os.path.expanduser("~"), ".config", "reggata")
# USER_CONFIG_FILE = os.path.join(USER_CONFIG_DIR, "reggata.conf")
# LOGGING_CONFIG_FILE = os.path.join(USER_CONFIG_DIR, "logging.conf")
# THUMBNAIL_DEFAULT_SIZE = 100
# DEFAULT_TMP_DIR = USER_CONFIG_DIR + os.sep + "tmp"
# RATING_FIELD = "Rating"
# NOTES_FIELD = "Notes"
# RESERVED_FIELDS = [RATING_FIELD, NOTES_FIELD]
# STATUSBAR_TIMEOUT = 5000
# DEFAULT_USER_LOGIN = "user"
# DEFAULT_USER_PASSWORD = ""
# STATISTICS_SERVER = "http://reggata-stats.appspot.com"
# MAX_FILE_SIZE_FOR_FULL_HASHING = 100*1024*1024
# MAX_BYTES_FOR_PARTIAL_HASHING = 10*1024*1024


import ply.yacc as yacc
import reggata.parsers.query_tree_nodes as tree
from reggata.parsers.query_tokens import tokens, build_lexer
from reggata.errors import YaccError
from reggata import consts
    '''field_op : EQUAL
                | GREATER
                | GREATER_EQ
                | LESS
                | LESS_EQ
                | LIKE
    '''
    p[0] = p[1]


def p_field_value(p):
    '''field_value : STRING
    '''
    p[0] = p[1]


def p_all_items(p):
    '''all_items : ALL
    '''
    p[0] = tree.AllItems()


# Error rule for syntax errors
def p_error(p):
    raise YaccError("Syntax error in '{}'".format(str(p)))

# TODO: use file for logging
#yacc_errorlog = ply.yacc.PlyLogger(open(os.path.join(USER_CONFIG_DIR, "yacc.log"), "w"))
yacc_errorlog = yacc.NullLogger()


# Path: reggata/parsers/query_tokens.py
# ALL_OPERATOR = QCoreApplication.translate("parsers", 'all', None, QCoreApplication.UnicodeUTF8)
# AND_OPERATOR = QCoreApplication.translate("parsers", 'and', None, QCoreApplication.UnicodeUTF8)
# OR_OPERATOR = QCoreApplication.translate("parsers", 'or', None, QCoreApplication.UnicodeUTF8)
# NOT_OPERATOR = QCoreApplication.translate("parsers", 'not', None, QCoreApplication.UnicodeUTF8)
# USER_KEYWORD = QCoreApplication.translate("parsers", 'user', None, QCoreApplication.UnicodeUTF8)
# PATH_KEYWORD = QCoreApplication.translate("parsers", 'path', None, QCoreApplication.UnicodeUTF8)
# TITLE_KEYWORD = QCoreApplication.translate("parsers", 'title', None, QCoreApplication.UnicodeUTF8)
# def t_STRING(t):
# def t_error(t):
# def needs_quote(string):
# def build_lexer():
# 
# Path: reggata/errors.py
# class YaccError(Exception):
#     def __init__(self, msg=None, cause=None):
#         super(YaccError, self).__init__(msg)
#         self.cause = cause
# 
# Path: reggata/consts.py
# DEBUG = False
# METADATA_DIR = ".reggata"
# DB_FILE = "database.sqlite3"
# USER_CONFIG_DIR = os.path.join(os.path.expanduser("~"), ".config", "reggata")
# USER_CONFIG_FILE = os.path.join(USER_CONFIG_DIR, "reggata.conf")
# LOGGING_CONFIG_FILE = os.path.join(USER_CONFIG_DIR, "logging.conf")
# THUMBNAIL_DEFAULT_SIZE = 100
# DEFAULT_TMP_DIR = USER_CONFIG_DIR + os.sep + "tmp"
# RATING_FIELD = "Rating"
# NOTES_FIELD = "Notes"
# RESERVED_FIELDS = [RATING_FIELD, NOTES_FIELD]
# STATUSBAR_TIMEOUT = 5000
# DEFAULT_USER_LOGIN = "user"
# DEFAULT_USER_PASSWORD = ""
# STATISTICS_SERVER = "http://reggata-stats.appspot.com"
# MAX_FILE_SIZE_FOR_FULL_HASHING = 100*1024*1024
# MAX_BYTES_FOR_PARTIAL_HASHING = 10*1024*1024


# Path: reggata/parsers/query_parser.py
import ply.yacc as yacc
import reggata.parsers.query_tree_nodes as tree
from reggata.parsers.query_tokens import tokens, build_lexer
from reggata.errors import YaccError
from reggata import consts

    '''field_op : EQUAL
                | GREATER
                | GREATER_EQ
                | LESS
                | LESS_EQ
                | LIKE
    '''
    p[0] = p[1]


def p_field_value(p):
    '''field_value : STRING
    '''
    p[0] = p[1]


def p_all_items(p):
    '''all_items : ALL
    '''
    p[0] = tree.AllItems()


# Error rule for syntax errors
def p_error(p):
    raise YaccError("Syntax error in '{}'".format(str(p)))

# TODO: use file for logging
#yacc_errorlog = ply.yacc.PlyLogger(open(os.path.join(USER_CONFIG_DIR, "yacc.log"), "w"))
yacc_errorlog = yacc.NullLogger()


tokens  # This line is needed to supress warning that 'tokens is unused'