Measures Concepts
GitHub icon

Treelang

Treelang - Programming language

< >

Treelang is a programming language created in 1988.

#958on PLDB 36Years Old

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 the GCC 4.3 release cycle, a patch was committed to remove the language, because of high maintenance costs outweighing its benefits and also because it was no longer considered a good front-end example by GCC developers.. Read more on Wikipedia...


Example from Wikipedia:
// function prototypes // function 'add' taking two ints and returning an int external_definition int add(int arg1, int arg2); external_definition int subtract(int arg3, int arg4); external_definition int first_nonzero(int arg5, int arg6); external_definition int double_plus_one(int arg7); external_definition int main(); // function definition add { // return the sum of arg1 and arg2 return arg1 + arg2; } subtract { return arg3 - arg4; } double_plus_one { // aaa is a variable, of type integer and allocated at the start of the function automatic int aaa; // set aaa to the value returned from add, when passed arg7 and arg7 as the two parameters aaa=add(arg7, arg7); aaa=add(aaa, aaa); aaa=subtract(subtract(aaa, arg7), arg7) + 1; return aaa; } first_nonzero { // C-like if statement if (arg5) { return arg5; } else { } return arg6; } // Like C, 'gtreelang' needs the main to be defined to create an executable. main { return double_plus_one(5); }

Language features

Feature Supported Token Example
Comments ✓
// A comment
Line Comments ✓ //
// A comment
Semantic Indentation X

View source

- Build the next great programming language · Search · Add Language · Features · Creators · Resources · About · Blog · Acknowledgements · Queries · Stats · Sponsor · Day 605 · feedback@pldb.io · Logout