proposal-binary-ast
proposal-binary-ast copied to clipboard
Grammar quirks
It is almost certainly too early to worry about this, but a couple notes while I'm thinking of them:
-
The tree grammar specified does not allow
for (var a = b in c);
, which is a legal program (in sloppy mode, assuming Annex B) as of https://github.com/tc39/ecma262/pull/614. -
There's a variety of ways that well-typed trees can fail to correspond to real programs, which should all be captured in this project (except that said project hasn't been updated for
async
/await
yet). For example, you can't have anif
with anelse
as the body of anif
without anelse
, even though the tree types can represent that. You also have to make sure thatIdentifiers
are actually identifiers and that sort of thing. These aren't captured by the early error rules because they don't match the lexical grammar, and so presumably will need to be checked explicitly. -
The type for
TemplateExpression
can be made more strict by having something like
interface Interpolation {
attribute Expression value;
attribute TemplateElement after;
}
interface TemplateExpression : Node {
attribute Expression? tag;
attribute TemplateElement start;
attribute FrozenArray<Interpolation> elements;
};
instead of the current TemplateExpression
definition which just has a list of elements which mixes Expression
s and TemplateElement
s. Shift doesn't currently do this because it's kinda awkward to use (or, well, I think that was the justification, but have now forgotten), but this project might find it to be worth it.
Thanks for the list! The validations that were implicit in the lexical grammar that must now be made explicit is a very important point.