MCPcopy
hub / github.com/jquery/esprima / parseStatementListItem

Method parseStatementListItem

src/parser.ts:1774–1813  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1772 // https://tc39.github.io/ecma262/#sec-block
1773
1774 parseStatementListItem(): Node.StatementListItem {
1775 let statement: Node.StatementListItem;
1776 this.context.isAssignmentTarget = true;
1777 this.context.isBindingElement = true;
1778 if (this.lookahead.type === Token.Keyword) {
1779 switch (this.lookahead.value) {
1780 case 'export':
1781 if (!this.context.isModule) {
1782 this.tolerateUnexpectedToken(this.lookahead, Messages.IllegalExportDeclaration);
1783 }
1784 statement = this.parseExportDeclaration();
1785 break;
1786 case 'import':
1787 if (!this.context.isModule) {
1788 this.tolerateUnexpectedToken(this.lookahead, Messages.IllegalImportDeclaration);
1789 }
1790 statement = this.parseImportDeclaration();
1791 break;
1792 case 'const':
1793 statement = this.parseLexicalDeclaration({ inFor: false });
1794 break;
1795 case 'function':
1796 statement = this.parseFunctionDeclaration();
1797 break;
1798 case 'class':
1799 statement = this.parseClassDeclaration();
1800 break;
1801 case 'let':
1802 statement = this.isLexicalDeclaration() ? this.parseLexicalDeclaration({ inFor: false }) : this.parseStatement();
1803 break;
1804 default:
1805 statement = this.parseStatement();
1806 break;
1807 }
1808 } else {
1809 statement = this.parseStatement();
1810 }
1811
1812 return statement;
1813 }
1814
1815 parseBlock(): Node.BlockStatement {
1816 const node = this.createNode();

Callers 6

parseBlockMethod · 0.95
parseSwitchCaseMethod · 0.95
parseModuleMethod · 0.95
parseScriptMethod · 0.95

Calls 8

parseClassDeclarationMethod · 0.95
isLexicalDeclarationMethod · 0.95
parseStatementMethod · 0.95

Tested by

no test coverage detected