MCPcopy Create free account
hub / github.com/dop251/goja / parseArrayLiteral

Method parseArrayLiteral

parser/expression.go:542–571  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

540}
541
542func (self *_parser) parseArrayLiteral() *ast.ArrayLiteral {
543
544 idx0 := self.expect(token.LEFT_BRACKET)
545 var value []ast.Expression
546 for self.token != token.RIGHT_BRACKET && self.token != token.EOF {
547 if self.token == token.COMMA {
548 self.next()
549 value = append(value, nil)
550 continue
551 }
552 if self.token == token.ELLIPSIS {
553 self.next()
554 value = append(value, &ast.SpreadElement{
555 Expression: self.parseAssignmentExpression(),
556 })
557 } else {
558 value = append(value, self.parseAssignmentExpression())
559 }
560 if self.token != token.RIGHT_BRACKET {
561 self.expect(token.COMMA)
562 }
563 }
564 idx1 := self.expect(token.RIGHT_BRACKET)
565
566 return &ast.ArrayLiteral{
567 LeftBracket: idx0,
568 RightBracket: idx1,
569 Value: value,
570 }
571}
572
573func (self *_parser) parseTemplateLiteral(tagged bool) *ast.TemplateLiteral {
574 res := &ast.TemplateLiteral{

Callers 2

Calls 3

expectMethod · 0.95
nextMethod · 0.95

Tested by

no test coverage detected