return mx if nmatch > 0 else 0 # # unit test # if __name__ == '__main__': import parseTest import sys print 'test entity extraction' utre = parseTest.Tree() uctx = parseTest.Context() ee = EntityExtractor(utre, uctx.syms) print 'procedures:' ee.dump() print '' while True: sys.stdout.write('> ') l = sys.stdin.readline() if len(l) <= 1: break b = list(l) mn = ee.run(b) print 'match n=', mn if mn > 0: print utre.lastph
# # unit test # if __name__ == '__main__': import ellyConfiguration import ellyDefinitionReader import parseTest import stat import os mode = os.fstat(0).st_mode # to check for redirection of stdin (=0) interact = not ( stat.S_ISFIFO(mode) or stat.S_ISREG(mode) ) ctx = parseTest.Context() # dummy interpretive context for testing tre = parseTest.Tree(ctx.syms) # dummy parse tree for testing print () basn = ellyConfiguration.baseSource + '/' filn = sys.argv[1] if len(sys.argv) > 1 else 'test' # which FSA definition to use ins = ellyDefinitionReader.EllyDefinitionReader(basn + filn + '.t.elly') print ( 'template test with' , '<' + filn + '>' ) if ins.error != None: print ( ins.error ) sys.exit(1) comp = None try: