One-pass Macro Processors
A one-pass macro processor is another design option available for macro processing. The restriction in working with one-pass macro processors is that they strictly require the definition of a macro to appear always before any statements that invoke that macro in the program.
The important data structures required in a one-pass macro processor are:
- DEFTAB (Definition Table): It is a definition table that used to store the macro definition including macro prototype and macro body. Comment lines are not included here, and references to the parameters use a positional notation for efficiency in substituting arguments.
- NAMTAB (Name Table): This table used for storing macros names. It serves as an index to DEFTAB and maintains pointers that point to the beginning and end of the macro definition in DEFTAB.
- ARGTAB (Argument Table): It maintains arguments according to their positions in the argument list. During expansion, the arguments from this table substituted for the corresponding parameters in the macro body.
- One-pass Macro Processor scheme presented as below.
Static Linking One-pass Macro Processors
- In static linking, the liner links all modules of a program before its execution begins; it produces a binary program that does not contain any unresolved external references.
- If statically linked programs use the same module from a library, each program will get a private copy of the module.
- If many programs that use the module are in execution at the same time, many copies of the module might be present in memory.
Dynamic Linking One-pass Macro Processors
- Dynamic linking performed during execution of a binary program.
- The linker invoked when an unresolved external reference and resumes execution of the program.
- This arrangement has several benefits concerning use, sharing and updating of library modules.
- If the module referenced by a program has already been linked to another program that in execution, a copy of the module would exist in memory. The same copy of the module could line to his program as well, thus saving memory.
- To facilitate dynamic linking, each program first processed by the static linker.
- The static linker links each external reference in the program to a dummy module whose