MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / statement

Function statement

lib/web/jshint.js:20546–20633  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20544 }
20545
20546 function statement() {
20547 var i = indent, r, t = state.tokens.next, hasOwnScope = false;
20548
20549 if (t.id === ";") {
20550 advance(";");
20551 return;
20552 }
20553
20554 // Is this a labelled statement?
20555 var res = isReserved(t);
20556
20557 // We're being more tolerant here: if someone uses
20558 // a FutureReservedWord as a label, we warn but proceed
20559 // anyway.
20560
20561 if (res && t.meta && t.meta.isFutureReservedWord && peek().id === ":") {
20562 warning("W024", t, t.id);
20563 res = false;
20564 }
20565
20566 if (t.identifier && !res && peek().id === ":") {
20567 advance();
20568 advance(":");
20569
20570 hasOwnScope = true;
20571 state.funct["(scope)"].stack();
20572 state.funct["(scope)"].block.addBreakLabel(t.value, { token: state.tokens.curr });
20573
20574 if (!state.tokens.next.labelled && state.tokens.next.value !== "{") {
20575 warning("W028", state.tokens.next, t.value, state.tokens.next.value);
20576 }
20577
20578 state.tokens.next.label = t.value;
20579 t = state.tokens.next;
20580 }
20581
20582 // Is it a lonely block?
20583
20584 if (t.id === "{") {
20585 // Is it a switch case block?
20586 //
20587 // switch (foo) {
20588 // case bar: { <= here.
20589 // ...
20590 // }
20591 // }
20592 var iscase = (state.funct["(verb)"] === "case" && state.tokens.curr.value === ":");
20593 block(true, true, false, false, iscase);
20594
20595 if (hasOwnScope) {
20596 state.funct["(scope)"].unstack();
20597 }
20598
20599 return;
20600 }
20601
20602 // Parse the statement.
20603

Callers 3

statementsFunction · 0.70
blockFunction · 0.70
jshint.jsFile · 0.70

Calls 7

isReservedFunction · 0.85
peekFunction · 0.85
warningFunction · 0.85
parseFinalSemicolonFunction · 0.85
advanceFunction · 0.70
blockFunction · 0.70
expressionFunction · 0.70

Tested by

no test coverage detected