()
| 511 | } |
| 512 | |
| 513 | func (self *_parser) parseSwitchStatement() ast.Statement { |
| 514 | idx := self.expect(token.SWITCH) |
| 515 | self.expect(token.LEFT_PARENTHESIS) |
| 516 | node := &ast.SwitchStatement{ |
| 517 | Switch: idx, |
| 518 | Discriminant: self.parseExpression(), |
| 519 | Default: -1, |
| 520 | } |
| 521 | self.expect(token.RIGHT_PARENTHESIS) |
| 522 | |
| 523 | self.expect(token.LEFT_BRACE) |
| 524 | |
| 525 | inSwitch := self.scope.inSwitch |
| 526 | self.scope.inSwitch = true |
| 527 | defer func() { |
| 528 | self.scope.inSwitch = inSwitch |
| 529 | }() |
| 530 | |
| 531 | for index := 0; self.token != token.EOF; index++ { |
| 532 | if self.token == token.RIGHT_BRACE { |
| 533 | node.RightBrace = self.idx |
| 534 | self.next() |
| 535 | break |
| 536 | } |
| 537 | |
| 538 | clause := self.parseCaseStatement() |
| 539 | if clause.Test == nil { |
| 540 | if node.Default != -1 { |
| 541 | self.error(clause.Case, "Already saw a default in switch") |
| 542 | } |
| 543 | node.Default = index |
| 544 | } |
| 545 | node.Body = append(node.Body, clause) |
| 546 | } |
| 547 | |
| 548 | return node |
| 549 | } |
| 550 | |
| 551 | func (self *_parser) parseWithStatement() ast.Statement { |
| 552 | node := &ast.WithStatement{} |
no test coverage detected