|
|
1.1 root 1: #include <stdio.h>
2: #include "def.h"
3: #include "4.def.h"
4: #include "3.def.h"
5:
6: ndbrace(v) /* determine whether braces needed around subparts of v */
7: /* return TRUE if v ends with IF THEN not in braces */
8: VERT v;
9: {
10: VERT w;
11: int i;
12: LOGICAL endif;
13: endif = FALSE;
14: for (i = 0; i < CHILDNUM(v); ++i)
15: {
16: endif = FALSE;
17: for (w = LCHILD(v,i); DEFINED(w); w = RSIB(w))
18: endif = ndbrace(w);
19: if (NTYPE(v) != DUMVX && NTYPE(v) != ITERVX &&
20: (!DEFINED(LCHILD(v,i)) || compound(v,i) ||
21: (endif && NTYPE(v) == IFVX && !IFTHEN(v) && i == THEN )))
22: /* DUMVX doesn't nest, ITERVX doen't nest since
23: nesting is done at LOOPNODE, etc., must
24: check for IFTHEN followed by unrelated ELSE */
25: {
26: YESBRACE(v,i);
27: endif = FALSE;
28: }
29: }
30: return(endif || IFTHEN(v) );
31: }
32:
33:
34: compound(v,ch) /* return TRUE iff subpart ch of v has multiple statements */
35: VERT v;
36: int ch;
37: {
38: VERT w;
39: w = LCHILD(v,ch);
40: if (!DEFINED(w))
41: return(FALSE);
42: if (NTYPE(w) == ITERVX)
43: {
44: ASSERT(DEFINED(NXT(w)),compound);
45: if (LABEL(NXT(w)))
46: return(TRUE); /* loop ends with labeled CONTINUE statement */
47: else
48: return(compound(w,0));
49: }
50: else if (DEFINED(RSIB(w)))
51: return(TRUE);
52: else if (NTYPE(w) == STLNVX && CODELINES(w) > 1)
53: return(TRUE);
54: else
55: return(FALSE);
56: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.