importing names in the modules, not just default imports
This commit is contained in:
committed by
Richard van Velzen
parent
d35a9e7839
commit
59e1601fb8
40
lib/parse.js
40
lib/parse.js
@@ -1613,8 +1613,28 @@ function parse($TEXT, options) {
|
||||
function import_() {
|
||||
var start = prev();
|
||||
var imported_name;
|
||||
var imported_names;
|
||||
if (is("name")) {
|
||||
imported_name = as_symbol(AST_SymbolImport);
|
||||
}
|
||||
|
||||
if (is("punc", ",")) {
|
||||
next();
|
||||
}
|
||||
|
||||
if (is("punc", "{")) {
|
||||
next();
|
||||
imported_names = [];
|
||||
while (!is("punc", "}")) {
|
||||
imported_names.push(import_name());
|
||||
if (is("punc", ",")) {
|
||||
next();
|
||||
}
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
if (imported_names || imported_name) {
|
||||
expect_token("name", "from");
|
||||
}
|
||||
var mod_str = S.token;
|
||||
@@ -1625,6 +1645,7 @@ function parse($TEXT, options) {
|
||||
return new AST_Import({
|
||||
start: start,
|
||||
imported_name: imported_name,
|
||||
imported_names: imported_names,
|
||||
module_name: new AST_String({
|
||||
start: mod_str,
|
||||
value: mod_str.value,
|
||||
@@ -1635,6 +1656,25 @@ function parse($TEXT, options) {
|
||||
});
|
||||
}
|
||||
|
||||
function import_name() {
|
||||
var start = S.token;
|
||||
var foreign_name;
|
||||
var name;
|
||||
|
||||
if (peek().value === "as" && peek().type === "name") {
|
||||
foreign_name = as_symbol(AST_SymbolImportForeign);
|
||||
next(); // The "as" word
|
||||
}
|
||||
name = as_symbol(AST_SymbolImport);
|
||||
|
||||
return new AST_NameImport({
|
||||
start: start,
|
||||
foreign_name: foreign_name,
|
||||
name: name,
|
||||
end: prev(),
|
||||
})
|
||||
}
|
||||
|
||||
function as_property_name() {
|
||||
var tmp = S.token;
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user