IMPLEMENTATION OF
MACRO PROCESSOR
AIM
To write a C-program for implementing a macro processor.
ALGORITHM
1.Get the state from input file.
2.From the line read,check if opcode is directive “MACRO” if
so then number of macro “n” must be incremented.
3.Repeat step 1 and 2 until end of file is encountered.
4.Open “n” number of files in write mode.These files will
later hold body of “n” macro respectively.
5.Rewind the input file pointer.
6.If opcode is “MACRO”
7.Enter macro name present in operand file field into array
names “m”.
8.Write line to expanded output file.
9.Enter lines in body of each macro into corresponding files
already opened in file.
10.Write body of each macro to be expanded output file also
until “END” is reached.
11.Else if OPCODE is “CALL” the line must be a macro
invocation statement so the macro body is retrieved from the corresponding
file.
12.Write all the remaining lines directly to expanded lines.
PROGRAM:
#include<stdio.h>