GNU Treelang, or treelang
, is designed initially as a free
replacement for, or alternative to, the 'toy' language, but which is
amenable to inclusion within the GCC source tree.
treelang
is largely a cut down version of C, designed to showcase
the features of the GCC code generation back end. Only those features
that are directly supported by the gcc code generation back end are
implemented. Features are implemented in a manner which is easiest and
clearest to implement. Not all or even most code generation back end
features are implemented. The intention is to add features incrementally
until most features of the GCC back end are implemented in treelang.
The main features missing are structures, arrays and pointers.
A sample program follows:
// 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); // 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 aaa, 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; }
Go to the first, previous, next, last section, table of contents.