Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grammar quirks #34

Open
bakkot opened this issue May 16, 2018 · 1 comment
Open

Grammar quirks #34

bakkot opened this issue May 16, 2018 · 1 comment

Comments

@bakkot
Copy link

bakkot commented May 16, 2018

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 Normative: Allow initializers in ForInStatement heads ecma262#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 an if with an else as the body of an if without an else, even though the tree types can represent that. You also have to make sure that Identifiers 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 Expressions and TemplateElements. 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.

@syg
Copy link
Collaborator

syg commented May 16, 2018

Thanks for the list! The validations that were implicit in the lexical grammar that must now be made explicit is a very important point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants