예제 #1
0
 def testHTMLTable(self):
     productionrulesetlogical = load_bnf_file("pydsl/contrib/grammar/TrueHTMLTable.bnf")
     parser = RecursiveDescentParser(productionrulesetlogical)
     result = parser.get_trees("<table><tr><td>1</td></tr></table>")
     self.assertTrue(result)
     result = parser.get_trees("<trble><tr><td>1</td></tr></table>")
     self.assertFalse(result)
예제 #2
0
 def testLogicalExpression(self):
     productionrulesetlogical = load_bnf_file("pydsl/contrib/grammar/LogicalExpression.bnf")
     parser = RecursiveDescentParser(productionrulesetlogical)
     result = parser.get_trees("True&&False")
     self.assertTrue(result)
     result = parser.get_trees("True&|False")
     self.assertFalse(result)
예제 #3
0
 def testLogicalExp(self):
     productionrulesetlogical = load_bnf_file("pydsl/contrib/grammar/LogicalExpression.bnf")
     #import pdb
     #pdb.set_trace()
     parser = RecursiveDescentParser(productionrulesetlogical)
     result = parser.get_trees(self.tokelist5)
     self.assertTrue(result)
예제 #4
0
 def load(self, name, **kwargs):
     resultlist = self._searcher.search(name)
     if len(resultlist) > 1:
         LOG.error("Found two or more matches, FIXME: processing the first, should raise exception")
     if len(resultlist) == 0:
         raise KeyError(self.__class__.__name__ + name)
     filepath = list(resultlist)[0]["filepath"]
     if _isRELFileName(filepath):
         from pydsl.Memory.File.Regexp import load_re_from_file
         return load_re_from_file(filepath)
     if _isGDLFileName(filepath):
         from pydsl.Memory.File.BNF import load_bnf_file
         return load_bnf_file(filepath)
     if _isBoardFileName(filepath):
         from pydsl.Memory.File.Board import load_board_file
         return load_board_file(filepath)
     from pydsl.Memory.File.Python import load_python_file
     return load_python_file(filepath, **kwargs)
예제 #5
0
 def testFileLoader(self):
     from pydsl.Memory.File.BNF import load_bnf_file
     self.assertTrue(load_bnf_file("tests/Date.bnf"))
예제 #6
0
 def testTrueFalse(self):
     productionrulesetlogical = load_bnf_file("pydsl/contrib/grammar/TrueFalse.bnf")
     parser = RecursiveDescentParser(productionrulesetlogical)
     result = parser.get_trees(self.tokelist5)
     self.assertTrue(result)