Comments (5)
no, there is not need to look ahead because function
means function declaration with or without a name, in which case the first one will fail, while the second one will pass.
IIRC the implementation in esprima does a lookahead but just to determine whether the function has a name or not.
The same applies to all other variants.
from ecmascript-more-export-from.
Then maybe it should made clear in Spec, for example like:
export default [lookahead ! {function, class, from}] AssignmentExpression[In] ;
from ecmascript-more-export-from.
no, the spec is clear on that regards. the fact that we do so in esprima is just an implementation detail to reuse the function declaration parser, but in the spec a function without a name is very well defined. You can find a lot of discussion around that topic in esdiscuss and espree repo.
from ecmascript-more-export-from.
It's not about function declaration...
export IdentifierName from module
is conflict with
export Declaration
when IdentifierName is function/class/let/const, and conflict with
export VariableStatement
when IdentifierName is var
and why use esprima as example? I just check it's source code, it does not even support additional export from statements in ES 7?
from ecmascript-more-export-from.
Look ahead restrictions in grammars are necessary to remove ambiguity, but there is no ambiguity here. Your first example is unambiguously an export-from and your second example is unambiguously an exported function.
Parser implementations need to look ahead to know what paths to take. In an LR(1) grammar, rules are designed to only require a single token look ahead in order to know which path to take, which is maybe what you were referring to here. However JavaScript is not an LR(1) grammar as there are already other cases in the language where a further look ahead is required. In this case, after lexing "function" and two paths are possible, a look ahead of two tokens is necessary.
from ecmascript-more-export-from.
Related Issues (10)
- follow up HOT 9
- Send PR that adds this to https://github.com/tc39/ecma262 HOT 2
- Take away from TC39 2015-5 HOT 2
- question on export * as ns from 'm' HOT 5
- ESlint rules HOT 1
- Clarify Babel extension. HOT 1
- Symmetry between import and export HOT 10
- export {default as v} from "mod"; HOT 2
- import {x,y} as v from "mod"; HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ecmascript-more-export-from.