You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/parse/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -137,7 +137,7 @@ Each *parse* procedure from CSS Syntax is named a *parser entry point* and runs
137
137
>
138
138
> [...]
139
139
140
-
Entry points can receive a string, tokens, or component values, and output the expected structure: a component value, a declaration, a rule, or a list of them. They are not intended to be used at an intermediate step of the recursive parsing process, since some algorithms output high-level objects that are not a string, tokens, or component values.
140
+
Entry points can receive a string, tokens, or component values, and output the expected structure: a component value, a declaration, a rule, or a list of them. They are not intended to be used at an intermediate step of the recursive parse process, since some algorithms output high-level objects that are not a string, tokens, or component values.
141
141
142
142
Algorithms for a rule and a declaration require validating them in the context against their grammar:
Copy file name to clipboardExpand all lines: doc/parse/value-data-structure.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,22 +9,22 @@ Consuming the input into tokens is the first parse step before consuming tokens
9
9
10
10
A token represents either:
11
11
12
-
- a delimiter (a single code point, `<--`, or `-->`)
13
12
- a numeric
14
13
- an identifier (possibly prefixed with `#` or `@`)
15
14
- a string (wrapped between `"` or `'`)
16
15
- a specific sequence of code points (`<function-token>`, `<url-token>`, `<unicode-range-token>`)
16
+
- a delimiter (a single code point, `<--`, or `-->`)
17
17
18
18
A token is defined in CSS Syntax with the following properties:
19
19
20
20
-`value`: a `Number` for numeric tokens, otherwise a `String`
21
-
-`sign`: a `String` only for `<number-token>`, `<dimension-token>`, `<percentage-token>`
21
+
-`sign`: a `String`, only for `<number-token>`, `<dimension-token>`, `<percentage-token>`
22
22
-`type`: a `String`, only for `<hash-token>`, `<number-token>`, `<dimension-token>`
23
23
-`unit`: a `String`, only for `<dimension-token>`
24
24
25
-
A component value is the same object than the consumed token, except a function or simple block, whose `value` is a list of component values. A function also has a `name` and a simple block has an `associatedToken`, which are both `String`.
25
+
Except for functions and simple blocks, a component value is the same object than the consumed token: a preserved token. The `value` of functions and simple blocks is a list of component values. A function also has a `name` and a simple block has an `associatedToken`, which are both `String`.
26
26
27
-
A component value must expose its token type in order to be matched against a token production. Some production rules include token productions:
27
+
A preserved token must expose its type in order to be matched against a token production. Some production rules directly include a token type:
28
28
29
29
-`<function-token>`
30
30
-`<general-enclosed>`
@@ -42,20 +42,20 @@ A component value must expose its token type in order to be matched against a to
42
42
-`<string-token>`
43
43
-`<attribute-selector>`
44
44
45
-
**[Issue](https://github.com/w3c/csswg-drafts/issues/7016):**`<function-token>` cannot be matched because because any CSS input goes through *consume a component value* before grammar validation.
45
+
**[Issue](https://github.com/w3c/csswg-drafts/issues/7016):**`<function-token>` cannot be matched because any CSS input goes through *consume a component value* before grammar validation.
46
46
47
-
A component value must expose its matched CSS type(s) in hierarchical order, to apply any associated parsing and serialization rule. For example, a component value matching `<percentage>` and `<alpha-value>` must serialize as a `<number>` to the shortest possible form, therefore `<alpha-value>` must be read before `<percentage>`.
47
+
A component value must expose its matched CSS type(s) in parse order, to apply any associated parsing and serialization rule. For example, a component value matching `<percentage>` and `<alpha-value>` must serialize as a `<number>` to the shortest possible form rather than as a `<percentage>`, therefore `<alpha-value>` must be read before `<percentage>`.
48
48
49
49
---
50
50
51
51
All component values are represented as plain objects exposing token and CSS types with a `types` property, rather than using classes (eg. `CSSNumber`, `CSSDimension`, etc) or separate properties (eg. `tokenType` and `cssTypes`).
52
52
53
-
A `<percentage-token>` can also be considered as a dimension (cf. [#7381](https://github.com/w3c/csswg-drafts/issues/7381)), therefore it also has `unit`, to simplify parsing and serializing.
53
+
A `<percentage-token>` can also be considered as a dimension (cf. [#7381](https://github.com/w3c/csswg-drafts/issues/7381)), therefore it is also implemented with a `unit` property, to simplify parsing and serializing.
54
54
55
55
In CSS Syntax:
56
56
57
57
-`<number-token>` and `<dimension-token>` are defined with a `type` that is either `integer` or `number`
58
-
-`<*-integer>` and `<*-dimension>`(produced by `<an+b>`) match `<number-token>` and `<dimension-token>` whose `type` is `integer`
58
+
-`<*-integer>` and `<*-dimension>` produced by `<an+b>` match `<number-token>` and `<dimension-token>` whose `type` is `integer`
59
59
-`type` is `number` when the value is specified with `.` or the scientific notation (even `1.0` or `1e1`)
60
60
61
61
In this library, `<number-token>` and `<dimension-token>` do not have `type` and `<integer>`, `<*-integer>`, `<*-dimension>`, match a corresponding token whose `value` is an integer, which means `nth-child(1e1)` or `nth-child(1e1n)` should be discarded.
@@ -64,4 +64,4 @@ In this library, `<number-token>` and `<dimension-token>` do not have `type` and
64
64
65
65
A declaration is represented as a plain object with `types` including `<declaration>`, in order to be serialized when it appears in a list of component values (the prelude of `@supports`).
66
66
67
-
A rule is initially represented as a plain object with `types` including `rule`, either `at-rule` or `qualified-rule`, and an identifier prefixed with `@` that usually corresponds to the rule name. Then it is represented as an instance of a `CSSRule` subclass with an internal `types`.
67
+
A rule and a style sheet are directly represented as a CSSOM object.
0 commit comments