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