archives

« Bugzilla Issues Index

#297 — Undecidable tokenization in modules' grammar


Consider the following expression:

export x, y, z;

According to the grammar defined in the harmony:modules wiki page, this expression can have two tokenized forms:

ExportDeclaration
-> ExportSpecifierSet
-> Id
-> Id
-> Id

ExportDeclaration
-> ExportSpecifierSet
-> Id
-> ExportSpecifierSet
-> Id
-> ExportSpecifierSet
-> Id

A parser has no way of choosing one form or the other unless maybe by using operator precedence, which is not defined in the grammar.

I've posted a possible revised grammar here: https://gist.github.com/1990115, replacing

ExportSpecifierSet ::= "{" ExportSpecifier ("," ExportSpecifier)* "}"
| Id ("," Id)*
| "*" ("from" Path)?

with

ExportSpecifierSet ::= "{" ExportSpecifier ("," ExportSpecifier)* "}"
| Id
| "*" ("from" Path)?


Regards.


no longer applicable to current ES6 module grammar