It seems like it should be much easier to do this in Lisp. In other languages wouldn't you need to work on the AST instead of on the source code to have much chance of generating syntactically correct programs ?
Lee Spector has made a Forth(like) language, called PushGP, which, in my opinion, handles syntactical correctness in a nice way. There's even a JS implementation, which wasn't there the last time I checked.