Beispiel #1
0
    def __init__(self):
        """
        Constructor.

        Loads the grammar.
        """
        self._parsley_grammar = _get_parsley_grammar()
        self._solver = translator_factory(self._parsley_grammar)
Beispiel #2
0
 def testDate(self):
     from pydsl.file.parsley import load_parsley_grammar_file
     repository = {'DayOfMonth':load_python_file('pydsl/contrib/grammar/DayOfMonth.py')} #DayOfMonth loaded as checker
     G=load_parsley_grammar_file("pydsl/contrib/grammar/Date.parsley", "expr", repository)
     C=checker_factory(G)
     T=translator_factory(G)
     self.assertTrue(C("2/4/12"))
     self.assertEqual(T("2/4/12"),(2,4,12))
     self.assertRaises(parsley.ParseError,T, "40/4/12")
Beispiel #3
0
 def testCalculator(self):
     G=load_python_file("pydsl/contrib/translator/calculator.py")
     T=translator_factory(G)
     self.assertEqual(T("1+1"),2)