def test_dfa(self): g = load_grammar(os.path.join(PKG, "data"), "udon") gram = make_grammar_from_rules(g.rules) voca = make_voca_from_categories(g.categories, g.vocabularies) result = make_dfa(gram, voca) self.assertIsNotNone(result) self.assertEqual(len(result), 2)
def register_grammar(name, path): root_dir, name = os.path.dirname(path), os.path.basename(path) pub = rospy.Publisher("/grammar", Grammar, queue_size=1) for i in range(10): if rospy.is_shutdown() or pub.get_num_connections() > 0: break rospy.sleep(1) rospy.loginfo("Waiting /grammar is advertised") if pub.get_num_connections() == 0: rospy.logerr("/grammar is not advertised") return gram = load_grammar(root_dir, name) if name: gram.name = name pub.publish(gram)
def test_grammar(self): g = load_grammar(os.path.join(PKG, "data"), "udon") gram = make_grammar_from_rules(g.rules) self.assertIsNotNone(gram)
def test_voca(self): g = load_grammar(os.path.join(PKG, "data"), "udon") voca = make_voca_from_categories(g.categories, g.vocabularies) self.assertIsNotNone(voca)
def test_load_grammar(self): self.assertTrue(os.path.join(PKG, "data", "udon.grammar")) self.assertTrue(os.path.join(PKG, "data", "udon.voca")) g = load_grammar(os.path.join(PKG, "data"), "udon") self.assertIsNotNone(g)