src/parser/switch.js
function() {
    // DETECT SWITCH MODE
    let expect = null;
    const result = this.node("block");
    const items = [];
    if (this.token === "{") {
      expect = "}";
    } else if (this.token === ":") {
      expect = this.tok.T_ENDSWITCH;
    } else {
      this.expect(["{", ":"]);
    }
    // OPTIONNAL ';'
    // https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L570
    if (this.next().token === ";") {
      this.next();
    }
    // EXTRACTING CASES
    while (this.token !== this.EOF && this.token !== expect) {
      items.push(this.read_case_list(expect));
    }
    // CHECK END TOKEN
    this.expect(expect) && this.next();
    if (expect === this.tok.T_ENDSWITCH) {
      this.expectEndOfStatement();
    }
    return result(null, items);
  }
function() {
    // DETECT SWITCH MODE
    let expect = null;
    const result = this.node("block");
    const items = [];
    if (this.token === "{") {
      expect = "}";
    } else if (this.token === ":") {
      expect = this.tok.T_ENDSWITCH;
    } else {
      this.expect(["{", ":"]);
    }
    // OPTIONNAL ';'
    // https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L570
    if (this.next().token === ";") {
      this.next();
    }
    // EXTRACTING CASES
    while (this.token !== this.EOF && this.token !== expect) {
      items.push(this.read_case_list(expect));
    }
    // CHECK END TOKEN
    this.expect(expect) && this.next();
    if (expect === this.tok.T_ENDSWITCH) {
      this.expectEndOfStatement();
    }
    return result(null, items);
  }
function ( ) { // DETECT SWITCH MODE let expect = null ; const result = this . node ( "block" ) ; const items = [ ] ; if ( this . token === "{" ) { expect = "}" ; } else if ( this . token === ":" ) { expect = this . tok . T_ENDSWITCH ; } else { this . expect ( [ "{" , ":" ] ) ; } // OPTIONNAL ';' // https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L570 if ( this . next ( ) . token === ";" ) { this . next ( ) ; } // EXTRACTING CASES while ( this . token !== this . EOF && this . token !== expect ) { items . push ( this . read_case_list ( expect ) ) ; } // CHECK END TOKEN this . expect ( expect ) && this . next ( ) ; if ( expect === this . tok . T_ENDSWITCH ) { this . expectEndOfStatement ( ) ; } return result ( null , items ) ; }
```ebnf
switch_case_list ::= '{' ';'? case_list* '}' | ':' ';'? case_list* T_ENDSWITCH ';'
```
@see https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L566
ebnf switch_case_list :: = { ; ? case_list * } | : ; ? case_list * T_ENDSWITCH ;