EDIT (May 18, 2020): I learned about some overlapping projects and expanded the scope of the package such that it can host different CSS specification modules. The repository is now named
I'm wrapping up the first draft of a new Racket package called
css3-syntax. It tracks the W3C's CSS
Syntax Module (Level 3) specification. Over the last couple of days I put together a tokenizer and parser according to sections 4 and 5, with error recovery logic.
Anyone who has every implemented a CSS parser before knows that I can't possibly be done in two days. A “baby” parser derived from §5 only understands the fundamental contents of qualified rules and at-rules. It does not understand selectors or the validity of expressions like
calc(100% - 2px).
That being said, the parser and tokenizer are fundamental pieces of a much larger system. They also aid coarse transformations from one CSS file to another. I'm releasing the package now so that anyone reading this can report bugs in the issue tracker. This is a good time to iron issues out before moving on to logic that isn't so close to the core.
For the purposes of this package, I want to at least implement §9 before actually using the parser in other projects. §9 extends the §5 parser to produce more meaningful nodes. This spans more than just the W3C's Syntax Module, since it introduces new grammar and semantics. I have not yet decided if the use of new W3C modules implies creating new Racket packages. I suspect that might be doable, but it would probably end in me releasing yet another package that just provides convenience functions from the others.
Ideally, feature development work on
css3-syntax will end when it provides bindings relevant to the entire spec. I do not have a timeline for this, but I am currently active on the project.