[SOLVED] CCUCD - Compiler Design Project 3 A Simple C Interpreter

30.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (1 vote)

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. }

 

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.