xref: /csrg-svn/usr.bin/m4/NOTES (revision 62076)
1*50847Sbosticm4 - macro processor
2*50847Sbostic
3*50847SbosticPD m4 is based on the macro tool distributed with the software
4*50847Sbostictools (VOS) package, and described in the "SOFTWARE TOOLS" and
5*50847Sbostic"SOFTWARE TOOLS IN PASCAL" books. It has been expanded to include
6*50847Sbosticmost of the command set of SysV m4, the standard UN*X macro processor.
7*50847Sbostic
8*50847SbosticSince both PD m4 and UN*X m4 are based on SOFTWARE TOOLS macro,
9*50847Sbosticthere may be certain implementation similarities between
10*50847Sbosticthe two. The PD m4 was produced without ANY references to m4
11*50847Sbosticsources.
12*50847Sbostic
13*50847Sbosticwritten by: Ozan S. Yigit
14*50847Sbostic
15*50847SbosticReferences:
16*50847Sbostic
17*50847Sbostic	Software Tools distribution: macro
18*50847Sbostic
19*50847Sbostic	Kernighan, Brian W. and P. J. Plauger, SOFTWARE
20*50847Sbostic	TOOLS IN PASCAL, Addison-Wesley, Mass. 1981
21*50847Sbostic
22*50847Sbostic	Kernighan, Brian W. and P. J. Plauger, SOFTWARE
23*50847Sbostic	TOOLS, Addison-Wesley, Mass. 1976
24*50847Sbostic
25*50847Sbostic	Kernighan, Brian W. and Dennis M. Ritchie,
26*50847Sbostic	THE M4 MACRO PROCESSOR, Unix Programmer's Manual,
27*50847Sbostic	Seventh Edition, Vol. 2, Bell Telephone Labs, 1979
28*50847Sbostic
29*50847Sbostic	System V man page for M4
30*50847Sbostic
31*50847Sbostic
32*50847SbosticImplementation Notes:
33*50847Sbostic
34*50847Sbostic[1]	PD m4 uses a different (and simpler) stack mechanism than the one
35*50847Sbostic	described in Software Tools and Software Tools in Pascal books.
36*50847Sbostic	The triple stack thing is replaced with a single stack containing
37*50847Sbostic	the call frames and the arguments. Each frame is back-linked to a
38*50847Sbostic	previous stack frame, which enables us to rewind the stack after
39*50847Sbostic	each nested call is completed. Each argument is a character pointer
40*50847Sbostic	to the beginning of the argument string within the string space.
41*50847Sbostic	The only exceptions to this are (*) arg 0 and arg 1, which are
42*50847Sbostic	the macro definition and macro name strings, stored dynamically
43*50847Sbostic	for the hash table.
44*50847Sbostic
45*50847Sbostic	    .					   .
46*50847Sbostic	|   .	|  <-- sp			|  .  |
47*50847Sbostic	+-------+				+-----+
48*50847Sbostic	| arg 3 ------------------------------->| str |
49*50847Sbostic	+-------+				|  .  |
50*50847Sbostic	| arg 2 --------------+ 		   .
51*50847Sbostic	+-------+	      |
52*50847Sbostic	    *		      |			|     |
53*50847Sbostic	+-------+	      | 		+-----+
54*50847Sbostic	| plev	|  <-- fp     +---------------->| str |
55*50847Sbostic	+-------+				|  .  |
56*50847Sbostic	| type	|				   .
57*50847Sbostic	+-------+
58*50847Sbostic	| prcf	-----------+		plev: paren level
59*50847Sbostic	+-------+  	   |		type: call type
60*50847Sbostic	|   .	| 	   |		prcf: prev. call frame
61*50847Sbostic	    .	   	   |
62*50847Sbostic	+-------+	   |
63*50847Sbostic	|	<----------+
64*50847Sbostic	+-------+
65