# 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 checker_factory(grammar):
#     from pydsl.grammar.BNF import BNFGrammar
#     from pydsl.grammar.PEG import Sequence, Choice, OneOrMore, ZeroOrMore
#     from pydsl.grammar.definition import PLYGrammar, RegularExpression, String, PythonGrammar, JsonSchema
#     from pydsl.grammar.parsley import ParsleyGrammar
#     if isinstance(grammar, str) and not isinstance(grammar, String):
#         raise TypeError(grammar)
#     if isinstance(grammar, BNFGrammar):
#         return BNFChecker(grammar)
#     elif isinstance(grammar, JsonSchema):
#         return JsonSchemaChecker(grammar)
#     elif isinstance(grammar, RegularExpression):
#         return RegularExpressionChecker(grammar)
#     elif isinstance(grammar, PythonGrammar) or isinstance(grammar, dict) and "matchFun" in grammar:
#         return PythonChecker(grammar)
#     elif isinstance(grammar, PLYGrammar):
#         return PLYChecker(grammar)
#     elif isinstance(grammar, Choice):
#         return ChoiceChecker(grammar)
#     elif isinstance(grammar, ParsleyGrammar):
#         return ParsleyChecker(grammar)
#     elif isinstance(grammar, String):
#         return StringChecker(grammar)
#     elif isinstance(grammar, Sequence):
#         return SequenceChecker(grammar)
#     elif isinstance(grammar, OneOrMore):
#         return OneOrMoreChecker(grammar)
#     elif isinstance(grammar, ZeroOrMore):
#         return ZeroOrMoreChecker(grammar)
#     elif isinstance(grammar, Iterable):
#         return ChoiceChecker(grammar)
#     else:
#         raise ValueError(grammar)


from pydsl.grammar.definition import Grammar
from pydsl.check import checker_factory
        import parsley
#!/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/>.

from __future__ import absolute_import

__author__ = "Ptolom"
__copyright__ = "Copyright 2014, Ptolom"
__email__ = "ptolom@hexifact.co.uk"

class ParsleyGrammar(Grammar):
    def __init__(self, rules, root_rule="expr", repository=None):
        Grammar.__init__(self)
        repo=dict(repository or {})
        for key in repo:

# 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 checker_factory(grammar):
#     from pydsl.grammar.BNF import BNFGrammar
#     from pydsl.grammar.PEG import Sequence, Choice, OneOrMore, ZeroOrMore
#     from pydsl.grammar.definition import PLYGrammar, RegularExpression, String, PythonGrammar, JsonSchema
#     from pydsl.grammar.parsley import ParsleyGrammar
#     if isinstance(grammar, str) and not isinstance(grammar, String):
#         raise TypeError(grammar)
#     if isinstance(grammar, BNFGrammar):
#         return BNFChecker(grammar)
#     elif isinstance(grammar, JsonSchema):
#         return JsonSchemaChecker(grammar)
#     elif isinstance(grammar, RegularExpression):
#         return RegularExpressionChecker(grammar)
#     elif isinstance(grammar, PythonGrammar) or isinstance(grammar, dict) and "matchFun" in grammar:
#         return PythonChecker(grammar)
#     elif isinstance(grammar, PLYGrammar):
#         return PLYChecker(grammar)
#     elif isinstance(grammar, Choice):
#         return ChoiceChecker(grammar)
#     elif isinstance(grammar, ParsleyGrammar):
#         return ParsleyChecker(grammar)
#     elif isinstance(grammar, String):
#         return StringChecker(grammar)
#     elif isinstance(grammar, Sequence):
#         return SequenceChecker(grammar)
#     elif isinstance(grammar, OneOrMore):
#         return OneOrMoreChecker(grammar)
#     elif isinstance(grammar, ZeroOrMore):
#         return ZeroOrMoreChecker(grammar)
#     elif isinstance(grammar, Iterable):
#         return ChoiceChecker(grammar)
#     else:
#         raise ValueError(grammar)


# Path: pydsl/grammar/parsley.py
from pydsl.grammar.definition import Grammar
from pydsl.check import checker_factory
        import parsley

#!/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/>.

from __future__ import absolute_import

__author__ = "Ptolom"
__copyright__ = "Copyright 2014, Ptolom"
__email__ = "ptolom@hexifact.co.uk"

class ParsleyGrammar(Grammar):
    def __init__(self, rules, root_rule="expr", repository=None):
        Grammar.__init__(self)
        repo=dict(repository or {})
        for key in repo:

            if isinstance(repo[key], Grammar):