MCPcopy Index your code
hub / github.com/nodejs/node / parseExpressionOrLabeledStatement

Function parseExpressionOrLabeledStatement

test/fixtures/snapshot/typescript.js:36083–36106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36081 return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc);
36082 }
36083 function parseExpressionOrLabeledStatement() {
36084 // Avoiding having to do the lookahead for a labeled statement by just trying to parse
36085 // out an expression, seeing if it is identifier and then seeing if it is followed by
36086 // a colon.
36087 var pos = getNodePos();
36088 var hasJSDoc = hasPrecedingJSDocComment();
36089 var node;
36090 var hasParen = token() === 20 /* SyntaxKind.OpenParenToken */;
36091 var expression = allowInAnd(parseExpression);
36092 if (ts.isIdentifier(expression) && parseOptional(58 /* SyntaxKind.ColonToken */)) {
36093 node = factory.createLabeledStatement(expression, parseStatement());
36094 }
36095 else {
36096 if (!tryParseSemicolon()) {
36097 parseErrorForMissingSemicolonAfter(expression);
36098 }
36099 node = factory.createExpressionStatement(expression);
36100 if (hasParen) {
36101 // do not parse the same jsdoc twice
36102 hasJSDoc = false;
36103 }
36104 }
36105 return withJSDoc(finishNode(node, pos), hasJSDoc);
36106 }
36107 function nextTokenIsIdentifierOrKeywordOnSameLine() {
36108 nextToken();
36109 return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak();

Callers 1

parseStatementFunction · 0.85

Calls 10

getNodePosFunction · 0.85
hasPrecedingJSDocCommentFunction · 0.85
allowInAndFunction · 0.85
parseOptionalFunction · 0.85
parseStatementFunction · 0.85
tryParseSemicolonFunction · 0.85
withJSDocFunction · 0.85
finishNodeFunction · 0.85
tokenFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…