1 | #
|
---|
2 | # test file for mp (not comprehensive)
|
---|
3 | #
|
---|
4 | # v7 m4 does not have `decr'.
|
---|
5 | #
|
---|
6 | define(DECR,`eval($1-1)')
|
---|
7 | #
|
---|
8 | # include string macros
|
---|
9 | #
|
---|
10 | include(String.m4)
|
---|
11 | #
|
---|
12 | # create some fortrash strings for an even uglier language
|
---|
13 | #
|
---|
14 | string(TEXT, "text")
|
---|
15 | string(DATA, "data")
|
---|
16 | string(BEGIN, "begin")
|
---|
17 | string(END, "end")
|
---|
18 | string(IF, "if")
|
---|
19 | string(THEN, "then")
|
---|
20 | string(ELSE, "else")
|
---|
21 | string(CASE, "case")
|
---|
22 | string(REPEAT, "repeat")
|
---|
23 | string(WHILE, "while")
|
---|
24 | string(DEFAULT, "default")
|
---|
25 | string(UNTIL, "until")
|
---|
26 | string(FUNCTION, "function")
|
---|
27 | string(PROCEDURE, "procedure")
|
---|
28 | string(EXTERNAL, "external")
|
---|
29 | string(FORWARD, "forward")
|
---|
30 | string(TYPE, "type")
|
---|
31 | string(VAR, "var")
|
---|
32 | string(CONST, "const")
|
---|
33 | string(PROGRAM, "program")
|
---|
34 | string(INPUT, "input")
|
---|
35 | string(OUTPUT, "output")
|
---|
36 | #
|
---|
37 | divert(2)
|
---|
38 | diversion #1
|
---|
39 | divert(3)
|
---|
40 | diversion #2
|
---|
41 | divert(4)
|
---|
42 | diversion #3
|
---|
43 | divert(5)
|
---|
44 | diversion #4
|
---|
45 | divert(0)
|
---|
46 | define(abc,xxx)
|
---|
47 | ifdef(`abc',defined,undefined)
|
---|
48 | #
|
---|
49 | # v7 m4 does this wrong. The right output is
|
---|
50 | # this is A vEry lon sEntEnCE
|
---|
51 | # see m4 documentation for translit.
|
---|
52 | #
|
---|
53 | translit(`this is a very long sentence', abcdefg, ABCDEF)
|
---|
54 | #
|
---|
55 | # include towers-of-hanoi
|
---|
56 | #
|
---|
57 | include(Hanoi.m4)
|
---|
58 | #
|
---|
59 | # some reasonable set of disks
|
---|
60 | #
|
---|
61 | hanoi(6)
|
---|
62 | #
|
---|
63 | # include ackermann's function
|
---|
64 | #
|
---|
65 | include(Ack.m4)
|
---|
66 | #
|
---|
67 | # something like (3,3) will blow away un*x m4.
|
---|
68 | #
|
---|
69 | ack(2,3)
|
---|
70 | #
|
---|
71 | # include a square_root function for fixed nums
|
---|
72 | #
|
---|
73 | include(Sqroot.m4)
|
---|
74 | #
|
---|
75 | # some square roots.
|
---|
76 | #
|
---|
77 | square_root(15)
|
---|
78 | square_root(100)
|
---|
79 | square_root(-4)
|
---|
80 | square_root(21372)
|
---|
81 | #
|
---|
82 | # some textual material for enjoyment.
|
---|
83 | #
|
---|
84 | [taken from the 'Clemson University Computer Newsletter',
|
---|
85 | September 1981, pp. 6-7]
|
---|
86 |
|
---|
87 | I am a wizard in the magical Kingdom of Transformation and I
|
---|
88 | slay dragons for a living. Actually, I am a systems programmer.
|
---|
89 | One of the problems with systems programming is explaining to
|
---|
90 | non-computer enthusiasts what that is. All of the terms I use to
|
---|
91 | describe my job are totally meaningless to them. Usually my response
|
---|
92 | to questions about my work is to say as little as possible. For
|
---|
93 | instance, if someone asks what happened at work this week, I say
|
---|
94 | "Nothing much" and then I change the subject.
|
---|
95 |
|
---|
96 | With the assistance of my brother, a mechanical engineer, I have devised
|
---|
97 | an analogy that everyone can understand. The analogy describes the
|
---|
98 | "Kingdom of Transformation" where travelers wander and are magically
|
---|
99 | transformed. This kingdom is the computer and the travelers are information.
|
---|
100 | The purpose of the computer is to change information to a more meaningful
|
---|
101 | forma. The law of conservation applies here: The computer never creates
|
---|
102 | and never intentionally destroys data. With no further ado, let us travel
|
---|
103 | to the Kingdom of Transformation:
|
---|
104 |
|
---|
105 | In a land far, far away, there is a magical kingdom called the Kingdom of
|
---|
106 | Transformation. A king rules over this land and employs a Council of
|
---|
107 | Wizardry. The main purpose of this kingdom is to provide a way for
|
---|
108 | neighboring kingdoms to transform citizens into more useful citizens. This
|
---|
109 | is done by allowing the citizens to enter the kingdom at one of its ports
|
---|
110 | and to travel any of the many routes in the kingdom. They are magically
|
---|
111 | transformed along the way. The income of the Kingdom of Transformation
|
---|
112 | comes from the many toll roads within its boundaries.
|
---|
113 |
|
---|
114 | The Kingdom of Transformation was created when several kingdoms got
|
---|
115 | together and discovered a mutual need for new talents and abilities for
|
---|
116 | citizens. They employed CTK, Inc. (Creators of Transformation, Inc.) to
|
---|
117 | create this kingdom. CTK designed the country, its transportation routes,
|
---|
118 | and its laws of transformation, and created the major highway system.
|
---|
119 |
|
---|
120 | Hazards
|
---|
121 | =======
|
---|
122 |
|
---|
123 | Because magic is not truly controllable, CTK invariably, but unknowingly,
|
---|
124 | creates dragons. Dragons are huge fire-breathing beasts which sometimes
|
---|
125 | injure or kill travelers. Fortunately, they do not travel, but always
|
---|
126 | remain near their den.
|
---|
127 |
|
---|
128 | Other hazards also exist which are potentially harmful. As the roads
|
---|
129 | become older and more weatherbeaten, pot-holes will develop, trees will
|
---|
130 | fall on travelers, etc. CTK maintenance men are called to fix these
|
---|
131 | problems.
|
---|
132 |
|
---|
133 | Wizards
|
---|
134 | =======
|
---|
135 |
|
---|
136 | The wizards play a major role in creating and maintaining the kingdom but
|
---|
137 | get little credit for their work because it is performed secretly. The
|
---|
138 | wizards do not wan the workers or travelers to learn their incantations
|
---|
139 | because many laws would be broken and chaos would result.
|
---|
140 |
|
---|
141 | CTK's grand design is always general enough to be applicable in many
|
---|
142 | different situations. As a result, it is often difficult to use. The
|
---|
143 | first duty of the wizards is to tailor the transformation laws so as to be
|
---|
144 | more beneficial and easier to use in their particular environment.
|
---|
145 |
|
---|
146 | After creation of the kingdom, a major duty of the wizards is to search for
|
---|
147 | and kill dragons. If travelers do not return on time or if they return
|
---|
148 | injured, the ruler of the country contacts the wizards. If the wizards
|
---|
149 | determine that the injury or death occurred due to the traveler's
|
---|
150 | negligence, they provide the traveler's country with additional warnings.
|
---|
151 | If not, they must determine if the cause was a road hazard or a dragon. If
|
---|
152 | the suspect a road hazard, they call in a CTK maintenance man to locate the
|
---|
153 | hazard and to eliminate it, as in repairing the pothole in the road. If
|
---|
154 | they think that cause was a dragon, then they must find and slay it.
|
---|
155 |
|
---|
156 | The most difficult part of eliminating a dragon is finding it. Sometimes
|
---|
157 | the wizard magically knows where the dragon's lair it, but often the wizard
|
---|
158 | must send another traveler along the same route and watch to see where he
|
---|
159 | disappears. This sounds like a failsafe method for finding dragons (and a
|
---|
160 | suicide mission for thr traveler) but the second traveler does not always
|
---|
161 | disappear. Some dragons eat any traveler who comes too close; others are
|
---|
162 | very picky.
|
---|
163 |
|
---|
164 | The wizards may call in CTK who designed the highway system and
|
---|
165 | transformation laws to help devise a way to locate the dragon. CTK also
|
---|
166 | helps provide the right spell or incantation to slay the dragon. (There is
|
---|
167 | no general spell to slay dragons; each dragon must be eliminated with a
|
---|
168 | different spell.)
|
---|
169 |
|
---|
170 | Because neither CTK nor wizards are perfect, spells to not always work
|
---|
171 | correctly. At best, nothing happens when the wrong spell is uttered. At
|
---|
172 | worst, the dragon becomes a much larger dragon or multiplies into several
|
---|
173 | smaller ones. In either case, new spells must be found.
|
---|
174 |
|
---|
175 | If all existing dragons are quiet (i.e. have eaten sufficiently), wizards
|
---|
176 | have time to do other things. They hide in castles and practice spells and
|
---|
177 | incatations. They also devise shortcuts for travelers and new laws of
|
---|
178 | transformation.
|
---|
179 |
|
---|
180 | Changes in the Kingdom
|
---|
181 | ======================
|
---|
182 |
|
---|
183 | As new transformation kingdoms are created and old ones are maintained,
|
---|
184 | CTK, Inc. is constantly learning new things. It learns ways to avoid
|
---|
185 | creating some of the dragons that they have previously created. It also
|
---|
186 | discovers new and better laws of transformation. As a result, CTK will
|
---|
187 | periodically create a new grand design which is far better than the old.
|
---|
188 | The wizards determine when is a good time to implement this new design.
|
---|
189 | This is when the tourist season is slow or when no important travelers
|
---|
190 | (VIPs) are to arrive. The kingdom must be closed for the actual
|
---|
191 | implementation and is leter reopened as a new and better place to go.
|
---|
192 |
|
---|
193 | A final question you might ask is what happens when the number of tourists
|
---|
194 | becomes too great for the kingdom to handle in a reasonable period of time
|
---|
195 | (i.e., the tourist lines at the ports are too long). The Kingdom of
|
---|
196 | Transformation has three options: (1) shorten the paths that a tourist must
|
---|
197 | travel, or (2) convince CTK to develop a faster breed of horses so that the
|
---|
198 | travelers can finish sooner, or (3) annex more territories so that the
|
---|
199 | kingdom can handle more travelers.
|
---|
200 |
|
---|
201 | Thus ends the story of the Kingdom of Transformation. I hope this has
|
---|
202 | explained my job to you: I slay dragons for a living.
|
---|
203 |
|
---|
204 | #
|
---|
205 | #should do an automatic undivert..
|
---|
206 | #
|
---|