Implemented the first prototype of SAM script file generation.

For now, the tests were performed by copying and pasting the generated
text into the required files. So far, the generated code seems OK.