Compiler Designing W01L05 & 06

COOL Example II & III


  • Implemented with two type of fact functions, one is by recursion and second is by loop.
  • One error faced was undefined class A2I in first line of the code. this can be easily avoided by including `` like this: `coolc`


  • Implemented having a list with two items: Object and pointer to list.
  • two function init(): for initialization and flatten(): returning the each item for out_string()

For COOL Manual click here.

I will be doing examples every now and then, the resources can be downloaded from here.

Compiler Designing W01L04.2

COOL Overview (Coding Part)

class Main {
main():Int {1};

Commands to run:-
spim filename.s

Some self Explanatory programs:

class Main(){
i:IO<-new IO;
main():Object { {i.out_string("Hello World!"); } };
class Main inherits IO{
main():Object {{out_string("Hello World!")}}; //or self.out_string

PS: From now on, programs would be on-> github.