Q1:
This part:
“However, the final character must not be a hyphen, nor may the name contain two or more consecutive hyphens. For example, “foo” or “a-bb8-c” are valid package names, while “bar-”, “-baz”, or “ab–ba” are not. Case is significant, so “foo” and “Foo” are considered to be different package names.”
States that the final char must not be a hyphen and contains the example “-baz” as an invalid package name, however:
“Some whitespace is required between a keyword and an immediately following alphanumeric character or hyphen.”
States that the first char can be a hyphen.
There are two ways that I can interpret this:
1. Package names that starts with a hyphen is allowed.
2. Package names that starts with a hyphen is not allowed, but a comment after a keyword is allowed.
Is any of these the correct interpretation of the text?
答疑:
is the correct interpretation. I don’t think you can read anything in the text as supporting (1), especially since it is explicitly stated both that a (simple) package name must start with a letter, and that -baz is not allowed. However, as already noted in this thread, the final “or hyphen” in the last sentence you quote is unnecessary and confusing, and you should just just ignore it.
这里提到的this thread见Q2
Q2:
Hi,
I have some questions about the grammar specification.
I’m unsure how to parse
package {
name ab–comment
version 1–comment 2
}
The exam says
1) “nor may the name contain two or more consecutive hyphens.”
but it also says
2) “A comment counts as whitespace for
the purpose of token separation.”
So I am sure that the version clause is legal, but the name clause can be interpreted as illegal (due to rule 1) or as legal (with package name ab) due to rule 2.
Which one is it?
Also, the exam text says
3) “Some whitespace is required between a keyword and an immediately following alphanumeric character or hyphen.”
However (comments excluded, see rule 2), I do not see a possibility of a keyword which is immediately followed by a hyphen.
So, are we to accept
package–comment
{
}
or is this illegal per rule 3?
答疑:
Your first example doesn’t parse, because there is no semicolon between the two clauses. But if you add one, there is exactly one possible parse, namely with the name taken as “ab”. Without restriction (1) on name, there would be an ambiguity, as it would then also be possible to parse the example as specifying a package with name “ab–comment”.
Rule (2) just serves to say that, e.g.,
package {
name– comment
foo
}
is well formed, even though “name” is not immediately followed by an “ordinary” whitespace character.
As for (3), the intended meaning was that, with more keywords added to the grammar, they could potentially also contain digits and/or hyphens (e.g., a “build-date” keyword), according to the same rules as simple names; but since none of the (current) nonterminals can start with a hyphen, there actually is no potential ambiguity. So you can just ignore the final “or hyphen” in (3), meaning that your last example would be syntactically OK (and also semantically, if you add a suitable “name” clause).
Q3:
问 type of the exported functions是否可以change?
答疑:
No, you should never change the type of the exported functions from what is in the skeleton files.
Q4:
What should merge return in the case of
(True, 2, 8) and (True, 4, 6)?
(False, 2, 8) and (False, 4, 6)?
I can’t seem to figure it out from the description?
答疑:
Assuming all of these constraints are about the same package name, the first call should return (True, 4, 6), and the second, (False, 4, 6). In both cases, the first argument represents a strictly weaker constraint on the package than the second.
学生问:
So if I understand this right
(True, 6, 8) and (True, 4, 6) would return (True, 6, 6) which in turn should give me a Nothing?
答疑:Correct.
(False, 6, 8) and (False, 4, 6) also return Nothing,Since the conjoined constraints in that case are satisfiable (by simply not installing the package in question), then no, it would not be correct to return Nothing here.
(False, 4, 6) means:”conflicting with any version strictly less than 4, and anything greater than or equal to 6″. That is, 4 is allowed,but 6 is not.
Q5:
“d. For any package in the list, all the packages it requires are also in the list.”
Does this only refer to the name or also the version number?
If the list includes a package that requires “foo” with version less than 3, and the list contains “foo” with version 5, is d satisfied? (assuming all other requirements are satisfied)
I’m thinking it is satisfied, because e is about version, but I don’t think it’s clear.
答疑:
In your example, (d) alone is satisfied, but (e) is not. This doesn’t really matter for implementing the solver (because its output must satisfy both criteria anyway), but it does simplify the definition of property `install_d` in Q1.4 a bit.