public Node parseExportDefaultDeclaration(Node node) { Node declaration = null, expression = null; // covers: // export default ... expectKeyword("default"); if (matchKeyword("function")) { // covers: // export default function foo () {} // export default function () {} declaration = parseFunctionDeclaration(new Node(), true); return node.finishExportDefaultDeclaration(declaration); } if (matchKeyword("class")) { declaration = parseClassDeclaration(true); return node.finishExportDefaultDeclaration(declaration); } if (matchContextualKeyword("from")) { throwError(string.Format(Messages.UnexpectedToken, lookahead.value)); } // covers: // export default {}; // export default []; // export default (1 + 2); if (match("{")) { expression = parseObjectInitializer(); } else if (match("[")) { expression = parseArrayInitializer(); } else { expression = parseAssignmentExpression(); } consumeSemicolon(); return node.finishExportDefaultDeclaration(expression); }