# Path: pydsl/grammar/definition.py
# class String(Grammar, str):
#     def __init__(self, string):
#         if isinstance(string, list):
#             raise TypeError('Attempted to initialize a String with a list %s' % (string, ) )
#         Grammar.__init__(self, None)
# 
#     @property
#     def first(self):
#         return String(self[0])
# 
#     def enum(self):
#         yield self
# 
#     @property
#     def maxsize(self):
#         return len(self)
# 
#     @property
#     def minsize(self):
#         return len(self)
# 
#     @property
#     def alphabet(self):
#         from pydsl.encoding import ascii_encoding
#         return ascii_encoding
# 
# Path: pydsl/grammar/parsley.py
# class ParsleyGrammar(Grammar):
#     def __init__(self, rules, root_rule="expr", repository=None):
#         import parsley
#         Grammar.__init__(self)
#         repo=dict(repository or {})
#         for key in repo:
#             if isinstance(repo[key], Grammar):
#                 repo[key] = checker_factory(repo[key])
#         self.grammar=parsley.makeGrammar(rules, repo)
#         self.root_rule=root_rule 
# 
# Path: pydsl/grammar/PEG.py
# class OneOrMore(Grammar):
#     def __init__(self, element):
#         Grammar.__init__(self)
#         self.element = element
# 
#     def first(self):
#         return Choice([self.element])
# 
# 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))
# 
# Path: pydsl/translator.py
# class ParsleyTranslator(object):
#     def __init__(self, grammar):
#         self.gd=grammar
# 
#     def __call__(self, input):
#         return getattr(self.gd.grammar(input), self.gd.root_rule)() #call grammar(data).root_rule()


import unittest
from pydsl.grammar import String
from pydsl.grammar.parsley import ParsleyGrammar
from pydsl.grammar.PEG import OneOrMore, Choice
from pydsl.translator import ParsleyTranslator
#!/usr/bin/python
# -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#pydsl is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with pydsl.  If not, see <http://www.gnu.org/licenses/>.

__author__ = "Nestor Arocha"
__copyright__ = "Copyright 2008-2014, Nestor Arocha"
__email__ = "nesaro@gmail.com"



class TestBinaryAlphabet(unittest.TestCase):
    def test_binaryAlphabet(self):

# Path: pydsl/grammar/definition.py
# class String(Grammar, str):
#     def __init__(self, string):
#         if isinstance(string, list):
#             raise TypeError('Attempted to initialize a String with a list %s' % (string, ) )
#         Grammar.__init__(self, None)
# 
#     @property
#     def first(self):
#         return String(self[0])
# 
#     def enum(self):
#         yield self
# 
#     @property
#     def maxsize(self):
#         return len(self)
# 
#     @property
#     def minsize(self):
#         return len(self)
# 
#     @property
#     def alphabet(self):
#         from pydsl.encoding import ascii_encoding
#         return ascii_encoding
# 
# Path: pydsl/grammar/parsley.py
# class ParsleyGrammar(Grammar):
#     def __init__(self, rules, root_rule="expr", repository=None):
#         import parsley
#         Grammar.__init__(self)
#         repo=dict(repository or {})
#         for key in repo:
#             if isinstance(repo[key], Grammar):
#                 repo[key] = checker_factory(repo[key])
#         self.grammar=parsley.makeGrammar(rules, repo)
#         self.root_rule=root_rule 
# 
# Path: pydsl/grammar/PEG.py
# class OneOrMore(Grammar):
#     def __init__(self, element):
#         Grammar.__init__(self)
#         self.element = element
# 
#     def first(self):
#         return Choice([self.element])
# 
# 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))
# 
# Path: pydsl/translator.py
# class ParsleyTranslator(object):
#     def __init__(self, grammar):
#         self.gd=grammar
# 
#     def __call__(self, input):
#         return getattr(self.gd.grammar(input), self.gd.root_rule)() #call grammar(data).root_rule()


# Path: tests/functional/test_Binary.py
import unittest
from pydsl.grammar import String
from pydsl.grammar.parsley import ParsleyGrammar
from pydsl.grammar.PEG import OneOrMore, Choice
from pydsl.translator import ParsleyTranslator

#!/usr/bin/python
# -*- coding: utf-8 -*-
#This file is part of pydsl.
#
#pydsl is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#pydsl is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with pydsl.  If not, see <http://www.gnu.org/licenses/>.

__author__ = "Nestor Arocha"
__copyright__ = "Copyright 2008-2014, Nestor Arocha"
__email__ = "nesaro@gmail.com"



class TestBinaryAlphabet(unittest.TestCase):
    def test_binaryAlphabet(self):

        binary_alphabet = Choice([String('0'), String('1')])