()
| 1511 | return generators; |
| 1512 | } |
| 1513 | _parseList() { |
| 1514 | const elts = []; |
| 1515 | this._tokenizer.expect('['); |
| 1516 | if (!this._tokenizer.match(']')) { |
| 1517 | const position = this._position(); |
| 1518 | const expr = this._parseExpression(-1, ['for']); |
| 1519 | if (this._tokenizer.match('id', 'for')) { |
| 1520 | const generators = this._parseGenerators(); |
| 1521 | this._tokenizer.expect(']'); |
| 1522 | const node = new ast.ListComp(expr, generators); |
| 1523 | this._mark(node, position); |
| 1524 | return node; |
| 1525 | } |
| 1526 | if (expr === null) { |
| 1527 | throw new python.Error(`Expected expression ${this._location()}`); |
| 1528 | } |
| 1529 | elts.push(expr); |
| 1530 | while (this._tokenizer.accept(',')) { |
| 1531 | if (this._tokenizer.match(']')) { |
| 1532 | break; |
| 1533 | } |
| 1534 | const expr = this._parseExpression(-1, ['for']); |
| 1535 | if (!expr) { |
| 1536 | throw new python.Error(`Expected expression ${this._location()}`); |
| 1537 | } |
| 1538 | elts.push(expr); |
| 1539 | } |
| 1540 | } |
| 1541 | this._tokenizer.expect(']'); |
| 1542 | return new ast.List(elts); |
| 1543 | } |
| 1544 | _parseSlice() { |
| 1545 | const elts = []; |
| 1546 | let slice = [null, null, null]; |
no test coverage detected