Closed jchitel closed 6 years ago
Ok, the syntax (all parser-impl, CST, and AST logic) is done.
The remaining work:
Things to address:
Additional problem:
This will actually be nice for several reasons:
Ok, tests are done and all passing. We could probably use more coverage, but we're fine for the time being. Closing my first feature!
Import/Export Additions
Description:
Exports are weird right now because they are sort of tacked on to declarations. They have their own scope for names, which sort of makes sense, but it can be done more intuitively. Also, as of now, exports are the only way to declare constants. It turned out that way because we wanted to be able to export expressions but had no way to declare non-exported expressions. We have an entire framework to support them, so we may as well just do it.
So these are the import forms we need to support:
import from "module": ImportName
: import defaultimport from "module": { {name}, {name} as {alias}, ... }
: import namedimport from "module": ImportName, { {name}, {name} as {alias}, ... }
: import named and defaultimport from "module": * as {namespace}
: wildcard importimport from "module": { {name}, {name} as {alias}, * as {namespace} }
: import named and wildcardimport from "module": ImportName, * as {namespace}
: default and wildcard importimport from "module": ImportName, { {name}, {name} as {alias}, * as {namespace} }
: default, named and wildcard importCurrently 1 and 2 are already supported, and 3-7 are not yet supported.
And these are the export forms we need to support:
export default {named declaration}
: export default in place declarationexport default {anon declaration}
: export default anonymous declarationexport default {name}
: export default already declared declarationexport {named declaration}
: export declaration with declaration nameexport {name} = {named declaration}
: export declaration with another nameexport {name} = {expression}
: export constant under nameexport { {name}, {name} as {alias}, ... }
: export already declared declaration(s)Currently 1 and 3 are already supported, and 2 and 4 are not yet supported. 5 and 6 are currently supported and will be removed. 7 currently exists in a different form for single exports, it will be redone to support multiple exports.
And these are fusion import/export declarations (export forwarding):
export from "module": ExportName
: Default from another -> Named from yoursexport default from "module"
: Default from another -> Default from yoursexport default from "module": { {name} }
: Named from another -> Default from yoursexport from "module:" { {name}, {name} as {alias}, ... }
: Named from another -> Named from yoursexport default from "module": *
: All from another -> Default from yours (grouped under a namespace object)export from "module": * as {name}
: All from another -> Named from yours (grouped under a namepsace object)export from "module": *
: All from another -> All from yours (ungrouped, just a 1:1 forward)Currently none of these are supported.
With the above, all possible kinds of imports and exports should be supported.
New syntactic features:
New Tokens
New NonTerminals:
Extended NonTerminals:
New semantic features:
Transformation: