-
-
Notifications
You must be signed in to change notification settings - Fork 85
/
treelang.scroll
79 lines (68 loc) · 2.28 KB
/
treelang.scroll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import ../code/conceptPage.scroll
id treelang
name Treelang
appeared 1988
tags pl
centralPackageRepositoryCount 0
reference https://web.archive.org/web/20011108165657/http://www.geocities.com/timjosling/treelang.diff.txt
lineCommentToken //
hasLineComments true
// A comment
hasComments true
// A comment
hasSemanticIndentation false
wikipedia https://en.wikipedia.org/wiki/Treelang
example
// 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);
}
related c
summary 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.
created 2004
backlinksCount 5
pageId 799463
revisionCount 37
dailyPageViews 2
appeared 2008
isbndb 0