Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upEditorial: <5.1.5 Grammar Notation> production parameterization example mistakes? #255
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Dec 16, 2015
Member
The spec is correct. To start, note that
ExpressionStatement[In] :
...
is equivalent to two productions:
ExpressionStatement:
...
ExpressionStatement_In:
...
When a non-terminal is on the RHS, it must refer unambiguously to one of those productions. It does so using the following conventions:
// assume we have an in param here, which doesn't actually exist.
StatementList[In] :
ExpressionStatement[In] // equivalent to ExpressionStatement_In
ExpressionStatement[?In] // Refers to ExpressionStatement_In if In is passed to StatementList, otherwise ExpressionStatement
You are right that ExpressionStatement doesn't take an In parameter. The example is illustrative only, but if you want to dig out a better example from somewhere in the grammar I'd happily accept it!
|
The spec is correct. To start, note that
is equivalent to two productions:
When a non-terminal is on the RHS, it must refer unambiguously to one of those productions. It does so using the following conventions:
You are right that ExpressionStatement doesn't take an In parameter. The example is illustrative only, but if you want to dig out a better example from somewhere in the grammar I'd happily accept it! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmm
Dec 16, 2015
Contributor
Thanks @bterlson! Sorry for the noise.
:
ExpressionStatement[In] // equivalent to ExpressionStatement_In
That's a bit counterintuitive to me, but I believe I get it now: the point of parameterizing the RHS is to be able to use the notation Whatever[A, B] instead of needing 2 separate lines (literal symbols), and I assume it's favored even in the single-parameter case (like the example) because that way the notation looks the same as when the symbol is the LHS of a production.
Would you be open to the prose spelling that out a bit more? If I'm the only one that had a hard time with this, I digress.
You are right that ExpressionStatement doesn't take an In parameter. The example is illustrative only, but if you want to dig out a better example from somewhere in the grammar I'd happily accept it!
I like:
ExportDeclaration :
export default HoistableDeclaration[Default]
It's a case with no parameter on LHS and only a single parameter on RHS, like the current illustration. And if you understand the semantics it also helps to illustrate that the parameter only "expands" to a single symbol.
If that sounds good I could try a PR -- it seems the build script runs for me now.
|
Thanks @bterlson! Sorry for the noise.
That's a bit counterintuitive to me, but I believe I get it now: the point of parameterizing the RHS is to be able to use the notation Would you be open to the prose spelling that out a bit more? If I'm the only one that had a hard time with this, I digress.
I like:
It's a case with no parameter on LHS and only a single parameter on RHS, like the current illustration. And if you understand the semantics it also helps to illustrate that the parameter only "expands" to a single symbol. If that sounds good I could try a PR -- it seems the build script runs for me now. |
bterlson
added
the
editorial change
label
Feb 18, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@jmm are you interested in making a PR for this? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Mar 21, 2018
Collaborator
(Note that the notation has changed slightly since this issue was raised.)
(Also, HoistableDeclaration now takes 3 parameters.)
|
(Note that the notation has changed slightly since this issue was raised.) (Also, HoistableDeclaration now takes 3 parameters.) |
jmm commentedDec 15, 2015
In the examples for parameterizing a nonterminal on the right-hand side in the ES2015 spec, I think there are a couple of mistakes, but perhaps I'm misunderstanding something.
:
Isn't that actually equivalent to this?:
:
Isn't that actually an abbreviation for?:
If this is correct I might be able to PR it later, but I got an error when I tried to build and haven't debugged it.
Also, I don't actually see
ExpressionStatement[In]in the grammar -- if that's correct it'd be better to use a real example, right?