LTLCodeGen: Code Generation of Syntactically Correct Temporal Logic for Robot Task Planning