Starting from:

$25

CCUCD - Compiler Design - Project 3 - A Simple C Interpreter  - Solved

In this project, you should implement a C interpreter. The supported input file should at least contain the following features:

(1)     integer and floating-point data types: int, float.

(2)     Statements for arithmetic computation. (ex: a = b+2*(100-1)) (3) Comparison expression. (ex: a > b)

(4)     if-then-else program construct.

(5)     printf() function with one/two parameters. (support types: %d, %f)

(6)     scanf() function. (support types: %d, %f)

 

The following is a sample C program (input file):

1.        void main()  

2.        { 

3.        int num; 

4.        float s; 

5.      

6.     printf(“Please enter a number:”); 7.     scanf(“%d”, &num); 

8.      

9.              if (num > 10) { 

10.            s = 3 * (num + 3.14); 

11.            } else { 

12.            s = num * (num – 3.14); 

13.            } 

14.      

15.      printf(“The result is %f\n”, s); 

16.      } 

 


More products