Target Language Compiler    

Output Streams

The typical "Hello World" example is rather simple in the target language. Type the following in a file named hello.tlc

To run this Target Language Compiler program, type

at the MATLAB prompt.

This simple program demonstrates some important concepts underlying the purpose (and hence the design) of the Target Language Compiler. Since the primary purpose of the Target Language Compiler is to generate code, it is output (or stream) oriented. It makes it easy to handle buffers of text and output them easily. In the above program, the %selectfile directive tells the Target Language Compiler to send any following text that it does not recognize to the standard output device. All syntax that the Target Language Compiler recognizes begins with the % character. Since Hello, World is not recognized, it is sent directly to the output. You could just as easily change the output destination to be a file.

Note that you can switch between buffers to display status messages. The semantics of the three directives, %openfile, %selectfile, and %closefile are given in the Compiler Directives table.


 Code Generation Concepts Variable Types