MCPcopy
hub / github.com/microsoft/pyright / _parseSubscriptList

Method _parseSubscriptList

server/src/parser/parser.ts:1644–1663  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1642
1643 // subscriptlist: subscript (',' subscript)* [',']
1644 private _parseSubscriptList(): ExpressionNode {
1645 let listResult = this._parseExpressionListGeneric(() => this._parseSubscript(), () => {
1646 // Override the normal terminal check to exclude colons,
1647 // which are a valid way to start subscription expressions.
1648 if (this._peekTokenType() === TokenType.Colon) {
1649 return false;
1650 }
1651 return this._isNextTokenNeverExpression();
1652 });
1653
1654 if (listResult.parseError) {
1655 return listResult.parseError;
1656 }
1657
1658 if (listResult.list.length === 0) {
1659 return this._handleExpressionParseError('Expected index or slice expression');
1660 }
1661
1662 return this._makeExpressionOrTuple(listResult);
1663 }
1664
1665 // subscript: test | [test] ':' [test] [sliceop]
1666 // sliceop: ':' [test]

Callers 1

_parseAtomExpressionMethod · 0.95

Calls 6

_parseSubscriptMethod · 0.95
_peekTokenTypeMethod · 0.95

Tested by

no test coverage detected