xref: /freebsd/usr.bin/m4/NOTES (revision 9b50d9027575220cb6dd09b3e62f03f511e908b8)
19b50d902SRodney W. Grimesm4 - macro processor
29b50d902SRodney W. Grimes
39b50d902SRodney W. GrimesPD m4 is based on the macro tool distributed with the software
49b50d902SRodney W. Grimestools (VOS) package, and described in the "SOFTWARE TOOLS" and
59b50d902SRodney W. Grimes"SOFTWARE TOOLS IN PASCAL" books. It has been expanded to include
69b50d902SRodney W. Grimesmost of the command set of SysV m4, the standard UN*X macro processor.
79b50d902SRodney W. Grimes
89b50d902SRodney W. GrimesSince both PD m4 and UN*X m4 are based on SOFTWARE TOOLS macro,
99b50d902SRodney W. Grimesthere may be certain implementation similarities between
109b50d902SRodney W. Grimesthe two. The PD m4 was produced without ANY references to m4
119b50d902SRodney W. Grimessources.
129b50d902SRodney W. Grimes
139b50d902SRodney W. Grimeswritten by: Ozan S. Yigit
149b50d902SRodney W. Grimes
159b50d902SRodney W. GrimesReferences:
169b50d902SRodney W. Grimes
179b50d902SRodney W. Grimes	Software Tools distribution: macro
189b50d902SRodney W. Grimes
199b50d902SRodney W. Grimes	Kernighan, Brian W. and P. J. Plauger, SOFTWARE
209b50d902SRodney W. Grimes	TOOLS IN PASCAL, Addison-Wesley, Mass. 1981
219b50d902SRodney W. Grimes
229b50d902SRodney W. Grimes	Kernighan, Brian W. and P. J. Plauger, SOFTWARE
239b50d902SRodney W. Grimes	TOOLS, Addison-Wesley, Mass. 1976
249b50d902SRodney W. Grimes
259b50d902SRodney W. Grimes	Kernighan, Brian W. and Dennis M. Ritchie,
269b50d902SRodney W. Grimes	THE M4 MACRO PROCESSOR, Unix Programmer's Manual,
279b50d902SRodney W. Grimes	Seventh Edition, Vol. 2, Bell Telephone Labs, 1979
289b50d902SRodney W. Grimes
299b50d902SRodney W. Grimes	System V man page for M4
309b50d902SRodney W. Grimes
319b50d902SRodney W. Grimes
329b50d902SRodney W. GrimesImplementation Notes:
339b50d902SRodney W. Grimes
349b50d902SRodney W. Grimes[1]	PD m4 uses a different (and simpler) stack mechanism than the one
359b50d902SRodney W. Grimes	described in Software Tools and Software Tools in Pascal books.
369b50d902SRodney W. Grimes	The triple stack thing is replaced with a single stack containing
379b50d902SRodney W. Grimes	the call frames and the arguments. Each frame is back-linked to a
389b50d902SRodney W. Grimes	previous stack frame, which enables us to rewind the stack after
399b50d902SRodney W. Grimes	each nested call is completed. Each argument is a character pointer
409b50d902SRodney W. Grimes	to the beginning of the argument string within the string space.
419b50d902SRodney W. Grimes	The only exceptions to this are (*) arg 0 and arg 1, which are
429b50d902SRodney W. Grimes	the macro definition and macro name strings, stored dynamically
439b50d902SRodney W. Grimes	for the hash table.
449b50d902SRodney W. Grimes
459b50d902SRodney W. Grimes	    .					   .
469b50d902SRodney W. Grimes	|   .	|  <-- sp			|  .  |
479b50d902SRodney W. Grimes	+-------+				+-----+
489b50d902SRodney W. Grimes	| arg 3 ------------------------------->| str |
499b50d902SRodney W. Grimes	+-------+				|  .  |
509b50d902SRodney W. Grimes	| arg 2 --------------+ 		   .
519b50d902SRodney W. Grimes	+-------+	      |
529b50d902SRodney W. Grimes	    *		      |			|     |
539b50d902SRodney W. Grimes	+-------+	      | 		+-----+
549b50d902SRodney W. Grimes	| plev	|  <-- fp     +---------------->| str |
559b50d902SRodney W. Grimes	+-------+				|  .  |
569b50d902SRodney W. Grimes	| type	|				   .
579b50d902SRodney W. Grimes	+-------+
589b50d902SRodney W. Grimes	| prcf	-----------+		plev: paren level
599b50d902SRodney W. Grimes	+-------+  	   |		type: call type
609b50d902SRodney W. Grimes	|   .	| 	   |		prcf: prev. call frame
619b50d902SRodney W. Grimes	    .	   	   |
629b50d902SRodney W. Grimes	+-------+	   |
639b50d902SRodney W. Grimes	|	<----------+
649b50d902SRodney W. Grimes	+-------+
65