git @ Cat's Eye Technologies N-DCNC / d3a6229
Initial import of 'N-DCNC version 1.0 revision 2000.0808 sources. Cat's Eye Technologies 10 years ago
12 changed file(s) with 662 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 'N-DCNC
1 -------
2 The Official Language of Pride and Envy
3 ---------------------------------------
4
5 Last updated Aug 8 2000 Chris Pressey, Cat's Eye Technologies
6 http://www.catseye.mb.ca/
7
8 What is 'N-DCNC?
9 ----------------
10
11 Besides just tasting good when served with crackers and white wine,
12 'N-DCNC is a computer programming language as well.
13
14 'N-DCNC provides the programmer with sophisticated features such
15 as subtraction, bodaceous syntax elements such as infix operators,
16 powerful abstractions such as single-character variable names, and
17 groundbreakingly radical concepts such as side-effects.
18
19 Warning and History
20 -------------------
21
22 'N-DCNC was reverse-engineered from spaceflight control systems
23 found aboard crashed extraterrestrial vehicles. It was related
24 first-hand to yours truly by a shifty figure in a trenchcoat
25 known to me only as "Deep Copy". Over coffee and doughnuts at a
26 local Tim Horton's, he described in hushed tones the following
27 language, claiming that he was part of the engineering team that
28 was subcontracted for the purpose of deciphering it.
29
30 As such, if you choose to use the 'N-DCNC language, I cannot be
31 not held responsible should various shadowy agents force themselves
32 into your home and erase all your computer files, OK? Good.
33
34 There is also a strong, but hitherto unrealized connection between
35 this language and manufactured glam pop bands. For example,
36 'N-DCNC does not write it's own music nor play it's own instruments.
37 It has been known to lip-synch to a pre-recorded soundtrack.
38
39 The Structure of an 'N-DCNC Program
40 -----------------------------------
41
42 An 'N-DCNC program consists of one big expression. Save those
43 semicolons; you won't need them here!
44
45 An expression contains many primitive terms connected by infix
46 operators. There are as many levels of precedence as there are
47 operators, one on each level. The precedence of an operator
48 depends on it's position in the ASCII table; lower ASCII values
49 means lower precedence (isn't that *much* easier to remember?)
50
51 The infix operators are (from lowest to highest precedence:)
52
53 * Wally likes cats & bunnies multiply/loop
54 + Bill shy but deep add
55 , Chaz enjoys parties input/output
56 - Jon a real heartbreaker subtract
57 . Petrov provably happy assignment
58 / DIV enjoys decision-making int-divide/if
59
60 A sub-expression enclosed in parentheses like so (1+2) has
61 a higher precedence than the entire expression it occurs in
62 (as foreign and unnatural as this may seem, it's true...)
63
64 Terms are pretty boring, but let's examine them anyway.
65 The symbols
66
67 A 2 3 4 5 6 7 8 9 J Q K
68
69 represent the integers from one to twelve. The symbol A
70 represents thirteen instead of one when aces are high.
71 Aces are only high in certain restricted situations, such
72 as when the compiler mistakenly assumes they are high.
73 To represent zero, you, the programmer, must use 7-7 or
74 anything of a similar nature.
75
76 Imperative Programming Becomes Possible
77 ---------------------------------------
78
79 Lower-case letters represent variables. Well, kind of.
80 In fact, the variables aren't often too happy with the
81 respresentation they get from their elected lower-case
82 letters, and see them as trough-feeding, self-serving,
83 two-faced, and devoid of moral fibre.
84
85 You can assign to a variable with something like Z.Q
86 To increment or decrement a variable try Z.(z+A) or Z.(z-A)
87
88 It turns out Deep Copy gave me the wrong impression,
89 here; I thought he meant that lower-case letters were
90 rvalue-type variables and upper-case letters were their
91 lvalue-type equivalents. As it turns out, this is only
92 one possible interpretation. The notation that seems
93 to actually have been used is closer to `z for an lvalue.
94
95 Try to avoid letters from the start of the alphabet
96 (a,b,c,d,e,f...) because they're 'taboo': likely used
97 for other internal purposes (as sad as that is.)
98
99 Not much need to explain addition and subtraction,
100 except perhaps to those who do not already grok such
101 concepts; if you are a member of this set, seriously
102 consider a course on remedial arithmetic.
103
104 But the other operators need some explanation, because
105 they tend to stray from the laws of computer programming,
106 if not the laws of physics themselves. Well, no, OK,
107 just the first one, and yes, I know, there are no "laws"
108 when it comes to computer programming, but, so, well,
109 er, ...
110
111 Anyway, multiplication is defined thus, in some fictional
112 pseudocode language (which is not included with 'N-DCNC):
113
114 mul(by-value int a, by-name int b) =
115 {
116 c = 0;
117 while a > 0
118 {
119 c = c + do(b); a--;
120 }
121 c;
122 }
123
124 Or, to say it in PortableFalse:
125 [b:a:0c:[a;0>][c;b;!+c:a;1-a:]#c;]e:
126
127 Note that b is an expression instead of a simple value.
128 Unlike other values it is passed as a 'thunk' - a parameterless
129 function. Multiplication does not automatically evaluate the
130 thunk that is b; a has to be greater than zero at some point.
131
132 This is why we have normal-order evaluation instead of
133 eager evaluation - so that multiplication can cause side
134 effects that are our loops that let us do all that neat
135 solving-any-problem stuff, availability of half-infinite
136 lengths of tape notwithstanding.
137
138 So if we say
139 K*(7,A-A)
140 What we will get on the standard output is 12 BELs.
141 (But how do we know whether it is noon or midnight?
142 Look at the sky - if there's a big ball of fire up there,
143 it's noon.)
144
145 By changing the a variable in the loop (it's a global
146 variable after all,) you can theoretically cause the loop
147 to never terminate, or terminate based on some magical
148 condition. (That is, iff magical conditions are locally
149 defined to be synonymous with logical conditions for the
150 purposes of the previous sentence.)
151
152 Division has a similar relationship with the simple
153 and super-common 'if' statement. In a division by zero,
154 the numerator's thunk isn't evaluated. But in division
155 by one or anything else, it is.
156
157 Again with the fictional pseudocode (sold seperately,
158 may not be exactly as illustrated):
159
160 div(by-name int a, by-value int b) =
161 {
162 if (b = 0)
163 {
164 0;
165 }
166 do(a) / b;
167 }
168
169 In PortableFalse:
170 [\b:a:b;[a;!b;/]?b;~[0]?]d:
171
172
173 Summary and Closing Arguments
174 -----------------------------
175
176 One day all computer programmers will be replaced by robots,
177 and they'll all code in 'N-DCNC. But this will only be possible
178 on new, extremely large (and noisy) machines using a strange new
179 technology called 'relays'. These new 'super-'computers will be
180 so large and expensive that only the five richest software
181 companies will be able to afford to automate their programming
182 department. The rest will probably continue to use the present-
183 day software engineering model, that is, obtaining galleys full
184 of slaves, releasing the code they come up with to the customer
185 as a finished product, then "supporting it into existance" as
186 the customer whines and bitches about how their system doesn't
187 work the way they or any sane person would expect it to.
188
189 Appendix 7: EBNF Grammar for 'N-DCNC
190 ------------------------------------
191
192 'N-DCNC := E(0).
193 E(n) := E(n+1) {O(n) E(n+1)}.
194 Prim := "(" E(0) ")" | Digit | ["`"] Var.
195 Digit := one of "A23456789JQK".
196 Var := one of "abcdefghijklmnopqrstuvwxyz".
197
198 O = ('*', '+', ',', '-', '.', '/').
199 E(6) = Prim.
200
201 Appendix 22: About the 'N-DCNC Compilers
202 ----------------------------------------
203
204 Both 'N-DCNC compilers compile 100% pure 'N-DCNC code to Wouter
205 van Oortmerssen's False language (actually, his PortableFalse
206 variant.)
207
208 "100% pure" means that the input code contains no syntax errors,
209 because neither compiler goes out of it's way to bother with such
210 irrelevant trivia. Dammit Jim, they're compilers, not proofreaders.
211
212 False and PortableFalse are trademarks of $#%!
213
214 'N-DCNC is not a trademark of anything; in fact, I'm pretty sure
215 'N-DCNC and its compilers are a mere hallucination. Hmm...
216
217 DISCLAIMER: 'N-DCNC and its compilers are a mere hallucination.
218 Therefore I cannot be held responsible for anything they may
219 or may not do or appear to do.
220
221 Aggregation of false.c into this package as an easement for
222 playing with 'N-DCNC will probably be construed by Wouter as a
223 hostile intellectual-property manouevre to subvert his FALSE
224 dynasty. He'll be siccing his army of lawyers on me in a matter
225 of hours I'm sure. So enjoy 'N-DCNC while it remains legally
226 feasible to do so.
227
228 * 'n-dcnc.pl
229
230 Written in only slightly obfuscated Perl, this compiler (mostly)
231 works.
232
233 * 'n-dcnc.bf
234
235 [This doesn't exist yet. I've tried four times and decided I had
236 better take a long break (like, at least a week or two) before
237 trying again. I've come to realize that, despite having invented
238 the language, I'm a terrible Befunge programmer. My mistake here
239 is probably trying to squash it too much. Still, I wanted to get
240 SOMETHING out the door for the Essies, early, just in case.]
241
242 Appendix 22a: About the Compile Cycle
243 -------------------------------------
244
245 Mainly about 'n-dcnc.bf [which doesn't exist yet, but see the last
246 three attempts,] but mostly applies to 'n-dcnc.pl as well.
247
248 We store a stack called the 'call stack' on the 0'th row of
249 space (0,0)-(79,0) or even further in Befunge-97 or Perl.
250
251 The pointer to the top of this stack is stored at (0, 1).
252
253 We store the last token read at (1, 1). So the program looks like:
254
255 cccccccccccccccc....
256 tkabcodecodecode....
257 >
258
259 where the program itself begins at >. The first c contains a v,
260 and t contains a space, both of which will be overwritten by the
261 startup code. We'll use (2, 1), (3, 1) for other scratch variables
262 if the need arises.
263
264 (4, 1) and on are 4-cell chunks of output boilerplate in
265 PortableFalse used by the gencode routine, a reference to which
266 is made below.
267
268 Speaking of which, the startup code @ (0, 2) consists of:
269
270 - writing a 0 into t
271 - dumping the PortableFalse runtime library for 'N-DCNC to stdout
272 - pushing an 0 (OUT) onto the call stack
273 - scanning the first token into k
274
275 There is then a main parse loop @ (0, 5), which consists of:
276
277 - Is the TOS > 5, that is, have we recursed down through all the
278 available infix operators, and should we look for terms now?
279
280 - If so, we check k for an open paren. If found it indicates there
281 is a sub-expression. We scan a new symbol into k, push 1 (NEST)
282 onto the call stack, push a zero onto the stack, and go back to
283 the start of the main parse loop.
284
285 - If there's no open paren, we check for 2-9 or J or Q or K or A and
286 if so, generate a constant. Or, we check for a-z and generate a
287 variable access. In both cases we simply scan for new tokens
288 and fall through to the 'common tail', described below.
289
290 - On the other hand, what if the TOS is <= 5? Well, we push 2
291 (LHS) onto the call stack. We also duplicate the TOS, increment
292 it, and jump back to the beginning of the main parse loop.
293
294 We also have a 'common tail' @ (??, ??), which consists of
295 some code and then an 'on goto' type branch:
296
297 - discard the top stack element
298 - pop the call stack into a temporary variable and
299 jump based on it's value, which may be OUT, NEST, LHS, or RHS:
300
301 0 OUT: jump to the end of the translation logic; print the
302 PortableFalse postlude (currently just a '%') and exit.
303
304 1 NEST: scan a token and fall through to the common tail (again.)
305
306 2 LHS: if the current token is not equal to the value on the
307 top of the stack plus '*', fall through to the common tail.
308
309 If it is, print a '[' if the TOS is 0 or 5 (to lazy-ize
310 the parameters), scan another token, push 3 (RHS) onto
311 the call stack, increment the top of the stack and go
312 back to the start of the main parse loop.
313
314 3 RHS: based on the top of the stack, print out a snippet of
315 PortableFalse code based on the current operator, then
316 fall through to LHS.
317
318 And that's basically it. Easy, really. That's what a recursive
319 descent parser looks like when you don't use recursion, or well,
320 you don't use any built-in call/return/function mechanism at all
321 because there essentially isn't any...
322
323 Appendix 22q. Befunge Idioms
324 ----------------------------
325
326 ~11p is scan a token
327 11g is get current token
328
329 01g is get the call stack ptr (an x coordinate)
330 ?01p is set the call stack ptr
331 01g1+01p is increment the call stack ptr
332 01g1-01p is decrement the call stack ptr
333 01g0g is get the value on the top of the call stack
334 ?01g0p is set the value on the top of the call stack
335
336 01g1-:01p0g is pop the call stack
337 ?01g0p01g1+01p is push onto call stack
338
339 Appendix 3. Excerpts from the Author's 'N-DCNC Diary
340 ----------------------------------------------------
341
342 May 12 2000. Met a man who told me to call him "Deep Copy." Not
343 really a pleasant guy. But he seems interested in language design.
344
345 June 7 2000. Deep Copy told me about a language he has access to
346 the specifications for. Claims it was reverse-engineered from
347 spaceflight control systems found aboard crashed flying saucers.
348 He told me not to write anything he talked about down, but he knew
349 full well who I was and what I do so I assumed he had to be lying.
350 Or stupid. If he didn't want me to write it down, he shouldn't
351 have told me.
352
353 July 26 2000. Got a rough version of 'N-DCNC working and decided
354 it would really piss Deep Copy off if I submitted it for an
355 Esoteric Award...
356
357 August 8 2000. Got a phone call from Deep Copy today. Somehow he
358 had found out about 'N-DCNC being an Essy entry. Also faxed over
359 some corrections along with a note about how my life could be in
360 jeopardy if I continued to pursue my interests in these
361 "Un-Canadian Activities". (???)
362
363 Glossary of Terms
364 -----------------
365
366 - Dom-ain't: a corporation with a name like MyTurn.com but
367 with a doman name like myturninc.com.
368
369 - Draffle: the little personal items (Dilbert cartoons,
370 fuzzy things with googly-eyes, etc) put in one's office or
371 workspace in a vain attempt to make it more familiar.
372
373 - Meta-barber: the person who cuts your barber's hair.
374
375 - Precipitation Limbo: where the rain goes when it's not
376 raining.
377
378 - Taunt Marquee: the route-identifying sign in the rear
379 window of the bus you just missed.
0 t.7+`t,A-A
0 J*((J+J+J+J+J+J+5),A-A)
0 4*5+2/2,(9*`c)+1
1
0 (J+J+J+J+J+J+5),A-A
0 ~00p001p"O"101gp01g1+01p0>:4`#v_"L"101gp01g1+01p:1+v
1 ^ < <
2 + >00g"("-#v_~00p"N"101gp01g1+01p0^
3 - v <
4 * >00g"?"-#v_~00p"&", 00g,~00pv
5 / v <
6 $ >00g, ~00pv
7 ^ <
8 > :2+0\g00g-#v_:4-#v_"{",v
9 > >~00p"R"101gp01g1+01p:1+ ^
10 > v
11 # :4-#v_"}",>:2+0\g, v>
12 > ^
13 ^ # <
14 v < <
15 >$01g1-01p101ggv
16 v <
17 >:"L"-#v_$ ^
18 v <
19 >:"R"-#v_$ ^
20 v <
21 >:"N"-#@_$ ~00p ^
0 v
1 **]e;!+ %,0 - f;! ]d;!
2 >001p0":e];c#[:a-1;a:c+!;b;c[]>0;a[:c"v
3 v"f:[\b:a:b;[a;!b;/]?b;~[0]?]d:[b:a:0"<
4 >"];c:\:c$[ ">:#,_01g0p01g1+01p~11pv
5 v <
6 >:5'#v_201g0p01g1+01p1+
7 ^ >11g"("-#v_~11p101g0p01g1+01p
8 v >,~11pv >11g"1"`#v_> >11g,
9 "a"11g`#v_v>11g,";",v>"9"11g`#^_
10 v # ># ^# p11~< >:1+4*:1v
11 >$01g1-:01p0g:#v_:1-#^_:2-#v_^v1+1:,g<
12 ^ # $<@, "%"<v --"*"g11:< >g,:2+1v
13 ^v^":",g11$< ># _v ^ ,g1+3:,g<
14 ^ >:#v_:5-#v_ >~11p 301g0p01g1+01p1+
15 ^ > >"[",^ >
0 v
1 **]e;!+ %,0 - f;! ]d;!
2 >001p0":e];c#[:a-1;a:c+!;b;c[]>0;a[:"v
3 v"[\b:a:b;[a;!b;/]?b;~[0]?]d:[b:a:0c"<
4 >":f];c:\:c$[D">:#,_01g0p01g1+01p~11pv
5 < +1p10+1g10p0g102_v#!`5:<
6 v_v# -"A"g11_v# -"(":<>$#<$^
7 >"1", v >~11p101g0p01g1+01p^
8 >11g"J"-!#v_11g"Q"-!#v_11g"K"-!#v_1$ v
9 v_v#`$<<v,g11_v#`g11 ":"_v#`"1" g11<
10 p11~<>"01" v"12"< >> ~11pv
11 < ^ g11"`"<>,, ^,,"31"< ^
12 > 11g" "-,":", ~11pv
13 >11g,";", ~11pv
14 <v1:*4+1:_v#-2:_v#-1:_v#:g0p10:-1g10$<
15 # v p11~<@,"%"<>
16 ^ <>:"*"+11g- #^_:#v_ v
17 > g,:1+1g,:2+1g,:3+1g,$ v >:5-#v_ v
18 ^ #+1:p10+1g10p0g103p11~<,"["<
19 ^ $<
0 v
1 **]e;!+ %,0 - f;! ]d;!
2 >001p0":e];c#[:a-1;a:c+!;b;c[]>0;a[:"v
3 v"[\b:a:b;[a;!b;/]?b;~[0]?]d:[b:a:0c"<
4 >":f];c:\:c$[D">:#,_01g0p01g1+01p~11pv
5 < +1:p10+1g10p0g102_v#!`5:<
6 0p10+1g10p0g101p11~_v#!-"("g11< ^
7 v <
8 >11g"1"`!#v_":"11g`!#v_11g," ",v
9 vp11~ < < >#< #< < v
10 v g11_v#-"K"g11_v#-"Q"g11_v#-"J"g11<
11 >"A"-#v _1, #v # #
12 >93+,^< >92+,^ >91+,^
13 >11g"`"`#v_11g" "-,":", ^
14 > 11g,";", ^
15 >$01g1-:01p0g:1-!#v_:! #v_:2-!#v_ gencode
16 ^ p11~<@,"%"<
17 lhs <
0 /* Introducing: Portable False!!!!
1
2 PortableFalse is different from AmigaFalse in:
3 - its Portable!!! :-)
4 - full stack checking
5 - strongly typed (no joke, really!)
6 - debug-modi
7 - real and meaningfull errormessages
8 - ` inline assembly not supported
9 - : and ; not supported for other than variable access.
10 - "beta" (flush) and "zero-slash" (pick) from the amiga charset
11 are now 'B' and 'O' resp.
12 - 'D' toggles stack-watch mode on and off. format:
13 [ bottom_of_stack , ... , top_of_stack | next_symbol ]
14 - "-q" on command line is quiet mode: no title printing.
15 (usefull for "filter"-type programs: 1> False -q filter.f <bla >burp)
16
17 this source has been writtin in good C style:
18 - no modularity whatsoever (only main())
19 - only global variables
20 - lots of ugly macros (replacing functions)
21 - great source formatting and indentation
22
23 still it compiles on 4-5 different ansi-C compilers. if you have trouble
24 porting it to your machine, your compiler sucks. (guaranteed to be
25 digested by: MaxonC++, SAS/C, DICE, GNUC++ (also on other platforms))
26
27 todo:
28 - interactive debugging?
29
30 False, Amiga False, Portable False are all trademarks of $#%!
31
32 */
33
34 #define MZ 10000
35 #define MS 1000
36 #include <stdio.h>
37 #define NIL 0
38 #define NUM 0
39 #define FUNC 1
40 #define VADR 2
41 #define UNDEF 3
42 #define l(x) ;break;case x:
43 #define x(num) {ernum=num;goto er;}
44 #define push(v,a) {if(S-2<sbeg)x(4)else{*--S=(v);*--S=(X)a;};}
45 #define pop(v,a) {if(S+2>se)x(5)else{if((ex=(int)a)!=(ge=(int)*S++))x(6);\
46 v= *S++;};}
47 #define pa(v,av) {if(S+2>se)x(5)else{av= *S++;v= *S++;};}
48 #define ru(v) {if(rp-1<rbeg)x(13)else{*--rp=(v);};}
49 #define ro(v) {if(rp+1>rend)x(14)else{v= *rp++;};}
50 #define CA(c) {ru(p);p=c;}
51 #define pu(x) push(x,NUM)
52 #define po(x) pop(x,NUM)
53 #define op(o) {po(b)po(d);pu((X)((int)d o (int)b));}
54 #define cm(o) {po(b)po(d);pu((X)(-((int)d o (int)b)));}
55 #define un(o) {po(b)pu((X)(o (int)b));}
56 #define ne (p<end)
57 #define W while
58 #define ec {W((*p!='}')&&ne)p++;p++;if(!ne)x(10);}
59 #define P printf
60 typedef char*X;typedef char**XP;X ST[MS],RST[MS],var[52],b,d,e,f,t1,t2,t3;
61 XP sbeg=ST+12,se=ST+MS-12,S,ts,rbeg=RST+12,rend=RST+MS-12,rp,vp;int ernum=
62 0,t,db=0,ex,ge,qq;FILE*fh;char src[MZ+5],a,c=0,*s,*end,*beg,*p=0,*erstr[]=
63 {"no args","could not open source file","source too large","data stack ov"
64 "erflow","data stack underflow","type conflict","stack not empty at exit "
65 "of program","unknown symbol","portable inline assembly not available","u"
66 "nbalanced '{'","unbalanced '\"'","unbalanced '['","return stack overflow"
67 ,"return stack underflow"},*types[]={"Integer","Functional","Variabele",""
68 "Unitialised"};int main(int narg,char*args[]){S=se;rp=rend;t=1;for(vp=var;
69 vp<(var+52);){*vp++=(X)UNDEF;};if(narg>1)if(args[1][0]=='-'&&args[1][1]==
70 'q')t=2;if(t==1)P("Portable False Interpreter/Debugger v0.1 (c) 1993 $#%!"
71 "\n");if(narg<t+1)x(1);if((fh=fopen(args[t],"r"))==NIL)x(2);s=src;*s++=
72 '\n';W((a=fgetc(fh))!=EOF)if((src+MZ)<=s){fclose(fh);x(3)}else{*s++=a;};*s
73 ++='\n';fclose(fh);end=s-1;beg=src+1;p=beg;W(ne){c= *p++;if(c>='0'&&c<='9'
74 ){int num;sscanf(p-1,"%d",&num);W((*p>='0')&&(*p<='9'))p++;push((X)num,NUM
75 );}else if(c>='a'&&c<='z'){push((X)&var[(c-'a')*2],VADR);}else switch(c){
76 case' ':case '\n':case'\t':l('+')op(+)l('-')op(-)l('*')op(*)l('/')op(/)l(
77 '&')op(&)l('|')op(|)l('_')un(-)l('~')un(~)l('=')cm(==)l('>')cm(>)l('%')pa(
78 b,e)l('$')pa(b,e)push(b,e)push(b,e)l('\\')pa(b,e)pa(d,f)push(b,e)push(d,f)
79 l('@')pa(b,t1)pa(d,t2)pa(e,t3)push(d,t2)push(b,t1)push(e,t3)l('O')po(b)if(
80 S+((t=(int)b*2)+2)>se)x(5)b= *(S+t);d= *(S+t+1);push(d,b)l(':')pop(b,VADR)
81 pa(d,e)*((XP)b)=d;*(((XP)b)+1)=e;l(';')pop(b,VADR)push(*((XP)b),*(((XP)b)+
82 1));l('.')po(b)P("%d",(int)b);l(',')po(b)P("%c",(char)b);l('^')pu((X)fgetc
83 (stdin));l('B')fflush(stdout);fflush(stdin);l('\"')W((*p!='\"')&&ne){fputc
84 (*p,stdout);p++;};p++;if(!ne)x(11);l('{')ec;l('\'')pu((X)*p++);l('`')x(9);
85 l('D')db=!db;l('[')push((X)p,FUNC)t=1;W(t>0&&ne){a= *p++;if(a=='['){t++;}
86 else if(a==']'){t--;}else if(a=='{'){ec}else if(a=='\"'){W((*p!='\"')&&ne)
87 p++;p++;if(!ne)x(11);};};if(!ne)x(12);l(']')ro(e)if((int)e==0){ro(p)po(b)
88 if((int)b){ro(d)ru(d)CA(d)ru((X)1);}else{ro(d)ro(d);};}else if((int)e==1){
89 ro(p)ro(b)ro(d)ru(d)ru(b)CA(d)ru((X)0);}else{p=e;};l('!')pop(b,FUNC)CA(b);
90 l('?')pop(b,FUNC)po(d)if((int)d){CA(b);};l('#')pop(b,FUNC)pop(d,FUNC)ru(d)
91 ru(b);CA(d)ru((X)0);break;default:x(8);};if(db){c= *p;if(c!=' '&&c!='\n'&&
92 c!='\t'&&c!='{'&&c!='\"'){ts=S+20;if(ts>se)ts=se;P("[");W(ts>S){t=(int)*(
93 ts-2);if(t==FUNC){P("<func>");}else if(t==VADR){P("<var>");}else P("%d",(
94 int)*(ts-1));ts-=2;if(ts>S)P(",");};P("|'%c']\n",*p);}};};c=0;p=0;if(S!=se
95 )x(7);er:if(ernum){P("\nERROR: %s!\n",erstr[ernum-1]);if(c)P("WORD: '%c'"
96 "\n",c);if(ernum==6)P("INFO: Expecting %s type, while reading %s type.\n"
97 ,types[ex],types[ge]);if(p){end=p;beg=p;W(*(beg-1)!='\n'){beg--;};W(*end!=
98 '\n'){end++;};t=end-beg;*end=0;if(t>0){P("LINE: %s\n",beg);qq=p-beg+3;P(
99 "AT:");for(t=0;t<qq;t++){putchar(' ');};P("^\n");};};}return 0;}
0 v
1 **]e;!+ %,0 - f;! ]d;!
2 >001p0":e];c#[:a-1;a:c+!;b;c[]>0;a[:"v
3 v"[\b:a:b;[a;!b;/]?b;~[0]?]d:[b:a:0c"<
4 >":f];c:\:c$[D">:#,_01g0p01g1+01p~11pv
5 >:5`#v_:1+201g0p01g1+01p >
6 >"@"11g-#v_~11p101g0p01g1+01p0 ^
7
8 todo!
0 #!/usr/local/bin/perl -w
1
2 # 'n-dcnc.pl - a 'N-DCNC to PortableFalse compiler in Perl
3 # v2000.08.12 Chris Pressey, Cat's Eye Technologies
4 # http://www.catseye.mb.ca/
5
6 $token = '';
7 sub scan
8 {
9 exit(0) if not read(STDIN, $token, 1);
10 }
11
12 sub top
13 {
14 return $_[$#_];
15 }
16
17 # print 'D';
18 print '[\b:a:b;[a;!b;/]?b;~[0]?]d:';
19 print "\n";
20 print '[b:a:0c:[a;0>][c;b;!+c:a;1-a:]#c;]e:';
21 print "\n";
22
23 scan();
24 push @back, 'Out';
25 push @stack, 0;
26
27 e:
28 if (top(@stack) > 5)
29 {
30 if ($token eq '@')
31 {
32 scan();
33 push @back, 'Nest';
34 push @stack, 0;
35 goto e;
36 Nest:
37 scan();
38 }
39 elsif ($token =~ /^[AJQK23456789]$/)
40 {
41 $token = 1 if $token eq 'A';
42 $token = 10 if $token eq 'J';
43 $token = 11 if $token eq 'Q';
44 $token = 12 if $token eq 'K';
45 print "$token ";
46 scan();
47 }
48 elsif ($token eq '`')
49 {
50 scan();
51 print "$token;";
52 scan();
53 }
54 else
55 {
56 print $token;
57 scan();
58 }
59 } else
60 {
61 push @back, 'LHS';
62 push @stack, top(@stack)+1;
63 goto e;
64 LHS:
65 if($token eq chr(top(@stack)+ord('*')))
66 {
67 if(top(@stack) == 0) { print '['; }
68 if(top(@stack) == 5) { print '['; }
69 scan();
70 push @back, 'RHS';
71 push @stack, top(@stack)+1;
72 goto e;
73 RHS:
74 print ']e;!' if top(@stack) == 0;
75 print '+' if top(@stack) == 1;
76 print '%,0' if top(@stack) == 2;
77 print '-' if top(@stack) == 3;
78 print '$c:\:c;' if top(@stack) == 4;
79 print ']d;!' if top(@stack) == 5;
80 goto LHS;
81 }
82 }
83 pop @stack;
84 my $b = pop @back;
85 goto LHS if $b eq 'LHS';
86 goto RHS if $b eq 'RHS';
87 goto Nest if $b eq 'Nest';
88
89 Out:
90 print '%';
91 exit(0);