Skip to content

bjkail/cool-cool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cool-cool

An interpreter for Classroom Object-Oriented Language (Cool) written in Cool.

This interpreter can be run using the UVA Cool Interpreter. A wrapper script is provided that allows multiple input files to be specified to the Cool Interpreter, and another script is provided to pass all requisite files for the interpreter itself to the Cool Interpreter:

$ export COOL_INTERPRETER=path/to/interpreter/cool
$ bin/cool test/interpret/hello-world.cl
Hello, World!

The interpreter can also run itself:

$ bin/cool --bootstrap test/interpret/hello-world.cl
Hello, World!

UVA Dialect

The interpreter can also be run using the UVA dialect of Cool:

$ bin/cool test/interpret/compare-bool.cl
ERROR: test/interpret/compare-bool.cl: line 3: left expression type 'Bool' is not type 'Int' for '<' expression
ERROR: test/interpret/compare-bool.cl: line 3: right expression type 'Bool' is not type 'Int' for '<' expression
$ bin/cool --uva test/interpret/compare-bool.cl
true

The UVA dialect has the following differences from the default dialect:

  1. A \c sequence within a string represents a literal backslash followed by the character (Strings), but IO.out_string interprets the \n and \t sequences as a linefeed and tab respectively (IO).
  2. The < and <= comparison operators can be used on operands of Int, String, and Bool (Arithmetic and Comparison Operations, Type Checking Rules, Operational Rules).
  3. A stack overflow runtime error occurs after 1000 outstanding method dispatch and new expressions. (Operational Rules).
  4. Errors are printed without a filename or stack trace.

Status

  • Lexical analysis - Nearly complete. The null character cannot be used (the UVA Cool Interpreter does not allow the null character in input strings).
  • Parsing - Complete.
  • Semantic analysis - Complete.
  • Interpreter - Complete.

About

An interpreter for Cool written in Cool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published