MCPcopy Create free account
hub / github.com/davidkingzyb/SCAST / parseStatement

Function parseStatement

lib/filbert.js:1741–1873  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1739 // does not help.
1740
1741 function parseStatement() {
1742 if (tokType === _slash || tokType === _assign && tokVal == "/=")
1743 readToken(true);
1744
1745 var starttype = tokType, node = startNode();
1746
1747 // Most types of statements are recognized by the keyword they
1748 // start with. Many are trivial to parse, some require a bit of
1749 // complexity.
1750
1751 switch (starttype) {
1752
1753 case _break:
1754 next();
1755 return finishNode(node, "BreakStatement");
1756
1757 case _continue:
1758 next();
1759 return finishNode(node, "ContinueStatement");
1760
1761 case _class:
1762 next();
1763 return parseClass(node);
1764
1765 case _def:
1766 next();
1767 return parseFunction(node);
1768
1769 case _for:
1770 next();
1771 return parseFor(node);
1772
1773 case _from: // Skipping from and import statements for now
1774 skipLine();
1775 next();
1776 return parseStatement();
1777
1778 case _if: case _elif:
1779 next();
1780 if (tokType === _parenL) node.test = parseParenExpression();
1781 else node.test = parseExpression();
1782 expect(_colon);
1783 node.consequent = parseSuite();
1784 if (tokType === _elif) {
1785 node.alternate = parseStatement();
1786 }
1787 else if (eat(_else)) {
1788 expect(_colon);
1789 eat(_colon);
1790 node.alternate = parseSuite();
1791 }
1792 else {
1793 node.alternate = null;
1794 }
1795 return finishNode(node, "IfStatement");
1796
1797 case _import: // Skipping from and import statements for now
1798 skipLine();

Callers 3

parseTopLevelFunction · 0.85
parseBlockFunction · 0.85
parseSuiteFunction · 0.85

Calls 15

readTokenFunction · 0.85
startNodeFunction · 0.85
finishNodeFunction · 0.85
parseClassFunction · 0.85
parseFunctionFunction · 0.85
parseForFunction · 0.85
skipLineFunction · 0.85
parseParenExpressionFunction · 0.85
parseExpressionFunction · 0.85
expectFunction · 0.85
parseSuiteFunction · 0.85
eatFunction · 0.85

Tested by

no test coverage detected