- Treelang programming language
Treelang is a "toy" programming language distributed with the
GNU Compiler Collection (GCC) to demonstrate the features of its code-generation backend. It was developed by Tim Josling, based on a language called Toy created by Richard Kenner. During GCC 4.3 release cycle, a patch was offered to remove the language. [ [http://gcc.gnu.org/wiki/TreeLang GCC Wiki (online)] ]Overview
Treelang is loosely based on the C programming language, but omits complex features such as
pointer s,array s, andstructure s. It is currently incomplete, although there are plans to gradually add more demonstrative features.From the documentation distributed with GCC [ [http://stderr.org/doc/treelang-4.1-doc/treelang.html Treelang Documentation] ] :
: Treelang is a sample language, useful only to help people understand how to implement a new language front end to GCC. It is not a useful language in itself other than as an example or basis for building a new language. Therefore only language developers are likely to have an interest in it.
Example
The following example is from the Treelang documentation, modified by adding the main function, and is included to give an impression of the Treelang syntax and semantics:
Note that C-style comments (with the
/* */
syntax) are not legal in Treelang.Commentary
As a simple, C-like language, Treelang is interoperable with C and
C++ with some minor datatype caveats. The designatedfilename extension for Treelang source code files is.tree
. Treelang source code can be compiled by invokinggcc
normally or asgtreelang
. Both invocations run the Treelang frontend (internally labelledtree1
) and produce machine code as output. Treelang does not issue "warning" messages; either the program is correct and is compiled, or it is not.References
Wikimedia Foundation. 2010.