Cool source files have extension .cl. The programming projects will also define other file formats related to Cool but they are not officially part of the language specification.
You can obtain the Cool interpreter cool from the course website. To interpret (i.e., run) a Cool program:
cool file.clThis official version is often called the reference implementation and you are encouraged to use it as a point of comparison when you are designing and testing parts of the course project.
The reference Cool interpreter has been specifically structured so that you can run the various stages (i.e., lexing, parsing, type-checking and interpreting) independently. This power is useful for PA2 through PA5.
The Cool interpreter has an number of command-line options:
--lex | This option causes Cool to stop after lexing and produce a new file, file.cl-lex, which contains the lexed tokens in a simple interchange format. Handy for PA2. |
--unlex | This option causes Cool to undo lexing and produce file.cl2 (a Cool source file) from the lexed tokens. This is usually used as a debugging aid for PA2 by feeding Cool a file.cl-lex file produced by your lexer from file.cl and then comparing file.cl2 to the original file.cl. |
--parse | This option causes Cool to stop after parsing and produce a new file, file.cl-ast, which contains the abstract syntax tree in a simple interchange format. Handy for PA3. |
--unparse | This option causes Cool to undo parsing and produce file.cl3 (a Cool source file) from the abstract syntax tree. This is usually used as a debugging aid for PA3 by feeding Cool a file.cl-ast file produced by your parser from file.cl and then comparing file.cl3 to the original file.cl. |
--type | This option causes Cool to stop after type checking and semantic analysis and produce a new file, file.cl-type, which contains the class mapping and implementation mapping in a simple interchange format. Handy for PA4. |
--class-map | This option causes Cool to stop after type checking and semantic analysis and produce a new file, file.cl-type, which contains the class mapping only in a simple interchange format. Handy for the PA4 Checkpoint (WA4). |
--imp-map | This option causes Cool to stop after type checking and semantic analysis and produce a new file, file.cl-type, which contains the implementation mapping only in a simple interchange format. Handy for the rest of PA4. |
--out newname | Causes Cool to produce newname.cl (or .cl-ast, or whatever) instead of file.cl. |
You may encounter other University uses of Cool on the web that mention programs such as coolc and spim. Those tool are used for a course on compilers; this is a course on interpreters. We will not use coolc or spim. In addition, we use a slightly different version of the Cool language specification, so comparing results against external tools may not be helpful.