Beispiel #1
0
    def __init__(self, n):
        self.statusSummary = {"LL1": 0, "non-LL1": 0}
        self.gc = GrammarChecker.GrammarChecker()
        self.g = SingleGrammarGenerator.SingleGrammarGenerator()

        #builds the ML model using our trainingData
        fI = os.path.join(script_dir,
                          'trainingData/' + str(n) + 'var-interesting')
        fN = os.path.join(script_dir,
                          'trainingData/' + str(n) + 'var-not-interesting')
        self.learnModel = SvmLearn.SvmLearn(n, fI, fN)
Beispiel #2
0
 def test_solve_parsing_table(self):
     checker = grammar_checker.GrammarChecker()
     result = checker.solve({'A': ['xA', 'Bz'], 'B': ['yB']}, 'A', False)
     parsing_table = result[2]
     self.assertEqual(parsing_table, {
         'A': {
             'x': ['xA'],
             'y': ['Bz']
         },
         'B': {
             'y': ['yB']
         }
     })
Beispiel #3
0
 def test_solve_reachability(self):
     checker = grammar_checker.GrammarChecker()
     result = checker.solve({'A': ['xA', 'Bz'], 'B': ['yB']}, 'A', False)
     reachability = result[4]
     self.assertEqual(reachability, True)
Beispiel #4
0
 def test_solve_status(self):
     checker = grammar_checker.GrammarChecker()
     result = checker.solve({'A': ['xA', 'Bz'], 'B': ['yB']}, 'A', False)
     status = result[3]
     self.assertEqual(status, 0)
Beispiel #5
0
 def test_solve_follow_sets(self):
     checker = grammar_checker.GrammarChecker()
     result = checker.solve({'A': ['xA', 'Bz'], 'B': ['yB']}, 'A', False)
     follow_sets = result[1]
     self.assertEqual(follow_sets, {'A': ['$'], 'B': ['z']})
Beispiel #6
0
 def test_solve_first_sets(self):
     checker = grammar_checker.GrammarChecker()
     result = checker.solve({'A': ['xA', 'Bz'], 'B': ['yB']}, 'A', False)
     first_sets = result[0]
     self.assertEqual(first_sets, {'A': ['x', 'y'], 'B': ['y']})
Beispiel #7
0
 def test_solve_terminals(self):
     checker = grammar_checker.GrammarChecker()
     result = checker.solve({'A': ['xA', 'Bz'], 'B': ['yB']}, 'A', False)
     terminals = result[5]
     self.assertEqual(terminals, ['x', 'y', 'z'])