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 script 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 script, the %selectfile directive tells the Target Language Compiler to send any following text that it generates or 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. The STDOUT stream does not have to be opened, but must be selected in order to write to the command window.

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.

Variable Types

The absence of explicit type declarations for variables is another feature of the Target Language Compiler. See Directives and Built-in Functions, for more information on the implicit data types of variables.


  Code Generation Concepts Records