@waldemarhorwat pointed out and is concerned about the ambiguity of import source from ....
Here are all possible productions:
// regular import, default binding name is `source`
import source from "";
// source phase import, binding name is `from`
import source from from "";
And when taking into account import declarations with local imports:
// with import declarations, regular import, default binding name = source, import declaration = from
import source from from;
Regarding other ambiguity with import declarations local imports, phase imports, and ASI, also see #41.
Due to the disambiguation complexity (even though I think it is bounded to a three token lookahead), I suggest we ban import source from from in the context of source phase imports. This means that: import source from ... is unambiguously a regular import with a binding name of source. With import declarations this could be followed by either a identifier (for local imports), or a specifier string literal.
This reduces the parsing complexity back to a 1-token lookahead.
@waldemarhorwat pointed out and is concerned about the ambiguity of
import source from ...
.Here are all possible productions:
And when taking into account import declarations with local imports:
Regarding other ambiguity with import declarations local imports, phase imports, and ASI, also see #41.
Due to the disambiguation complexity (even though I think it is bounded to a three token lookahead), I suggest we ban
import source from from
in the context of source phase imports. This means that:import source from ...
is unambiguously a regular import with a binding name of source. With import declarations this could be followed by either a identifier (for local imports), or a specifier string literal.This reduces the parsing complexity back to a 1-token lookahead.
Thanks @littledan for the suggestion.
@waldemarhorwat, what do you think?