Parser COMPLETED!

I-did-it-crown1

See the code here.

Advertisements

Compiler Designing W01L05 & 06

COOL Example II & III

Example1:

  • Implemented fact.cl 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 `atio.cl` like this: `coolc fact.cl atoi.cl`

Example2:

  • Implemented list.cl 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:-
coolc filename.cl
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.