Commit c428a0b
## Summary
This PR adds support for parsing dotted layer names (e.g., `a.b.c`) in
CSS `@layer` at-rule prelude declarations, allowing nested layer
references to be properly recognized and preserved.
## Key Changes
- **Enhanced layer name parsing**: Modified `parse_layer_names()` to
recognize and preserve dotted notation in layer names by consuming
consecutive `.` and `<ident>` tokens that immediately follow the initial
identifier with no whitespace gaps
- **Whitespace sensitivity**: Implemented strict position checking to
ensure dots separated by whitespace are not glued to layer names (e.g.,
`a. b` parses as two separate names)
- **Token imports**: Added `TOKEN_DELIM` import to support dot token
detection
- **String utilities**: Added `CHAR_PERIOD` constant for dot character
code comparison
- **Comprehensive test coverage**: Added four new test cases covering:
- Dotted layer names mixed with simple names in comma-separated lists
- Deeply nested dotted layer names (e.g., `d.e.f`)
- Whitespace-separated dots not being attached to names
- Improved assertion specificity for existing dotted layer name test
## Implementation Details
The parser now uses a lookahead mechanism with position save/restore to
safely attempt consuming dot-identifier segments. It validates that:
1. The next token is a `TOKEN_DELIM` with character code matching
`CHAR_PERIOD`
2. The dot immediately follows the previous token (no whitespace gap)
3. An identifier immediately follows the dot (no whitespace gap)
If any condition fails, the parser restores the previous position and
stops consuming segments, allowing the comma separator or end of prelude
to be processed normally.
https://claude.ai/code/session_01R9GWUSxhM3VVAWVFs9F5bG
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4fe1f0a commit c428a0b
2 files changed
Lines changed: 77 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
976 | 976 | | |
977 | 977 | | |
978 | 978 | | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
979 | 996 | | |
980 | 997 | | |
981 | 998 | | |
| |||
1969 | 1986 | | |
1970 | 1987 | | |
1971 | 1988 | | |
1972 | | - | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
1973 | 2015 | | |
1974 | 2016 | | |
1975 | 2017 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
553 | 555 | | |
554 | 556 | | |
555 | 557 | | |
| 558 | + | |
| 559 | + | |
556 | 560 | | |
557 | 561 | | |
558 | 562 | | |
| |||
564 | 568 | | |
565 | 569 | | |
566 | 570 | | |
567 | | - | |
568 | | - | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
569 | 600 | | |
570 | | - | |
| 601 | + | |
571 | 602 | | |
572 | 603 | | |
573 | 604 | | |
| |||
0 commit comments