Home | History | Annotate | Download | only in tests
      1 import antlr3
      2 import testbase
      3 import unittest
      4 
      5 
      6 class t032subrulePredict(testbase.ANTLRTest):
      7     def setUp(self):
      8         self.compileGrammar()
      9         
     10 
     11     def parserClass(self, base):
     12         class TParser(base):
     13             def recover(self, input, re):
     14                 # no error recovery yet, just crash!
     15                 raise
     16 
     17         return TParser
     18     
     19         
     20     def testValid1(self):
     21         cStream = antlr3.StringStream(
     22             'BEGIN A END'
     23             )
     24 
     25         lexer = self.getLexer(cStream)
     26         tStream = antlr3.CommonTokenStream(lexer)
     27         parser = self.getParser(tStream)
     28         events = parser.a()
     29 
     30 
     31     @testbase.broken("DFA tries to look beyond end of rule b", Exception)
     32     def testValid2(self):
     33         cStream = antlr3.StringStream(
     34             ' A'
     35             )
     36 
     37         lexer = self.getLexer(cStream)
     38         tStream = antlr3.CommonTokenStream(lexer)
     39         parser = self.getParser(tStream)
     40         events = parser.b()
     41 
     42 
     43 if __name__ == '__main__':
     44     unittest.main()
     45