CCUCD Project 3-A Simple C Interpreter Solved

30.00 $

Category:

Description

Rate this product

 

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

  • integer and floating-point data types: int, float.
  • Statements for arithmetic computation. (ex: a = b+2*(100-1)) (3) Comparison expression. (ex: a > b)
  • if-then-else program construct.
  • printf() function with one/two parameters. (support types: %d, %f)
  • scanf() (support types: %d, %f)

 

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

  1. void main()
  2. {
  3. int num;
  4. float s;
  5. printf(“Please enter a number:”); 7. scanf(“%d”, &num);
  6. if (num > 10) {
  7. s = 3 * (num + 3.14);
  8. } else {
  9. s = num * (num – 3.14);
  10. }
  11. printf(“The result is %f\n”, s);
  12. }

 

In your hand-in report, you need to have the followings:

  • Describe the C subset supported by your interpreter.
  • Give a set of testing programs which can illustrate the features of your interpreter. (at least 3 test programs)
  • Use the “ANTLR” to help you develop your interpreter.
  • You can use Java or other programming languages to write your interpreter. (Java is recommended)
  • Please ensure your program can be executed under the mcore8 or

1

Compiler Design

linux.cs.ccu.edu.tw workstation.

 

3

  • Project3_Simple_C_Interpreter-7z2cqv.zip