-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
cool.scroll
120 lines (104 loc) · 3.25 KB
/
cool.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import ../code/conceptPage.scroll
id cool
name Classroom Object Oriented Language
appeared 1996
creators Alexander Aiken
tags pl
standsFor Classroom Object Oriented Language
fileType text
wordRank 1457
centralPackageRepositoryCount 0
country United States
originCommunity Stanford University
leachim6 Cool
filepath c/Cool.cl
fileExtensions cl
example
class Main inherits IO {
main(): Object {
out_string("Hello World.\n")
};
};
lineCommentToken --
multiLineCommentTokens (* *)
printToken out_string
booleanTokens true false
hasLineComments true
-- A comment
hasComments true
-- A comment
hasPrintDebugging true
hasMultiLineComments true
(* A comment
*)
hasSemanticIndentation false
hasBooleans true
wikipedia https://en.wikipedia.org/wiki/Cool_(programming_language)
example
class Main inherits IO {
main(): Object {{
out_string("Enter an integer greater-than or equal-to 0: ");
let input: Int <- in_int() in
if input < 0 then
out_string("ERROR: Number must be greater-than or equal-to 0\n")
else {
out_string("The factorial of ").out_int(input);
out_string(" is ").out_int(factorial(input));
out_string("\n");
}
fi;
}};
factorial(num: Int): Int {
if num = 0 then 1 else num * factorial(num - 1) fi
};
};
related clips sather java ml pascal ocaml mips
summary Cool, an acronym for Classroom Object Oriented Language, is a computer programming language designed by Alexander Aiken for use in an undergraduate compiler course project. While small enough for a one term project, Cool still has many of the features of modern programming languages, including objects, automatic memory management, strong static typing and simple reflection. The reference Cool compiler is written in C++, built fully on the public domain tools. It generates code for a MIPS simulator, SPIM. Thus, the language should port easily to other platforms. It has been used for teaching compilers at many institutions (such as the University of California at Berkeley, where it was first used or Shahid Beheshti University of Iran) and the software is stable. This language is unrelated to the COOL language included in CLIPS.
pageId 14782123
created 2007
backlinksCount 18
revisionCount 105
dailyPageViews 25
appeared 1996
githubBigQuery Cool
repos 57
users 56
linguistGrammarRepo https://github.com/anunayk/cool-tmbundle
firstCommit 2014
lastCommit 2014
committerCount 1
commitCount 4
sampleCount 2
example
(* This simple example of a list class is adapted from an example in the
Cool distribution. *)
class List {
isNil() : Bool { true };
head() : Int { { abort(); 0; } };
tail() : List { { abort(); self; } };
cons(i : Int) : List {
(new Cons).init(i, self)
};
};
class Cons inherits List {
car : Int; -- The element in this list cell
cdr : List; -- The rest of the list
isNil() : Bool { false };
head() : Int { car };
tail() : List { cdr };
init(i : Int, rest : List) : List {
{
car <- i;
cdr <- rest;
self;
}
};
};
isbndb 0
githubLanguage Cool
fileExtensions cl
trendingProjectsCount 0
type programming
aceMode text
tmScope source.cool
repos 102