The FIL programming in GPOST allows to do such things, although it is not always very comfortable.
The INSERT command allows you to wnter any text, so based on what you compute in your program, you can virtually enter whatever you like.
But I believe there should be simple options to specify files that are attached to the begin/end of the postprocessed code, so can be used to add comments or other code.