MCPcopy Index your code
hub / github.com/lutzroeder/netron / _parseList

Method _parseList

source/python.js:1513–1543  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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];

Callers 2

_parseExpressionMethod · 0.80
_parseTypeMethod · 0.80

Calls 9

_positionMethod · 0.80
_parseExpressionMethod · 0.80
_parseGeneratorsMethod · 0.80
_markMethod · 0.80
expectMethod · 0.45
matchMethod · 0.45
_locationMethod · 0.45
pushMethod · 0.45
acceptMethod · 0.45

Tested by

no test coverage detected