summaryrefslogtreecommitdiff
path: root/src/iconc/ctree.c
blob: 170a63141f1e812c18e01416d037be3cd0e010b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
/*
 * ctree.c -- functions for constructing parse trees.
 */
#include "../h/gsupport.h"
#include "../h/lexdef.h"
#include "ctrans.h"
#include "ctree.h"
#include "csym.h"
#include "ctoken.h"
#include "ccode.h"
#include "cproto.h"

/*
 * prototypes for static functions.
 */
static nodeptr chk_empty (nodeptr n);
static void put_elms  (nodeptr t, nodeptr args, int slot);
static nodeptr subsc_nd  (nodeptr op, nodeptr arg1, nodeptr arg2);

/*
 *  tree[1-6] construct parse tree nodes with specified values.
 *   loc_model is a node containing the same line and column information
 *   as is needed in this node, while parameters a through d are values to
 *   be assigned to n_field[0-3]. Note that this could be done with a
 *   single routine; a separate routine for each node size is used for
 *   speed and simplicity.
 */

nodeptr tree1(type)
int type;
   {
   register nodeptr t;

   t = NewNode(0);
   t->n_type = type;
   t->n_file = NULL;
   t->n_line = 0;
   t->n_col = 0;
   t->freetmp = NULL;
   return t;
   }

nodeptr tree2(type, loc_model)
int type;
nodeptr loc_model;
   {
   register nodeptr t;

   t = NewNode(0);
   t->n_type = type;
   t->n_file = loc_model->n_file;
   t->n_line = loc_model->n_line;
   t->n_col = loc_model->n_col;
   t->freetmp = NULL;
   return t;
   }

nodeptr tree3(type, loc_model, a)
int type;
nodeptr loc_model;
nodeptr a;
   {
   register nodeptr t;

   t = NewNode(1);
   t->n_type = type;
   t->n_file = loc_model->n_file;
   t->n_line = loc_model->n_line;
   t->n_col = loc_model->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_ptr = a;
   return t;
   }

nodeptr tree4(type, loc_model, a, b)
int type;
nodeptr loc_model;
nodeptr a, b;
   {
   register nodeptr t;

   t = NewNode(2);
   t->n_type = type;
   t->n_file = loc_model->n_file;
   t->n_line = loc_model->n_line;
   t->n_col = loc_model->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_ptr = a;
   t->n_field[1].n_ptr = b;
   return t;
   }

nodeptr tree5(type, loc_model, a, b, c)
int type;
nodeptr loc_model;
nodeptr a, b, c;
   {
   register nodeptr t;

   t = NewNode(3);
   t->n_type = type;
   t->n_file = loc_model->n_file;
   t->n_line = loc_model->n_line;
   t->n_col = loc_model->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_ptr = a;
   t->n_field[1].n_ptr = b;
   t->n_field[2].n_ptr = c;
   return t;
   }

nodeptr tree6(type, loc_model, a, b, c, d)
int type;
nodeptr loc_model;
nodeptr a, b, c, d;
   {
   register nodeptr t;

   t = NewNode(4);
   t->n_type = type;
   t->n_file = loc_model->n_file;
   t->n_line = loc_model->n_line;
   t->n_col = loc_model->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_ptr = a;
   t->n_field[1].n_ptr = b;
   t->n_field[2].n_ptr = c;
   t->n_field[3].n_ptr = d;
   return t;
   }

nodeptr int_leaf(type, loc_model, a)
int type;
nodeptr loc_model;
int a;
   {
   register nodeptr t;

   t = NewNode(1);
   t->n_type = type;
   t->n_file = loc_model->n_file;
   t->n_line = loc_model->n_line;
   t->n_col = loc_model->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_val = a;
   return t;
   }

nodeptr c_str_leaf(type, loc_model, a)
int type;
nodeptr loc_model;
char *a;
   {
   register nodeptr t;

   t = NewNode(1);
   t->n_type = type;
   t->n_file = loc_model->n_file;
   t->n_line = loc_model->n_line;
   t->n_col = loc_model->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_str = a;
   return t;
   }

/*
 * i_str_leaf - create a leaf node containing a string and length.
 */
nodeptr i_str_leaf(type, loc_model, a, b)
int type;
nodeptr loc_model;
char *a;
int b;
   {
   register nodeptr t;

   t = NewNode(2);
   t->n_type = type;
   t->n_file = loc_model->n_file;
   t->n_line = loc_model->n_line;
   t->n_col = loc_model->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_str = a;
   t->n_field[1].n_val = b;
   return t;
   }

/*
 * key_leaf - create a leaf node for a keyword.
 */
nodeptr key_leaf(loc_model, keyname)
nodeptr loc_model;
char *keyname;
   {
   register nodeptr t;
   struct implement *ip;
   struct il_code *il;
   char *s;
   int typcd;

   /*
    * Find the data base entry for the keyword, if it exists.
    */
   ip = db_ilkup(keyname, khash);

   if (ip == NULL)
      tfatal("invalid keyword", keyname);
   else if (ip->in_line == NULL)
      tfatal("keyword not installed", keyname);
   else {
      il = ip->in_line;
      s = il->u[1].s;
      if (il->il_type == IL_Const) {
        /*
         * This is a constant keyword, treat it as a literal.
         */
        t = NewNode(1);
        t->n_file = loc_model->n_file;
        t->n_line = loc_model->n_line;
        t->n_col = loc_model->n_col;
        t->freetmp = NULL;
        typcd = il->u[0].n;
        if (typcd == cset_typ) {
           t->n_type =  N_Cset;
           CSym0(t) = putlit(&s[1], F_CsetLit, strlen(s) - 2);
           }
        else if (typcd == int_typ) {
           t->n_type = N_Int;
           CSym0(t) = putlit(s, F_IntLit, 0);
           }
        else if (typcd == real_typ) {
           t->n_type = N_Real;
           CSym0(t) = putlit(s, F_RealLit, 0);
           }
        else if (typcd == str_typ) {
           t->n_type = N_Str;
           CSym0(t) = putlit(&s[1], F_StrLit, strlen(s) - 2);
           }
        return t;
        }
     }

   t = NewNode(2);
   t->n_type = N_InvOp;
   t->n_file = loc_model->n_file;
   t->n_line = loc_model->n_line;
   t->n_col = loc_model->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_val = 0;      /* number of arguments */
   t->n_field[1].ip = ip;
   return t;
   }

/*
 * list_nd - create a list creation node.
 */
nodeptr list_nd(loc_model, args)
nodeptr loc_model;
nodeptr args;
   {
   register nodeptr t;
   struct implement *impl;
   int nargs;

   /*
    * Determine the number of arguments.
    */
   if (args->n_type == N_Empty)
      nargs = 0;
   else {
      nargs = 1;
      for (t = args; t->n_type == N_Elist; t = t->n_field[0].n_ptr)
         ++nargs;
      if (nargs > max_prm)
         max_prm = nargs;
      }

   impl = spec_op[ListOp];
   if (impl == NULL)
      nfatal(loc_model, "list creation not implemented", NULL);
   else if (impl->in_line == NULL)
      nfatal(loc_model, "list creation not installed", NULL);

   t = NewNode(nargs + 2);
   t->n_type = N_InvOp;
   t->n_file = loc_model->n_file;
   t->n_line = loc_model->n_line;
   t->n_col = loc_model->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_val = nargs;
   t->n_field[1].ip = impl;
   if (nargs > 0)
      put_elms(t, args, nargs + 1);
   return t;
   }

/*
 * invk_nd - create a node for invocation.
 */
nodeptr invk_nd(loc_model, proc, args)
nodeptr loc_model;
nodeptr proc;
nodeptr args;
   {
   register nodeptr t;
   int nargs;

   /*
    * Determine the number of arguments.
    */
   if (args->n_type == N_Empty)
      nargs = 0;
   else {
      nargs = 1;
      for (t = args; t->n_type == N_Elist; t = t->n_field[0].n_ptr)
         ++nargs;
      if (nargs > max_prm)
         max_prm = nargs;
      }

   t = NewNode(nargs + 2);
   t->n_type = N_Invok;
   t->n_file = loc_model->n_file;
   t->n_line = loc_model->n_line;
   t->n_col = loc_model->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_val = nargs;
   t->n_field[1].n_ptr = proc;
   if (nargs > 0)
      put_elms(t, args, nargs + 1);
   return t;
   }

/*
 * put_elms - convert a linked list of arguments into an array of arguments
 *  in a node.
 */
static void put_elms(t, args, slot)
nodeptr t;
nodeptr args;
int slot;
   {
   if (args->n_type == N_Elist) {
      /*
       * The linked list is in reverse argument order.
       */
      t->n_field[slot].n_ptr = chk_empty(args->n_field[1].n_ptr);
      put_elms(t, args->n_field[0].n_ptr, slot - 1);
      free(args);
      }
   else
      t->n_field[slot].n_ptr = chk_empty(args);
   }

/*
 * chk_empty - if an argument is empty, replace it with &null.
 */
static nodeptr chk_empty(n)
nodeptr n;
   {
   if (n->n_type == N_Empty)
      n = key_leaf(n, spec_str("null"));
   return n;
   }

/*
 * case_nd - create a node for a case statement.
 */
nodeptr case_nd(loc_model, expr, cases)
nodeptr loc_model;
nodeptr expr;
nodeptr cases;
   {
   register nodeptr t;
   nodeptr reverse;
   nodeptr nxt_cases;
   nodeptr ccls;

   t = NewNode(3);
   t->n_type = N_Case;
   t->n_file = loc_model->n_file;
   t->n_line = loc_model->n_line;
   t->n_col = loc_model->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_ptr = expr;
   t->n_field[2].n_ptr = NULL;

   /*
    * The list of cases is in reverse order. Walk the list reversing it,
    *  and extract the default clause if one exists.
    */
   reverse = NULL;
   while (cases->n_type != N_Ccls) {
      nxt_cases = cases->n_field[0].n_ptr;
      ccls = cases->n_field[1].n_ptr;
      if (ccls->n_field[0].n_ptr->n_type == N_Res) {
         /*
          * default clause.
          */
         if (t->n_field[2].n_ptr == NULL)
            t->n_field[2].n_ptr = ccls->n_field[1].n_ptr;
         else
            nfatal(ccls, "duplicate default clause", NULL);
         }
       else {
          if (reverse == NULL) {
             reverse = cases;
             reverse->n_field[0].n_ptr = ccls;
             }
          else {
             reverse->n_field[1].n_ptr = ccls;
             cases->n_field[0].n_ptr = reverse;
             reverse = cases;
             }
         }
      cases = nxt_cases;
      }

   /*
    * Last element in list.
    */
   if (cases->n_field[0].n_ptr->n_type == N_Res) {
      /*
       * default clause.
       */
      if (t->n_field[2].n_ptr == NULL)
         t->n_field[2].n_ptr = cases->n_field[1].n_ptr;
      else
         nfatal(ccls, "duplicate default clause", NULL);
      if (reverse != NULL)
         reverse = reverse->n_field[0].n_ptr;
      }
   else {
      if (reverse == NULL)
         reverse = cases;
      else
         reverse->n_field[1].n_ptr = cases;
      }
   t->n_field[1].n_ptr = reverse;
   return t;
   }

/*
 * multiunary - construct nodes to implement a sequence of unary operators
 *  that have been lexically analyzed as one operator.
 */
nodeptr multiunary(op, loc_model, oprnd)
nodeptr loc_model;
char *op;
nodeptr oprnd;
   {
   int n;
   nodeptr nd;

   if (*op == '\0')
     return oprnd;
   for (n = 0; optab[n].tok.t_word != NULL; ++n)
      if ((optab[n].expected & Unary) & (*(optab[n].tok.t_word) == *op)) {
         nd = OpNode(n);
         nd->n_file = loc_model->n_file;
         nd->n_line = loc_model->n_line;
         nd->n_col = loc_model->n_col;
         return unary_nd(nd,multiunary(++op,loc_model,oprnd));
         }
   fprintf(stderr, "compiler error: inconsistent parsing of unary operators");
   exit(EXIT_FAILURE);
   }

/*
 * binary_nd - construct a node for a binary operator.
 */
nodeptr binary_nd(op, arg1, arg2)
nodeptr op;
nodeptr arg1;
nodeptr arg2;
   {
   register nodeptr t;
   struct implement *impl;

   /*
    * Find the data base entry for the operator.
    */
   impl = optab[Val0(op)].binary;
   if (impl == NULL)
      nfatal(op, "binary operator not implemented", optab[Val0(op)].tok.t_word);
   else if (impl->in_line == NULL)
      nfatal(op, "binary operator not installed", optab[Val0(op)].tok.t_word);

   t = NewNode(4);
   t->n_type = N_InvOp;
   t->n_file = op->n_file;
   t->n_line = op->n_line;
   t->n_col = op->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_val = 2;      /* number of arguments */
   t->n_field[1].ip = impl;
   t->n_field[2].n_ptr = arg1;
   t->n_field[3].n_ptr = arg2;
   return t;
   }

/*
 * unary_nd - construct a node for a unary operator.
 */
nodeptr unary_nd(op, arg)
nodeptr op;
nodeptr arg;
   {
   register nodeptr t;
   struct implement *impl;

   /*
    * Find the data base entry for the operator.
    */
   impl = optab[Val0(op)].unary;
   if (impl == NULL)
      nfatal(op, "unary operator not implemented", optab[Val0(op)].tok.t_word);
   else if (impl->in_line == NULL)
      nfatal(op, "unary operator not installed", optab[Val0(op)].tok.t_word);

   t = NewNode(3);
   t->n_type = N_InvOp;
   t->n_file = op->n_file;
   t->n_line = op->n_line;
   t->n_col = op->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_val = 1;      /* number of arguments */
   t->n_field[1].ip = impl;
   t->n_field[2].n_ptr = arg;
   return t;
   }

/*
 * buildarray - convert "multi-dimensional" subscripting into a sequence
 *  of subsripting operations.
 */
nodeptr buildarray(a,lb,e)
nodeptr a, lb, e;
   {
   register nodeptr t, t2;
   if (e->n_type == N_Elist) {
      t2 = int_leaf(lb->n_type, lb, lb->n_field[0].n_val);
      t = subsc_nd(t2, buildarray(a,lb,e->n_field[0].n_ptr),
         e->n_field[1].n_ptr);
      free(e);
      }
   else
      t = subsc_nd(lb, a, e);
   return t;
   }

/*
 * subsc_nd - construct a node for subscripting.
 */
static nodeptr subsc_nd(op, arg1, arg2)
nodeptr op;
nodeptr arg1;
nodeptr arg2;
   {
   register nodeptr t;
   struct implement *impl;

   /*
    * Find the data base entry for subscripting.
    */
   impl = spec_op[SubscOp];
   if (impl == NULL)
      nfatal(op, "subscripting not implemented", NULL);
   else if (impl->in_line == NULL)
      nfatal(op, "subscripting not installed", NULL);

   t = NewNode(4);
   t->n_type = N_InvOp;
   t->n_file = op->n_file;
   t->n_line = op->n_line;
   t->n_col = op->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_val = 2;      /* number of arguments */
   t->n_field[1].ip = impl;
   t->n_field[2].n_ptr = arg1;
   t->n_field[3].n_ptr = arg2;
   return t;
   }

/*
 * to_nd - construct a node for binary to.
 */
nodeptr to_nd(op, arg1, arg2)
nodeptr op;
nodeptr arg1;
nodeptr arg2;
   {
   register nodeptr t;
   struct implement *impl;

   /*
    * Find the data base entry for to.
    */
   impl = spec_op[ToOp];
   if (impl == NULL)
      nfatal(op, "'i to j' not implemented", NULL);
   else if (impl->in_line == NULL)
      nfatal(op, "'i to j' not installed", NULL);

   t = NewNode(4);
   t->n_type = N_InvOp;
   t->n_file = op->n_file;
   t->n_line = op->n_line;
   t->n_col = op->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_val = 2;      /* number of arguments */
   t->n_field[1].ip = impl;
   t->n_field[2].n_ptr = arg1;
   t->n_field[3].n_ptr = arg2;
   return t;
   }

/*
 * toby_nd - construct a node for binary to-by.
 */
nodeptr toby_nd(op, arg1, arg2, arg3)
nodeptr op;
nodeptr arg1;
nodeptr arg2;
nodeptr arg3;
   {
   register nodeptr t;
   struct implement *impl;

   /*
    * Find the data base entry for to-by.
    */
   impl = spec_op[ToByOp];
   if (impl == NULL)
      nfatal(op, "'i to j by k' not implemented", NULL);
   else if (impl->in_line == NULL)
      nfatal(op, "'i to j by k' not installed", NULL);

   t = NewNode(5);
   t->n_type = N_InvOp;
   t->n_file = op->n_file;
   t->n_line = op->n_line;
   t->n_col = op->n_col;
   t->freetmp = NULL;
   t->n_field[0].n_val = 3;      /* number of arguments */
   t->n_field[1].ip = impl;
   t->n_field[2].n_ptr = arg1;
   t->n_field[3].n_ptr = arg2;
   t->n_field[4].n_ptr = arg3;
   return t;
   }

/*
 * aug_nd - create a node for an augmented assignment.
 */
nodeptr aug_nd(op, arg1, arg2)
nodeptr op;
nodeptr arg1;
nodeptr arg2;
   {
   register nodeptr t;
   struct implement *impl;

   t = NewNode(5);
   t->n_type = N_Augop;
   t->n_file = op->n_file;
   t->n_line = op->n_line;
   t->n_col = op->n_col;
   t->freetmp = NULL;

   /*
    * Find the data base entry for assignment.
    */
   impl = optab[asgn_loc].binary;
   if (impl == NULL)
      nfatal(op, "assignment not implemented", NULL);
   t->n_field[0].ip = impl;

   /*
    * The operator table entry for the augmented assignment is
    *  immediately after the entry for the operation.
    */
   impl = optab[Val0(op) - 1].binary;
   if (impl == NULL)
      nfatal(op, "binary operator not implemented",
         optab[Val0(op) - 1].tok.t_word);
   t->n_field[1].ip = impl;

   t->n_field[2].n_ptr = arg1;
   t->n_field[3].n_ptr = arg2;
   /* t->n_field[4].typ - type of intermediate result */
   return t;
   }

/*
 * sect_nd - create a node for sectioning.
 */
nodeptr sect_nd(op, arg1, arg2, arg3)
nodeptr op;
nodeptr arg1;
nodeptr arg2;
nodeptr arg3;
   {
   register nodeptr t;
   int tok;
   struct implement *impl;
   struct implement *impl1;

   t = NewNode(5);
   t->n_file = op->n_file;
   t->n_line = op->n_line;
   t->n_col = op->n_col;
   t->freetmp = NULL;

   /*
    * Find the data base entry for sectioning.
    */
   impl = spec_op[SectOp];
   if (impl == NULL)
      nfatal(op, "sectioning not implemented", NULL);

   tok = optab[Val0(op)].tok.t_type;
   if (tok == COLON) {
      /*
       * Simple sectioning, treat as a ternary operator.
       */
      t->n_type = N_InvOp;
      t->n_field[0].n_val = 3;      /* number of arguments */
      t->n_field[1].ip = impl;
      }
   else {
      /*
       * Find the data base entry for addition or subtraction.
       */
      if (tok == PCOLON) {
         impl1 = optab[plus_loc].binary;
         if (impl1 == NULL)
            nfatal(op, "addition not implemented", NULL);
         }
      else { /* MCOLON */
         impl1 = optab[minus_loc].binary;
         if (impl1 == NULL)
            nfatal(op, "subtraction not implemented", NULL);
         }
      t->n_type = N_Sect;
      t->n_field[0].ip = impl;
      t->n_field[1].ip = impl1;
      }
   t->n_field[2].n_ptr = arg1;
   t->n_field[3].n_ptr = arg2;
   t->n_field[4].n_ptr = arg3;
   return t;
   }

/*
 * invk_main - produce an procedure invocation node with one argument for
 *  use in the initial invocation to main() during type inference.
 */
nodeptr invk_main(main_proc)
struct pentry *main_proc;
   {
   register nodeptr t;

   t = NewNode(3);
   t->n_type = N_InvProc;
   t->n_file = NULL; 
   t->n_line = 0;
   t->n_col = 0;
   t->freetmp = NULL;
   t->n_field[0].n_val = 1;               /* 1 argument */
   t->n_field[1].proc = main_proc;
   t->n_field[2].n_ptr = tree1(N_Empty);

   if (max_prm < 1)
      max_prm = 1;
   return t;
   }