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

Function statement

lib/web/CodeMirror/mode/javascript/javascript.js:364–412  ·  view source on GitHub ↗
(type, value)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

contFunction · 0.70
pushlexFunction · 0.70
expectFunction · 0.70
passFunction · 0.70
matchMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected