MCPcopy
hub / github.com/lutzroeder/netron / _parseStatement

Method _parseStatement

source/python.js:753–1077  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

751 return body;
752 }
753 _parseStatement() {
754 let node = null;
755 let position = this._position();
756 if (this._eat('id', 'break')) {
757 const node = new ast.Break();
758 return this._mark(node, position);
759 }
760 if (this._eat('id', 'continue')) {
761 const node = new ast.Continue();
762 return this._mark(node, position);
763 }
764 if (this._eat('id', 'return')) {
765 const value = this._parseExpression(-1, [], true);
766 const node = new ast.Return(value);
767 return this._mark(node, position);
768 }
769 if (this._eat('id', 'raise')) {
770 let exc = this._parseExpression(-1, ['from']);
771 let cause = null;
772 if (this._tokenizer.accept('id', 'from')) {
773 cause = this._parseExpression();
774 } else if (this._tokenizer.accept(',')) {
775 exc = [exc];
776 exc.push(this._parseExpression());
777 if (this._tokenizer.accept(',')) {
778 exc.push(this._parseExpression());
779 }
780 }
781 node = new ast.Raise(exc, cause);
782 return this._mark(node, position);
783 }
784 if (this._eat('id', 'assert')) {
785 const test = this._parseExpression(-1, [',']);
786 let msg = null;
787 if (this._tokenizer.accept(',')) {
788 msg = this._parseExpression();
789 }
790 node = new ast.Assert(test, msg);
791 return this._mark(node, position);
792 }
793 if (this._eat('id', 'global')) {
794 const names = [];
795 do {
796 const name = this._parseName(true);
797 names.push(name.id);
798 }
799 while (this._tokenizer.accept(','));
800 const node = new ast.Global(names);
801 return this._mark(node, position);
802 }
803 if (this._eat('id', 'nonlocal')) {
804 const names = [];
805 do {
806 const name = this._parseName(true);
807 names.push(name.id);
808 }
809 while (this._tokenizer.accept(','));
810 const node = new ast.Nonlocal(names);

Callers 2

parseMethod · 0.80
_parseSuiteMethod · 0.80

Calls 15

_positionMethod · 0.80
_markMethod · 0.80
_parseExpressionMethod · 0.80
_parseNameMethod · 0.80
_parseDottedNameMethod · 0.80
_decoratorMethod · 0.80
_parseSuiteMethod · 0.80
_parseArgumentsMethod · 0.80
_eatMethod · 0.45
acceptMethod · 0.45
pushMethod · 0.45
peekMethod · 0.45

Tested by

no test coverage detected