archives

« Bugzilla Issues Index

#2266 — Grammar needs a single root, not Script or Module


Based on experience with traceur and what I can tell from the current draft grammar, the parser must chose whether to parse JS source as a Module or a Script before accessing the first token. This is not practical for development tools, eg parsers for editors and linters.

As a purely empirical guess, it seems to me that 'export' should be a legal token and that the difference between module and script currently expressed in the grammar should instead be environmental.


This would be significant design change. You need to take it up with the module champions or try to get some significant discussion on it on es-discuss.

It is understood that parsers including editor's and linters need to know what goal symbol to use. Plus even if a module body parses as a script, different semantics apply.

One possibility that has been kicked around is a new file extension convention for for ES modules. Perhaps ''jsm'. That would solve the problem for most file based tools.


We're locked in to have both module and script roots for the grammar.