Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Language/JavaScript/Parser/Grammar7.y
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,15 @@ ImportSpecifier : IdentifierName
-- [x] export ExportClause ;
-- [x] export VariableStatement
-- [ ] export Declaration
-- [ ] Declaration :
-- [ ] HoistableDeclaration
-- [ ] ClassDeclaration
-- [x] LexicalDeclaration
-- [ ] HoistableDeclaration :
-- [x] FunctionDeclaration
-- [ ] GeneratorDeclaration
-- [ ] AsyncFunctionDeclaration
-- [ ] AsyncGeneratorDeclaration
-- [ ] export default HoistableDeclaration[Default]
-- [ ] export default ClassDeclaration[Default]
-- [ ] export default [lookahead ∉ { function, class }] AssignmentExpression[In] ;
Expand All @@ -1269,6 +1278,8 @@ ExportDeclaration : ExportClause AutoSemi
{ $1 {- 'ExportDeclaration1' -} }
| VariableStatement AutoSemi
{ AST.JSExport $1 $2 {- 'ExportDeclaration2' -} }
| FunctionDeclaration AutoSemi
{ AST.JSExport $1 $2 {- 'ExportDeclaration2' -} }

-- ExportClause :
-- { }
Expand Down
3 changes: 3 additions & 0 deletions test/Test/Language/Javascript/ModuleParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ testModuleParser = describe "Parse modules:" $ do
test "export const a = 1;"
`shouldBe`
"Right (JSAstModule [JSModuleExportDeclaration (JSExport (JSConstant (JSVarInitExpression (JSIdentifier 'a') [JSDecimal '1'])))])"
test "export function f() {};"
`shouldBe`
"Right (JSAstModule [JSModuleExportDeclaration (JSExport (JSFunction 'f' () (JSBlock [])))])"
test "export { a };"
`shouldBe`
"Right (JSAstModule [JSModuleExportDeclaration (JSExportLocals ((JSExportLocalSpecifier (JSIdentifier 'a'))))])"
Expand Down