-
-
Notifications
You must be signed in to change notification settings - Fork 397
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 Parser #268
Comments
Forgive me if this is a dumb question, but isn't there a chance for you to reuse a lot of what lightningcss does? As far as I know they use some rust crates written by Mozilla for Firefox, so it should be a very solid base... |
We did consider it. While doing some research we reached out to Devon, and he suggested to not use that crate (the Mozilla one) because it wouldn't fit our CST. I also created a PoC some time ago, and I can confirm that unfortunately that crate has some limitations for us. |
Oh… ok, that's a shame. So there is no prior art for you then, given your architecture? |
I'm going to return to this task the next monday🙃 |
- CssIdSelectorPattern - CssClassSelectorPattern - CssTypeSelectorPattern
Introduce new grama for selectors.
I've updated the issue to start parsing properties. |
I created #1359 to track implementing the CSS-wide keywords as tokens and making them invalid as custom identifiers. |
I've gotten part way through implementing some infrastructure to enable exact parsing of individual properties, but I'm realizing that it will require some changes to the parser itself to support checkpoint rewinding (similar to how the JS parser already works), since there's ambiguity about whether a parsed value is valid until reaching the end of the value definition (i.e., the I'll open an issue for tracking that work either later tonight or tomorrow. |
Could I start working on implementing the other properties in a matter similar to the border one or are you working on a better solution? |
I think that we want to keep property parsing as it is now. We want to have properties at a semantic level. |
@ematipico yeah, exactly but for the other properties like align, background etc. assuming the way its done in the border one is close to final, I could work on implementing it for the rest |
@Gami13 as Denis mentioned, after investigating with #1453 and discussing afterward, we are most likely going to keep the parser generic, just parsing component value lists for each property, and then have the analyzers do the actual semantic parsing to get the real values for each rule. There's just too much context and evaluation needed for this to be feasible in a parser, and it will be much easier with an evaluation engine in the analyzer as well. So, unfortunately, please ignore how the |
Hello, |
@denbezrukov I could take #1743 if it's possible. |
You can assign #1743 to me, and I'll take a look at it tomorrow. |
@bjoroen you have to comment on the issue, so we can assign that to you. That's how GitHub works |
Description
This is an umbrella issue to track the works of the CSS parser.
The lexer of the CSS parser should be ready, so now it's time to start working on the parser itself.
We should already have a basic syntax, although it's possible that some grammar or cases are not covered, so it's highly* suggested to always make sure we have to nodes to represent a specific grammar.
Resources:
Let's remember that Biome parser needs to be recoverable, so we have to consider invalid cases and ensure that the parser can recover itself and resume parsing in a fancy matter.
How to contribute
Before starting, please wait for us to implement the testing infrastructure. In the meantime, you can take a look at the JS parser and JSON parser to understand how the parsing works, the internal APIs, the recovery system, etc.
In this very issue, add a comment saying you want to work on a specific task(s). We will create the issue for you and eventually assign it to:
Note
In order to have the issue assigned to you, you must comment on the issue.,
Prior work
You can the previous Rome's (TS) implementation of the parser: https://github.com/rome/tools/blob/archived-js/internal/css-parser/parser/rules.ts
Before starting
CSS parser tasks
Parsing
at-rules
At-rules are very strict, and they have a determined syntax. Let us adhere to that.
@font-feature-values
#1743Ideas
... more to come
The text was updated successfully, but these errors were encountered: