while (ps.p_stack[ps.tos] == ifhead && tk != elselit) { /* true if we have an if without an else */
ps.p_stack[ps.tos] = stmt; /* apply the if(..) stmt ::= stmt
* reduction */
reduce(); /* see if this allows any reduction */
}
switch (tk) { /* go on and figure out what to do with the
* input */
case decl: /* scanned a declaration word */
ps.search_brace = btype_2; /* indicate that following brace should be on same line */ if (ps.p_stack[ps.tos] != decl) { /* only put one declaration
* onto stack */
break_comma = true; /* while in declaration, newline should be
* forced after comma */
ps.p_stack[++ps.tos] = decl;
ps.il[ps.tos] = ps.i_l_follow;
if (ps.ljust_decl) {/* only do if we want left justified
* declarations */
ps.ind_level = 0; for (i = ps.tos - 1; i > 0; --i) if (ps.p_stack[i] == decl)
++ps.ind_level; /* indentation is number of
* declaration levels deep we are */
ps.i_l_follow = ps.ind_level;
}
} break;
case ifstmt: /* scanned if (...) */ if (ps.p_stack[ps.tos] == elsehead && ps.else_if) /* "else if ..." */ /* *Notethatthestackpointerhereisdecremented,effectively *reducing"elseif"to"if".Thissavesalotofstackspace *incaseofalong"if-else-if...else-if"sequence.
*/
ps.i_l_follow = ps.il[ps.tos--]; /* the rest is the same as for dolit and forstmt */ /* FALLTHROUGH */ case dolit: /* 'do' */ case forstmt: /* for (...) */
ps.p_stack[++ps.tos] = tk;
ps.il[ps.tos] = ps.ind_level = ps.i_l_follow;
++ps.i_l_follow; /* subsequent statements should be indented 1 */
ps.search_brace = btype_2; break;
case lbrace: /* scanned { */
break_comma = false; /* don't break comma in an initial list */ if (ps.p_stack[ps.tos] == stmt || ps.p_stack[ps.tos] == decl
|| ps.p_stack[ps.tos] == stmtl)
++ps.i_l_follow; /* it is a random, isolated stmt group or a
* declaration */ else { if (s_code == e_code) { /* *onlydothisifthereisnothingontheline
*/
--ps.ind_level; /* *itisagroupaspartofawhile,for,etc.
*/ if (ps.p_stack[ps.tos] == swstmt && ps.case_indent >= 1)
--ps.ind_level; /* *foraswitch,braceshouldbetwolevelsoutfromthecode
*/
}
}
case whilestmt: /* scanned while (...) */ if (ps.p_stack[ps.tos] == dohead) { /* it is matched with do stmt */
ps.ind_level = ps.i_l_follow = ps.il[ps.tos];
ps.p_stack[++ps.tos] = whilestmt;
ps.il[ps.tos] = ps.ind_level = ps.i_l_follow;
} else { /* it is a while loop */
ps.p_stack[++ps.tos] = whilestmt;
ps.il[ps.tos] = ps.i_l_follow;
++ps.i_l_follow;
ps.search_brace = btype_2;
}
break;
case elselit: /* scanned an else */
if (ps.p_stack[ps.tos] != ifhead)
diag2(1, "Unmatched 'else'"); else {
ps.ind_level = ps.il[ps.tos]; /* indentation for else should
* be same as for if */
ps.i_l_follow = ps.ind_level + 1; /* everything following should
* be in 1 level */
ps.p_stack[ps.tos] = elsehead; /* remember if with else */
ps.search_brace = btype_2 | ps.else_if;
} break;
case rbrace: /* scanned a } */ /* stack should have <lbrace> <stmt> or <lbrace> <stmtl> */ if (ps.tos > 0 && ps.p_stack[ps.tos - 1] == lbrace) {
ps.ind_level = ps.i_l_follow = ps.il[--ps.tos];
ps.p_stack[ps.tos] = stmt;
} else
diag2(1, "Statement nesting error"); break;
case swstmt: /* had switch (...) */
ps.p_stack[++ps.tos] = swstmt;
ps.cstk[ps.tos] = case_ind; /* save current case indent level */
ps.il[ps.tos] = ps.i_l_follow;
case_ind = ps.i_l_follow + ps.case_indent; /* cases should be one *leveldownfrom
* switch */
ps.i_l_follow += ps.case_indent + 1; /* statements should be two
* levels in */
ps.search_brace = btype_2; break;
case semicolon: /* this indicates a simple stmt */
break_comma = false; /* turn off flag to break after commas in a
* declaration */
ps.p_stack[++ps.tos] = stmt;
ps.il[ps.tos] = ps.ind_level; break;
default: /* this is an error */
diag2(1, "Unknown code to parser"); return;
} /* end of switch */
if (ps.tos >= nitems(ps.p_stack) - 1)
errx(1, "Parser stack overflow");
reduce(); /* see if any reduction can be done */
#ifdef debug for (i = 1; i <= ps.tos; ++i)
printf("(%d %d)", ps.p_stack[i], ps.il[i]);
printf("\n"); #endif
case swstmt: /* <switch> <stmt> */
case_ind = ps.cstk[ps.tos - 1]; /* FALLTHROUGH */ case decl: /* finish of a declaration */ case elsehead: /* <<if> <stmt> else> <stmt> */ case forstmt: /* <for> <stmt> */ case whilestmt: /* <while> <stmt> */
ps.p_stack[--ps.tos] = stmt;
ps.i_l_follow = ps.il[ps.tos]; break;
default: /* <anything else> <stmt> */ return;
} /* end of section for <stmt> on top of stack */ break;
case whilestmt: /* while (...) on top */ if (ps.p_stack[ps.tos - 1] == dohead) { /* it is termination of a do while */
ps.tos -= 2; break;
} else return;
default: /* anything else on top */ return;
}
}
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.2Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-08-06)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.