# 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


from .definition import Grammar
from itertools import chain
        from .definition import String
    def __hash__(self):
        return hash(tuple(self))

    @classmethod
    def from_string(cls, string):
        return cls([String(x) for x in string])

class Choice(set, Grammar):
    """Uses a list of grammar definitions with common base alphabets"""
    def __init__(self, grammarlist, calculate_base_alphabet = True):
        set.__init__(self, grammarlist)
        if calculate_base_alphabet:
            base_alphabet = set()
            for x in self:
                base_alphabet = base_alphabet.union(x.alphabet)
        else:
            base_alphabet = None
        Grammar.__init__(self, base_alphabet)

    def __str__(self):
        return str([str(x) for x in self])

    def __add__(self, other):
        return Choice([x for x in self] + [x for x in other])

    def __hash__(self):
        return hash(tuple(x for x in self))

class Optional(object):
    def __init__(self, element):

# 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/grammar/PEG.py
from .definition import Grammar
from itertools import chain
        from .definition import String

    def __hash__(self):
        return hash(tuple(self))

    @classmethod
    def from_string(cls, string):
        return cls([String(x) for x in string])

class Choice(set, Grammar):
    """Uses a list of grammar definitions with common base alphabets"""
    def __init__(self, grammarlist, calculate_base_alphabet = True):
        set.__init__(self, grammarlist)
        if calculate_base_alphabet:
            base_alphabet = set()
            for x in self:
                base_alphabet = base_alphabet.union(x.alphabet)
        else:
            base_alphabet = None
        Grammar.__init__(self, base_alphabet)

    def __str__(self):
        return str([str(x) for x in self])

    def __add__(self, other):
        return Choice([x for x in self] + [x for x in other])

    def __hash__(self):
        return hash(tuple(x for x in self))

class Optional(object):
    def __init__(self, element):

        Grammar.__init__(self)