MCPcopy Create free account
hub / github.com/TextGeneratorio/text-generator.io / statement

Function statement

static/libs/javascript.js:369–417  ·  view source on GitHub ↗
(type, value)

Source from the content-addressed store, hash-verified

367 }
368
369 function statement(type, value) {
370 if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
371 if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
372 if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
373 if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
374 if (type == "debugger") return cont(expect(";"));
375 if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
376 if (type == ";") return cont();
377 if (type == "if") {
378 if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
379 cx.state.cc.pop()();
380 return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
381 }
382 if (type == "function") return cont(functiondef);
383 if (type == "for") return cont(pushlex("form"), pushblockcontext, forspec, statement, popcontext, poplex);
384 if (type == "class" || (isTS && value == "interface")) {
385 cx.marked = "keyword"
386 return cont(pushlex("form", type == "class" ? type : value), className, poplex)
387 }
388 if (type == "variable") {
389 if (isTS && value == "declare") {
390 cx.marked = "keyword"
391 return cont(statement)
392 } else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
393 cx.marked = "keyword"
394 if (value == "enum") return cont(enumdef);
395 else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";"));
396 else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
397 } else if (isTS && value == "namespace") {
398 cx.marked = "keyword"
399 return cont(pushlex("form"), expression, statement, poplex)
400 } else if (isTS && value == "abstract") {
401 cx.marked = "keyword"
402 return cont(statement)
403 } else {
404 return cont(pushlex("stat"), maybelabel);
405 }
406 }
407 if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext,
408 block, poplex, poplex, popcontext);
409 if (type == "case") return cont(expression, expect(":"));
410 if (type == "default") return cont(expect(":"));
411 if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
412 if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
413 if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
414 if (type == "async") return cont(statement)
415 if (value == "@") return cont(expression, statement)
416 return pass(pushlex("stat"), expression, expect(";"), poplex);
417 }
418 function maybeCatchBinding(type) {
419 if (type == "(") return cont(funarg, expect(")"))
420 }

Callers

nothing calls this directly

Calls 4

contFunction · 0.85
pushlexFunction · 0.85
expectFunction · 0.85
passFunction · 0.70

Tested by

no test coverage detected