def ast2token_seq(data):
	ast = my_c_ast.load_astdata(data)
	ast.before_show()
	#code.interact(local={'ast':ast})
	src = ast.show()
	with open('tmp.c','w') as fp:
		fp.write(src)
	res = tokenizer.tokenize('tmp.c')
	#print(src,res)
	return res
Exemplo n.º 2
0
def show_data():
	for asm,tree in data:
		print('asm:',' '.join([vocab_dst[v] for v in asm]))
		nast = my_c_ast.load_astdata(tree)
		nast.before_show()
		print('source:',nast.show())
Exemplo n.º 3
0
	aststr = ast.show()
	#print(aststr)
	#exit()
	with open('t.c','w') as fp:
		fp.write(aststr)
	#print(ast.get_astdata())
	#c_cfg.data_miyasui(ast.get_astdata())
	c_cfg.validate_astdata(ast.get_astdata(),CursorKind.TRANSLATION_UNIT)
	print('validate passed')
	ds = ast.subexpr_line_list()
	#print(ds)
	#print(ds[-1])
	
	for (a,b),nsize,tree in ds:
		#if nsize<5:
		#	continue
		print(tree)
		print(' '.join(csrc[a-1:b]))
		print(a,b)
		nast = my_c_ast.load_astdata(tree)
		nast.before_show()
		print(nast.show())
		
		tree = c_cfg.alphaconv(tree)
		print(tree)
		nast = my_c_ast.load_astdata(tree)
		nast.before_show()
		print(nast.show())