source: trunk/minix/commands/m4/Test.m4@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

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