-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Editorial: Remove unused steps from definitions of Contains #1519
Conversation
Such as introducing a new static semantic rule like "ContainsIdentifier" or somesuch? |
Yup, e.g. Or we might try to introduce a form that abstracts over this kind of ContainsFoo operation, so that defining a new one isn't too burdensome. |
Is Contains ever used with identifiers? If not, then it might be better to do the following:
It's currently unclear where Contains stops. Does it jump from the syntactic grammar to the lexical grammar? I hope it doesn't, but the spec is ambiguous. While doing the above it would be good to clarify how Contains deals with that boundary (and on which side of that boundary reserved words and IdentifierName lie) in the definition of Contains. |
The right-hand argument of Here are all the right-hand args:
Yeah, I think that would work (assuming the syntactic/lexical boundary isn't a problem, see below).
What do you mean by "reserved words not in IdentifierName"? It seems to me that there's no such thing. (That is, any sequence of characters that matches
I believe it doesn't (currently) matter. That is, for the cases in which it is currently used,
It seems to me that the spec prefers to avoid talking about that boundary. Which might be one reason that these rules stop the recursion one step away from it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the unused definitions lgtm. Though @jmdyck, what were your conclusions re: Waldemar's suggestions, that having them in the spec won't really help readability?
Having just read some about this, two relevant details: The syntactic grammar "has ECMAScript tokens defined by the lexical grammar as its terminal symbols".
In particular, per the first point IdentifierName is a terminal symbol of the syntactic grammar, not a nonterminal. Therefore, per the second point, Strictly speaking this means that we could remove the four productions currently touched by this PR without adding any new ones, since all terminals effectively have a default definition of "return false". However, I think this would be more confusing than the current PR. In other words, my reading is that the answer to @waldemarhorwat's question
is that it unambiguously does not jump to the lexical grammar (assuming my reading of the above two things are correct). And I don't really want to mess with that, so my preference is to stick with the current PR. |
... specifically, steps of the form: If _symbol_ is an |Identifier| and StringValue of _symbol_ is the same value as the StringValue of |IdentifierName|, return *true*. Resolves issue tc39#831. As @allenwb points out, the intended use case for such steps does not occur in the spec. And as I point out, these steps are semantically problematic. If the intended use case ever *does* occur, I'm guessing we'll find a different way to handle it.
... after previous commit. Specifically, when code says: ``` 1. If <something>, return *false*. 1. Return *false*. ``` we can drop the first step, because the result is `*false*` either way.
Except that it's definitely a nonterminal of the lexical grammar. So a given IdentifierName would seem to satisfy the condition in step 1.b ("child is an instance of a nonterminal"), suggesting that Contains would indeed recurse on it. However, the recursive invocation would in practice violate the 'assertion' that symbol "is a terminal or nonterminal of the grammar that includes the associated production". So it's unclear, and I think it would be a spec bug if we ever allowed it to happen (under the current formulation). (@syg, does that also answer your question?)
(Other than when they actually match the symbol being searched for.)
Yeah. (It might be possible to make that approach clearer, but that's not currently on offer!) |
Ah, I suppose that's fair. I read it to mean "a nonterminal of the grammar of which this production is a part", since one does not generally talk about nonterminals except in relation to a particular grammar. |
... specifically, steps of the form:
Resolves #831.
As @allenwb points out, the intended use case for such steps does not occur in the spec.
And as I point out, these steps are semantically problematic.
If the intended use case ever does occur, I suspect we'll find a different way to handle it.