use shared_ptr
free in parser instead of codegen
change free chain, not sure its correct. but safe to let parser free