Skip to content
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

[css-syntax] Concrete criteria for rule / declaration validity when being produced by a [compliant] parser? #10359

Closed
amn opened this issue May 22, 2024 · 4 comments
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-syntax-3

Comments

@amn
Copy link

amn commented May 22, 2024

parse-css implements certain criteria for determining if a rule is valid: https://github.com/tabatkins/parse-css/blob/c7859c41887409c533beed36956b7976ea0144b4/parse-css.js#L1142-L1167

Since the former was ostensibly written to verify the "soundness" of the current [CSS Syntax] draft, and because I don't see any of the implemented criteria specified in the draft, am I to understand these are specified in other CSS compendiums? A different module, perhaps?

If so, could one say that all CSS rules and declarations are syntactically valid as parsed? I am trying to assess how viable/useful it would be for a more general CSS parser to consider so, at the cost of qualified rules in the parse tree with e.g. a semi-colon (;) in their prelude, among other peculiarities.

@amn amn changed the title [css-syntax] Concrete criteria for rule / declaration validity? [css-syntax] Concrete criteria for rule / declaration validity when being produced by a [compliant] parser? May 22, 2024
@tabatkins
Copy link
Member

Yes, the rest of CSS beyond the Syntax spec has the actual grammar definitions of all the rules and declarations. What's in parse-css is a super generic notion of "validity" sufficient to differentiate between qualified rules and declarations when consuming a block's contents.

Of those checks in parse-css, the semicolon check isn't even strictly necessary for that purpose; it's just strictly guaranteed that such a construct will always be invalid in CSS because it's a rule that cannot, by definition, ever be nested, so we will never design a qualified rule that allows a top-level semicolon in its prelude (and no other language hosted on CSS syntax should, either).

The {}-block check for declarations is also slightly stronger than necessary - per Syntax, a non-custom property is allowed to have a {}-block as its entire value, and the parse-css check disallows that. I should probably fix that.

@tabatkins
Copy link
Member

(Really, parse-css is slightly behind the spec at the moment.)

@amn
Copy link
Author

amn commented May 25, 2024

Thank you for the informative reply, that clarifies it.

@MrHBS
Copy link
Contributor

MrHBS commented May 26, 2024

I am assuming this issue can be closed then?

@tabatkins tabatkins added css-syntax-3 Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. labels May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-syntax-3
Projects
None yet
Development

No branches or pull requests

3 participants