from simpleparse import generator
from simpleparse.examples import pythonebnfgenerator
from TextTools import TextTools
import pprint

declaration = open( 'py_ebnf.def').read()
testdata = open( r'python.def').read()

def test ( ):
	parser = generator.buildParser( declaration ).parserbyname( 'declarationset' )
	newgenerator = pythonebnfgenerator.PythonEBNFGenerator( testdata, parser )
	newgenerator.build( )
	return newgenerator

if __name__ == '__main__':
	newgenerator = test()
	pythonparsertuple = newgenerator.parserbyname( 'file_input' )
	pprint.pprint( pythonparsertuple )
	#for file in (r'p:\simpleparse\generator.py',r'p:\simpleparse\bootstrap.py'):
	#	data = open( file ).read()
	#	pprint.pprint( TextTools.tag( data, pythonparsertuple)), 'length:',len( data )
	#pprint.pprint( b.parserbyname( 'single_input' ) )
	