algorithm for one pass macro processor l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Algorithm for One-pass Macro Processor PowerPoint Presentation
Download Presentation
Algorithm for One-pass Macro Processor

Loading in 2 Seconds...

play fullscreen
1 / 4

Algorithm for One-pass Macro Processor - PowerPoint PPT Presentation


  • 607 Views
  • Uploaded on

Algorithm for One-pass Macro Processor . main () /* main program */ { EXPANDING = 0; /* definition case ; a control variable for reading input record from input sources */ while (OPCODE != ‘END’) {

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Algorithm for One-pass Macro Processor' - diata


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
algorithm for one pass macro processor
Algorithm for One-pass Macro Processor

main () /* main program */

{

EXPANDING = 0; /* definition case; a control variable for reading input record from input sources */

while (OPCODE != ‘END’) {

GETLINE (line); /* get a next line (from expansion or definition); label, opcode, operands */

PROCESSLINE (line); /* define or expand a line after getting it; label, opcode, operands*/

}

}

PROCESSLINE (line)

{

search NAMTAB for line.opcode;

if (found)

EXPAND (line); /* expand macro definition with arguments from invocation */

else if

DEFINE (line); /* put macro definition in DEFTAB */

else

write the source line to expand file;

}

CmpE 220 - Software Systems

algorithm for one pass macro processor2
Algorithm for One-pass Macro Processor

DEFINE (line)

{

enter line.label into NAMTAB; /* enter macro name into NAMTAB */

enter macro prototype into DEFTAB; /* the first declaration statement */

LEVEL = 1;

while (LEVEL > 0) {

GETLINE (line); /* get the next line of the macro definition */

if (line != comment line) {

substitute positional notation for parameters; /* &param_1  ?1, etc. */

enter line into DEFTAB;

if (OPCODE = ‘MACRO’)

LEVEL = LEVEL +1;

else if (OPCODE = ‘MEND’)

LEVEL = LEVEL –1;

}

}

store pointers (label->begin and label->end) in NAMTAB; /* store macro def. begin and end pointers */

}

CmpE 220 - Software Systems

algorithm for one pass macro processor3
Algorithm for One-pass Macro Processor

EXPAND (line)

{

EXPANDING = 1; /* expansion case; ready to read input from DEFTAB*/

get the first line of macro definition (macro prototype) from DEFTAB;

set up arguments (from macro invocation) in ARGTAB;

write macro invocation to expanded file (output file) as a comment;

while (OPCODE != MEND) { /* while not end of macro definition */

GETLINE (line);

PROCESSLINE (line);

}

EXPANDING = 0; /* macro expansion is done */

}

GETLINE (line)

{

if (EXPANDING = 1) {

get next line of macro definition from DEFTAB;

substitute arguments from ARGTAB for position notation;

}

else

read next line from input file; /* read the source program file */

}

}

CmpE 220 - Software Systems

one pass macro processor algorithm

GETLINE

One-pass Macro Processor Algorithm

2

  • A flow chart for the one-pass macro processor algorithm.

INPUT FILE

READ (next line)

2

1

READ (next line)

MACRO

PROCESSOR

DEFTAB

5

SUBSTITUTE (arguments)

4

PROCESSLINE

DEFINE

ENTER (macro prototype/line)

WRITE (source line)

3

5

5

EXPANDED FILE

SEARCH

EXPAND

ARGTAB

NAMTAB

ENTER (macro name)

SET UP (arguments)

CmpE 220 - Software Systems