0% found this document useful (0 votes)
6 views1 page

Lab Assignment 3

This document outlines Lab Assignment 3 for the Compiler course at the Indian Institute of Information Technology, Nagpur, for the 2024-2025 session. The assignment involves three tasks: converting loops in C programs, writing a lex program to mark keywords and identifiers, and processing macros with a substitution feature. The submission deadline is set for April 2, 2025, with a total of 30 marks available.

Uploaded by

vinnu.spa04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Lab Assignment 3

This document outlines Lab Assignment 3 for the Compiler course at the Indian Institute of Information Technology, Nagpur, for the 2024-2025 session. The assignment involves three tasks: converting loops in C programs, writing a lex program to mark keywords and identifiers, and processing macros with a substitution feature. The submission deadline is set for April 2, 2025, with a total of 30 marks available.

Uploaded by

vinnu.spa04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Indian Institute of Information Technology, Nagpur

Department of Computer Science and Engineering


Session:2024-2025
Course: Compiler
Lab Assignment 3
Semester: VI Marks: 30

This assignment is based on preprocessing C language program. Submission deadline is 2nd


April 2025.

1. Convert “for-loop”/“do-while loop” to “while loop” without changing the meaning of


the program. There may be loops inside loops and so on. The input would be a C
language program and output would be a valid C language program. Both the programs
should be compiling and producing same output for same input. [10M]

2. Write a lex program which takes a C language program as input and places a marker
<KW> and <ID> with every Keyword and Identifier respectively.
Example:
Input Program
main( )
{
int a = 10;
printf(“%d\n”, a);
}

Output program
main( )
{
int<KW> a<ID> = 10;
printf(“%d\n”, a);
} [10M]

3. Write code to process macros.


For Example:

#define f(x) x*x

If anywhere f(x) appears in any function then it is replaced by the right side of the
macro substituting for the argument ‘x’.
For example, f(3) would be replaced with 3*3. Remember that a macro can call
another macro.
The program should also produce a table of all macros (#defines) and their values.
[10M]

You might also like