HOME

TheInfoList



OR:

Cool, an
acronym An acronym is a word or name formed from the initial components of a longer name or phrase. Acronyms are usually formed from the initial letters of words, as in ''NATO'' (''North Atlantic Treaty Organization''), but sometimes use syllables, as ...
for Classroom Object Oriented Language, is a
computer A computer is a machine that can be programmed to Execution (computing), carry out sequences of arithmetic or logical operations (computation) automatically. Modern digital electronic computers can perform generic sets of operations known as C ...
programming
language Language is a structured system of communication. The structure of a language is its grammar and the free components are its vocabulary. Languages are the primary means by which humans communicate, and may be conveyed through a variety of met ...
designed by
Alexander Aiken Alexander is a male given name. The most prominent bearer of the name is Alexander the Great, the king of the Ancient Greek kingdom of Macedonia who created one of the largest empires in ancient history. Variants listed here are Aleksandar, Al ...
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 In computer science, garbage collection (GC) is a form of automatic memory management. The ''garbage collector'' attempts to reclaim memory which was allocated by the program, but is no longer referenced; such memory is called '' garbage''. ...
, strong static typing and simple
reflection Reflection or reflexion may refer to: Science and technology * Reflection (physics), a common wave phenomenon ** Specular reflection, reflection from a smooth surface *** Mirror image, a reflection in a mirror or in water ** Signal reflection, in ...
. The reference Cool compiler is written in
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
, built fully on the public domain tools. It generates code for a MIPS simulator,
SPIM SPIM is a MIPS processor simulator, designed to run assembly language code for this architecture. The program simulates R2000 and R3000 processors, and was written by James R. Larus while a professor at the University of Wisconsin–Madison. ...
. 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 The University of California, Berkeley (UC Berkeley, Berkeley, Cal, or California) is a public land-grant research university in Berkeley, California. Established in 1868 as the University of California, it is the state's first land-grant univ ...
, where it was first used or
Shahid Beheshti University Shahid Behesti University ( fa, دانشگاه شهید بهشتی , Dāneshgāh-e Shahid Beheshti) (formerly known as the National University of Iran) is a public research university in Tehran, Iran. The university offers many programs at Bache ...
of
Iran Iran, officially the Islamic Republic of Iran, and also called Persia, is a country located in Western Asia. It is bordered by Iraq and Turkey to the west, by Azerbaijan and Armenia to the northwest, by the Caspian Sea and Turkmeni ...
) and the software is stable. This language is unrelated to the COOL language included in
CLIPS CLIPS is a public domain software tool for building expert systems. The name is an acronym for "C Language Integrated Production System." The syntax and name were inspired by Charles Forgy's OPS5. The first versions of CLIPS were developed st ...
.


Features

As the primary purpose of Cool is instruction, it lacks many of the features common to other, more general programming languages. For instance, the language supports less than comparisons but not greater than. The syntax is very much stripped down, and the "standard library" contains only a few basic classes. Separate compilation is not supported, though the compiler does support multiple source files as input. Every Cool program must define a class Main which must have a no argument main method in which execution flow begins. Namespaces are not supported.


Examples

" Hello, world!":
class Main inherits IO ;
A simple program for computing factorials:
class Main inherits IO ;


References

{{reflist
Cool: A Portable Project for Teaching Compiler Construction

PostScript

CoolAid: The Cool 2016 Reference Manual



External links



project main page
Stanford Compilers course page (MOOC)

CoolToJS: An online, interactive Cool compiler
*
VSCode's Language Server Protocol support for COOL and also a full Python implementation of a COOL interpreter
Object-oriented programming languages