MCPcopy
hub / github.com/jquery/esprima / parseArrayInitializer

Method parseArrayInitializer

src/parser.ts:711–738  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

709 }
710
711 parseArrayInitializer(): Node.ArrayExpression {
712 const node = this.createNode();
713 const elements: Node.ArrayExpressionElement[] = [];
714
715 this.expect('[');
716 while (!this.match(']')) {
717 if (this.match(',')) {
718 this.nextToken();
719 elements.push(null);
720 } else if (this.match('...')) {
721 const element = this.parseSpreadElement();
722 if (!this.match(']')) {
723 this.context.isAssignmentTarget = false;
724 this.context.isBindingElement = false;
725 this.expect(',');
726 }
727 elements.push(element);
728 } else {
729 elements.push(this.inheritCoverGrammar(this.parseAssignmentExpression));
730 if (!this.match(']')) {
731 this.expect(',');
732 }
733 }
734 }
735 this.expect(']');
736
737 return this.finalize(node, new Node.ArrayExpression(elements));
738 }
739
740 // https://tc39.github.io/ecma262/#sec-object-initializer
741

Callers 1

Calls 8

createNodeMethod · 0.95
expectMethod · 0.95
matchMethod · 0.95
nextTokenMethod · 0.95
parseSpreadElementMethod · 0.95
inheritCoverGrammarMethod · 0.95
finalizeMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected