-
Notifications
You must be signed in to change notification settings - Fork 44
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
Should the processing model care about validity? #221
Comments
Hmm, are you suggesting to remove the grammar definitions and rely on the parsing and processing steps to handle errors? That makes sense to me, though personally I'd find the grammar useful so readers can tell at a glance how to construct valid text directives (or other fragment directives); maybe keep that as a non-normative reference? |
Yeah, I think a dual nature makes sense. One to guide producers and the other to guide consumers. URL and the HTML syntax also have this dual nature. |
One additional point, I see that for |
Usually the problem is that implementers don't use grammars in their implementation so you get subtle differences. I've found a lot of these over the years in HTTP header parsers. They also had quite a bit of complexity when a string iterator can do the job as well. |
Yeah, that's true, but then I have a bit of a meta question about spec writing :) ...I recently came across this note in parallelism:
How do we balance this vs. writing steps that match implementation? Blink also doesn't use a grammar for this case but this seemed like the best way to convey the requirements in spec; implementors can validate however they choose but the spec wins in case of any deviations (does HTML follow something similar to C++'s as-if rule?). Is this typically a judgement call, with preference to match implementation? As another example, the core find a range algorithm in this spec no longer mechanically matches what Blink does (though the output should be the same). Blink rearranged the steps to enable asynchronous execution but it's much harder to understand than the spec steps. Presumably that's reasonable (and common?) |
Yeah, see https://infra.spec.whatwg.org/#algorithm-conformance for a description of that rule in standards land. (I had not seen the C++ rule before today though and there may well be differences.) In my experience implementers prefer a set of steps over a grammar. And a set of steps tends to lead towards better tests and more interoperable implementations. But yes, ultimately it's a bit of a judgment call and people might have different preferences. Now we already have algorithms for splitting on code points and such written down so I think for the case at hand here building on that would be very straightforward. As for "find a range", I think it works because the invocation is rather hand-wavy. Though I have not studied |
This commit overhauls the parsing steps to avoid using the EBNF grammar for validity, instead specifying that imperatively. It also moves parsing to happen earlier in the process so that we pass around parsed Text Directive objects. Also makes the steps more precise, referring to infra types and correctly decoding the strings. Fixes WICG#221 Fixes WICG#230
This commit overhauls the parsing steps to avoid using the EBNF grammar for validity, instead specifying that imperatively. It also moves parsing to happen earlier in the process so that we pass around parsed Text Directive objects. Also makes the steps more precise, referring to infra types and correctly decoding the strings. Fixes WICG#221 Fixes WICG#230
* Specify parsing imperatively This commit overhauls the parsing steps to avoid using the EBNF grammar for validity, instead specifying that imperatively. It also moves parsing to happen earlier in the process so that we pass around parsed Text Directive objects. Also makes the steps more precise, referring to infra types and correctly decoding the strings. Fixes #221 Fixes #230 * Fix and make grammar non-normative The grammar is now provided solely as a convenience so this makes the section non-normative. Also fixes it so that UnknownDirective doesn't subsume TextDirective. Fixes #220
It currently has
but can that actually happen? It seems better if we don't need these additional grammar-based validation requirements.
The text was updated successfully, but these errors were encountered: