v11 spec-first playground: Pratt parser + §10.10 simplifier#240
Draft
dkryaklin wants to merge 1 commit intopostcss:masterfrom
Draft
v11 spec-first playground: Pratt parser + §10.10 simplifier#240dkryaklin wants to merge 1 commit intopostcss:masterfrom
dkryaklin wants to merge 1 commit intopostcss:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A decoupled prototype of new calc() internals under
playground/pratt/Why
v10 uses a JISON-generated LR parser and an ad-hoc reducer. It doesn't cover
min()/max()/clamp(), typed division (calc(100vw / 1px)), or calc-keyword folding (pi,e,infinity). CSS Values & Units 4 §10 gives a deterministic simplification algorithm — implementing it directly makes correctness reviewable section-by-section rather than invented-and-patched.How
Five TS modules, each mapped one-to-one to a spec section:
tokenizer.ts— §10.1 tokensparser.ts— §10.1 grammar (Pratt + parselet registry)type.ts— §10.2 calculation typessimplify.ts— §10.10 simplificationserialize.ts— §10.12 output169 tests (parser / tokenizer / simplify / typed / opaque / serialize / WPT crib), run via
pnpm test:pratt.tsxruntime, no build step.See
ROADMAP.mdfor more details