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

Method parseContinueStatement

parser/statement.go:1002–1045  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1000}
1001
1002func (self *_parser) parseContinueStatement() ast.Statement {
1003 idx := self.expect(token.CONTINUE)
1004 semicolon := self.implicitSemicolon
1005 if self.token == token.SEMICOLON {
1006 semicolon = true
1007 self.next()
1008 }
1009
1010 if semicolon || self.token == token.RIGHT_BRACE {
1011 self.implicitSemicolon = false
1012 if !self.scope.inIteration {
1013 goto illegal
1014 }
1015 return &ast.BranchStatement{
1016 Idx: idx,
1017 Token: token.CONTINUE,
1018 }
1019 }
1020
1021 self.tokenToBindingId()
1022 if self.token == token.IDENTIFIER {
1023 identifier := self.parseIdentifier()
1024 if !self.scope.hasLabel(identifier.Name) {
1025 self.error(idx, "Undefined label '%s'", identifier.Name)
1026 return &ast.BadStatement{From: idx, To: identifier.Idx1()}
1027 }
1028 if !self.scope.inIteration {
1029 goto illegal
1030 }
1031 self.semicolon()
1032 return &ast.BranchStatement{
1033 Idx: idx,
1034 Token: token.CONTINUE,
1035 Label: identifier,
1036 }
1037 }
1038
1039 self.expect(token.IDENTIFIER)
1040
1041illegal:
1042 self.error(idx, "Illegal continue statement")
1043 self.nextStatement()
1044 return &ast.BadStatement{From: idx, To: self.idx}
1045}
1046
1047// Find the next statement after an error (recover)
1048func (self *_parser) nextStatement() {

Callers 1

parseStatementMethod · 0.95

Calls 9

expectMethod · 0.95
nextMethod · 0.95
tokenToBindingIdMethod · 0.95
parseIdentifierMethod · 0.95
errorMethod · 0.95
semicolonMethod · 0.95
nextStatementMethod · 0.95
hasLabelMethod · 0.80
Idx1Method · 0.65

Tested by

no test coverage detected