oops. make depend after nl.c moves to ../src to be common with pi/pc0.
[unix-history] / usr / src / usr.bin / pascal / pxp / const.c
CommitLineData
f4e01610 1static char *sccsid = "@(#)const.c 1.2 (Berkeley) %G%";
9fad0514
PK
2/* Copyright (c) 1979 Regents of the University of California */
3#
4/*
5 * pxp - Pascal execution profiler
6 *
7 * Bill Joy UCB
8 * Version 1.2 January 1979
9 */
10
11#include "0.h"
12#include "tree.h"
13
f4e01610 14STATIC int constcnt = -1;
9fad0514
PK
15
16/*
17 * The const declaration part
18 */
19constbeg(l, cline)
20 int l, cline;
21{
22
23 line = l;
24 if (nodecl)
25 printoff();
26 puthedr();
27 putcm();
28 ppnl();
29 indent();
30 ppkw("const");
31 ppgoin(DECL);
32 constcnt = 0;
33 setline(cline);
34}
35
36const(cline, cid, cdecl)
37 int cline;
38 char *cid;
39 int *cdecl;
40{
41
42 if (constcnt)
43 putcm();
44 setline(cline);
45 ppitem();
46 ppid(cid);
47 ppsep(" = ");
48 gconst(cdecl);
49 ppsep(";");
50 constcnt++;
51 setinfo(cline);
52 putcml();
53}
54
55constend()
56{
57
58 if (constcnt == -1)
59 return;
60 if (nodecl)
61 return;
62 if (constcnt == 0)
63 ppid("{const decls}");
64 ppgoout(DECL);
65 constcnt = -1;
66}
67
68/*
69 * A constant in an expression
70 * or a declaration.
71 */
72gconst(r)
73 int *r;
74{
75 register *cn;
76
77 cn = r;
78loop:
79 if (cn == NIL) {
80 ppid("{constant}");
81 return;
82 }
83 switch (cn[0]) {
84 default:
85 panic("gconst");
86 case T_PLUSC:
87 ppop("+");
88 cn = cn[1];
89 goto loop;
90 case T_MINUSC:
91 ppop("-");
92 cn = cn[1];
93 goto loop;
94 case T_ID:
95 ppid(cn[1]);
96 return;
97 case T_CBINT:
98 case T_CINT:
99 case T_CFINT:
100 ppnumb(cn[1]);
101 if (cn[0] == T_CBINT)
102 ppsep("b");
103 return;
104 case T_CSTRNG:
105 ppstr(cn[1]);
106 return;
107 }
108}