# Path: pydsl/grammar/definition.py
# class RegularExpression(Grammar):
#     def __init__(self, regexp, flags = 0):
#         Grammar.__init__(self, None)
#         import re
#         retype = type(re.compile('hello, world'))
#         if isinstance(regexp, retype):
#             self.regexp = regexp
#             self.regexpstr = regexp.pattern
#             self.flags = regexp.flags
#         elif isinstance(regexp, str):
#             self.regexpstr = regexp
#             self.flags = flags
#             self.regexp = re.compile(regexp, flags)
#         else:
#             raise TypeError
# 
#     def __hash__(self):
#         return hash(self.regexpstr)
# 
#     def __eq__(self, other):
#         try:
#             return self.regexpstr == other.regexpstr and self.flags == other.flags
#         except AttributeError:
#             return False
# 
#     def __str__(self):
#         return self.regexpstr
# 
#     @property
#     def first(self):
#         i = 0
#         while True:
#             if self.regexpstr[i] == "^":
#                 i+=1
#                 continue
#             if self.regexpstr[i] == "[":
#                 from .PEG import Choice
#                 return Choice([String(x) for x in self.regexpstr[i+1:self.regexpstr.find("]")]])
#             return String(self.regexpstr[i])
# 
#     def __getattr__(self, attr):
#         return getattr(self.regexp, attr)
# 
#     @property
#     def alphabet(self):
#         from pydsl.encoding import ascii_encoding
#         return ascii_encoding
# 
# Path: pydsl/guess.py
# class Guesser(object):
#     """Returns every grammar and alphabet definition that matches the input"""
#     def __init__(self, grammarlist):
#         self.grammarlist = grammarlist
# 
#     def __call__(self, data):
#         return [x for x in self.grammarlist if check(x,data)]


import unittest
from pydsl.grammar import RegularExpression
from pydsl.guess import Guesser
#!/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 TestGuesser(unittest.TestCase):
    def testGuesser(self):
        cstring = RegularExpression('.*')

# Path: pydsl/grammar/definition.py
# class RegularExpression(Grammar):
#     def __init__(self, regexp, flags = 0):
#         Grammar.__init__(self, None)
#         import re
#         retype = type(re.compile('hello, world'))
#         if isinstance(regexp, retype):
#             self.regexp = regexp
#             self.regexpstr = regexp.pattern
#             self.flags = regexp.flags
#         elif isinstance(regexp, str):
#             self.regexpstr = regexp
#             self.flags = flags
#             self.regexp = re.compile(regexp, flags)
#         else:
#             raise TypeError
# 
#     def __hash__(self):
#         return hash(self.regexpstr)
# 
#     def __eq__(self, other):
#         try:
#             return self.regexpstr == other.regexpstr and self.flags == other.flags
#         except AttributeError:
#             return False
# 
#     def __str__(self):
#         return self.regexpstr
# 
#     @property
#     def first(self):
#         i = 0
#         while True:
#             if self.regexpstr[i] == "^":
#                 i+=1
#                 continue
#             if self.regexpstr[i] == "[":
#                 from .PEG import Choice
#                 return Choice([String(x) for x in self.regexpstr[i+1:self.regexpstr.find("]")]])
#             return String(self.regexpstr[i])
# 
#     def __getattr__(self, attr):
#         return getattr(self.regexp, attr)
# 
#     @property
#     def alphabet(self):
#         from pydsl.encoding import ascii_encoding
#         return ascii_encoding
# 
# Path: pydsl/guess.py
# class Guesser(object):
#     """Returns every grammar and alphabet definition that matches the input"""
#     def __init__(self, grammarlist):
#         self.grammarlist = grammarlist
# 
#     def __call__(self, data):
#         return [x for x in self.grammarlist if check(x,data)]


# Path: tests/unit/test_Guess.py
import unittest
from pydsl.grammar import RegularExpression
from pydsl.guess import Guesser

#!/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 TestGuesser(unittest.TestCase):
    def testGuesser(self):
        cstring = RegularExpression('.*')

        g1234 = RegularExpression('1234')