# Path: pydsl/grammar/definition.py
# class Grammar(object):
# 
#     def __init__(self, base_alphabet = None):
#         self.__base_alphabet = base_alphabet
# 
#     def enum(self):
#         """Generates every possible accepted string"""
#         raise NotImplementedError
# 
#     @property
#     def first(self):
#         """Alphabet that matches every possible first element.
#         the returned value is a subset of the base_alphabet"""
#         return self.alphabet
# 
#     @property
#     def minsize(self):# -> int:
#         """Returns the minimum size in alphabet tokens"""
#         return 0
# 
#     @property
#     def maxsize(self):
#         """Returns the max size in alphabet tokens"""
#         return None
# 
#     @property
#     def alphabet(self):
#         if not self.__base_alphabet:
#             raise AttributeError
#         return self.__base_alphabet
# 
# Path: pydsl/check.py
# def check(definition, data, *args, **kwargs):
#     """Checks if the input follows the definition"""
#     checker = checker_factory(definition)
#     return checker(data, *args, **kwargs)


import logging
from pydsl.grammar.definition import Grammar
from pydsl.check import check
    def __init__(self, name):
        Symbol.__init__(self)

    def __str__(self):
        return "<NonTS: " + self + ">"

    def __hash__(self):
        return str.__hash__(self)

    def __eq__(self, other):
        if not isinstance(other, NonTerminalSymbol):
            return False
        return str.__eq__(self,other)


class TerminalSymbol(Symbol):

    def __init__(self, gd):
        if not isinstance(gd, Grammar):
            raise TypeError("Expected Grammar, got %s" % (gd,))
        Symbol.__init__(self)
        if not gd:
            raise Exception
        self.gd = gd

    def __hash__(self):
        return hash(self.gd)

    def check(self, data):# ->bool:
        """Checks if input is recognized as this symbol"""

# Path: pydsl/grammar/definition.py
# class Grammar(object):
# 
#     def __init__(self, base_alphabet = None):
#         self.__base_alphabet = base_alphabet
# 
#     def enum(self):
#         """Generates every possible accepted string"""
#         raise NotImplementedError
# 
#     @property
#     def first(self):
#         """Alphabet that matches every possible first element.
#         the returned value is a subset of the base_alphabet"""
#         return self.alphabet
# 
#     @property
#     def minsize(self):# -> int:
#         """Returns the minimum size in alphabet tokens"""
#         return 0
# 
#     @property
#     def maxsize(self):
#         """Returns the max size in alphabet tokens"""
#         return None
# 
#     @property
#     def alphabet(self):
#         if not self.__base_alphabet:
#             raise AttributeError
#         return self.__base_alphabet
# 
# Path: pydsl/check.py
# def check(definition, data, *args, **kwargs):
#     """Checks if the input follows the definition"""
#     checker = checker_factory(definition)
#     return checker(data, *args, **kwargs)


# Path: pydsl/grammar/symbol.py
import logging
from pydsl.grammar.definition import Grammar
from pydsl.check import check

    def __init__(self, name):
        Symbol.__init__(self)

    def __str__(self):
        return "<NonTS: " + self + ">"

    def __hash__(self):
        return str.__hash__(self)

    def __eq__(self, other):
        if not isinstance(other, NonTerminalSymbol):
            return False
        return str.__eq__(self,other)


class TerminalSymbol(Symbol):

    def __init__(self, gd):
        if not isinstance(gd, Grammar):
            raise TypeError("Expected Grammar, got %s" % (gd,))
        Symbol.__init__(self)
        if not gd:
            raise Exception
        self.gd = gd

    def __hash__(self):
        return hash(self.gd)

    def check(self, data):# ->bool:
        """Checks if input is recognized as this symbol"""

        return check(self.gd, data)