1import os 2import sys 3import antlr3 4import testbase 5import unittest 6 7 8class t021hoist(testbase.ANTLRTest): 9 def setUp(self): 10 self.compileGrammar() 11 12 13 def testValid1(self): 14 cStream = antlr3.StringStream('enum') 15 lexer = self.getLexer(cStream) 16 tStream = antlr3.CommonTokenStream(lexer) 17 parser = self.getParser(tStream) 18 parser.enableEnum = True 19 enumIs = parser.stat() 20 21 self.assertEqual(enumIs, 'keyword') 22 23 24 def testValid2(self): 25 cStream = antlr3.StringStream('enum') 26 lexer = self.getLexer(cStream) 27 tStream = antlr3.CommonTokenStream(lexer) 28 parser = self.getParser(tStream) 29 parser.enableEnum = False 30 enumIs = parser.stat() 31 32 self.assertEqual(enumIs, 'ID') 33 34 35 36if __name__ == '__main__': 37 unittest.main() 38 39