Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dr. Mohamed Ben Othman 1 Project phase 3 1)Rewrite the code of the project in the slides, run it: 1)change it so the input should be from file with extension.exp.

Similar presentations


Presentation on theme: "Dr. Mohamed Ben Othman 1 Project phase 3 1)Rewrite the code of the project in the slides, run it: 1)change it so the input should be from file with extension.exp."— Presentation transcript:

1 Dr. Mohamed Ben Othman 1 Project phase 3 1)Rewrite the code of the project in the slides, run it: 1)change it so the input should be from file with extension.exp 2)The output should be to a file with the same name and extension.obj 3)The errors should be in a file with the same name and extension.err 2) Add more error information

2 Dr. Mohamed Ben Othman 2 3- As you can see the output of the program is the postfix notation of the infix expression given as input. Change the code so the output will be in the intermediate code instead of postfix format.

3 Dr. Mohamed Ben Othman 3 1 + 2 – 5; Compiler 1 2 + 5 - Input (Infix) Output (Postfix) Push 1 Push 2 Pop r1 Pop r2 Add r2, r1 Push r2 Push 5 Pop r1 Pop r2 Sub r2, r1 Push r2 Output (Intermediate code)

4 Dr. Mohamed Ben Othman 4 The Operations in intermediate language are: Add: addition Sub: subtraction Rdiv: real division Div: integer division Mod: division reminder Mult: multiplication 5- change the grammar by adding the semantic actions. 6- change the program to provide the intermediate code as output.

5 Dr. Mohamed Ben Othman 5 Hint: manipulation of files in C char InputFileName[80], OutputFileName[80], ErrorFileName [80]; strcpy(InputFileName,"file"); strcat(InputFileName,".exp"); input = fopen(InputFileName,"r"); fprintf(output, “%d %s …”, …); fscanf(input, “%d …”, …); t = fgetc(input);


Download ppt "Dr. Mohamed Ben Othman 1 Project phase 3 1)Rewrite the code of the project in the slides, run it: 1)change it so the input should be from file with extension.exp."

Similar presentations


Ads by Google