Definition at line 49 of file parse.c.
50{
52
53#ifdef debug
55#endif
56
58 /* true if we have an if without an else */
60 * reduction */
61 reduce();
/* see if this allows any reduction */
62 }
63
64
65 switch (tk) { /* go on and figure out what to do with the
66 * input */
67
68 case decl:
/* scanned a declaration word */
70 /* indicate that following brace should be on same line */
72 * onto stack */
73 break_comma =
true;
/* while in declaration, newline should be
74 * forced after comma */
77
79 * declarations */
84 * declaration levels deep we are */
86 }
87 }
88 break;
89
90 case ifstmt:
/* scanned if (...) */
92 /*
93 * Note that the stack pointer here is decremented, effectively
94 * reducing "else if" to "if". This saves a lot of stack space
95 * in case of a long "if-else-if ... else-if" sequence.
96 */
98 /* the rest is the same as for dolit and forstmt */
99 /* FALLTHROUGH */
100 case dolit:
/* 'do' */
104 ++
ps.
i_l_follow;
/* subsequent statements should be indented 1 */
106 break;
107
108 case lbrace:
/* scanned { */
109 break_comma =
false;
/* don't break comma in an initial list */
112 ++
ps.
i_l_follow;
/* it is a random, isolated stmt group or a
113 * declaration */
114 else {
116 /*
117 * only do this if there is nothing on the line
118 */
120 /*
121 * it is a group as part of a while, for, etc.
122 */
125 /*
126 * for a switch, brace should be two levels out from the code
127 */
128 }
129 }
130
134 /* allow null stmt between braces */
136 break;
137
138 case whilestmt:
/* scanned while (...) */
140 /* it is matched with do stmt */
144 }
145 else { /* it is a while loop */
150 }
151
152 break;
153
154 case elselit:
/* scanned an else */
155
157 diag2(1,
"Unmatched 'else'");
158 else {
160 * be same as for if */
162 * be in 1 level */
164 /* remember if with else */
166 }
167 break;
168
169 case rbrace:
/* scanned a } */
170 /* stack should have <lbrace> <stmt> or <lbrace> <stmtl> */
174 }
175 else
176 diag2(1,
"Statement nesting error");
177 break;
178
179 case swstmt:
/* had switch (...) */
182 /* save current case indent level */
185 * level down from
186 * switch */
188 * levels in */
190 break;
191
192 case semicolon:
/* this indicates a simple stmt */
193 break_comma =
false;
/* turn off flag to break after commas in a
194 * declaration */
197 break;
198
199 default: /* this is an error */
200 diag2(1,
"Unknown code to parser");
201 return;
202
203
204 } /* end of switch */
205
207 errx(1,
"Parser stack overflow");
208
209 reduce();
/* see if any reduction can be done */
210
211#ifdef debug
215#endif
216
217 return;
218}
void errx(int eval, const char *fmt,...)
void diag2(int, const char *)
References break_comma, btype_2, case_ind, parser_state::case_indent, parser_state::cstk, decl, diag2(), dohead, dolit, e_code, parser_state::else_if, elsehead, elselit, errx(), forstmt, i, parser_state::i_l_follow, ifhead, ifstmt, parser_state::il, parser_state::ind_level, lbrace, parser_state::ljust_decl, nitems, parser_state::p_stack, printf, ps, rbrace, reduce(), s_code, parser_state::search_brace, semicolon, stmt, stmtl, swstmt, parser_state::tos, and whilestmt.