tc39 / proposal-binary-ast

Binary AST proposal for ECMAScript
965 stars 23 forks source link

Could the AST be based on a reduced subset of productions? #74

Open dead-claudia opened 5 years ago

dead-claudia commented 5 years ago

I'm reflecting back on the AST and the overzealous #37 and thinking I could probably narrow it down a bit further. JS has a lot of cases where there's multiple ways to do things and it semantically makes no difference even in the general case:

There's also a few cases where the spec ends up complicating encoding if followed to the letter.

So I'm thinking the AST could be reduced to a smaller, significantly more easily parsed and consumed subset so engines can realize parsing gains much quicker.

Of course there's ways to further reduce this (reducing block labels to break depth), but most of that's beyond the scope of this bug. I'm just looking at stuff that still mirrors JS while removing the duplication.

dead-claudia commented 5 years ago

BTW, to clarify, the intent isn't to extend, but just to simplify and compress. There's only two things I added:

These two added could really be considered replacements for let/const and void, respectively, and don't really add anything that wouldn't have existed before.