Skip to content

Commit

Permalink
[css-mixins-1][css-values-5] Move the definition of <syntax> to V&U 5…
Browse files Browse the repository at this point in the history
…, since we'll be using it in multiple places.
  • Loading branch information
tabatkins committed Oct 15, 2024
1 parent fdd5d08 commit 45fc958
Showing 1 changed file with 1 addition and 88 deletions.
89 changes: 1 addition & 88 deletions css-mixins-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -585,91 +585,4 @@ Issue: Should we indeed use {{CSSNestedDeclarations}} for this purpose?
should probably not be a regular {{CSSStyleDeclaration}},
since only custom properties
and the '@function/result' descriptor
are relevant.

<!-- Big Text: appendix

███▌ ████▌ ████▌ █████▌ █ █▌ ████▌ ████ █ █
▐█ ▐█ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ ▐▌ █ █
█▌ █▌ █▌ █▌ █▌ █▌ █▌ ██▌ █▌ █▌ █▌ ▐▌ █ █
█▌ █▌ ████▌ ████▌ ████ █▌▐█ █▌ █▌ █▌ ▐▌ █
█████▌ █▌ █▌ █▌ █▌ ██▌ █▌ █▌ ▐▌ █ █
█▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ ▐▌ █ █
█▌ █▌ █▌ █▌ █████▌ █▌ ▐▌ ████▌ ████ █ █
-->

Appendix: The <<syntax>> Production {#syntax}
=============================================

The <<syntax>> production represents a [=syntax definition=],
which may be used to impose a type
on [=function parameters=],
[=function dependencies=],
or [=custom function=] return values.

<pre class="prod def" nohighlight>
<dfn><<syntax-type>></dfn> = angle | color | custom-ident | image | integer |
length | length-percentage | number |
percentage | resolution | string | time |
url | transform-function
<dfn><<syntax-combinator>></dfn> = '|'
<dfn><<syntax-multiplier>></dfn> = [ '#' | '+' ]
<dfn><<syntax-component-name>></dfn> = '<' <<syntax-type>> '>' | <<custom-ident>>
<dfn><<syntax-component>></dfn> = <<syntax-component-name>> <<syntax-multiplier>>? |
'<' transform-list '>'
<dfn><<syntax>></dfn> = '*' | <<syntax-component>> [ <<syntax-combinator>> <<syntax-component>> ]+
</pre>

A <<syntax-component>> consists of either a <<syntax-type>>,
which maps to one of the [=supported syntax component names=];
or a <<custom-ident>>, which represents any [=keyword=].
Additionally,
a <<syntax-component>> may contain a [[css-properties-values-api-1#multipliers|multiplier]],
which indicates a [=list=] of values.

Note: This means that <code>&lt;length&gt;</code>
and <code>length</code> are two different types:
the former describes a <<length>>,
whereas the latter describes a [=keyword=] <code>length</code>.

Multiple <<syntax-component>>s may be [[css-properties-values-api-1#combinator|combined]]
with a <code>|</code> <<delim-token>>,
causing the syntax components to be matched
against a value
in the specified order.

<div class='example'>
<xmp class='lang-css'>
<percentage> | <number> | auto
</xmp>

The above, when parsed as a <<syntax>>,
would accept <<percentage>> values,
<<number>> values,
as well as the keyword <code>auto</code>.
</div>

<div class='example'>
<xmp class='lang-css'>
red | <color>
</xmp>

The [=syntax definition=] resulting from the above <<syntax>>,
when used as a grammar for [=parse|parsing=],
would match an input <code>red</code> as an [=identifier=],
but would match an input <code>blue</code> as a <<color>>.
</div>

The <code>*</code> <<delim-token>> represents the [=universal syntax definition=].

The <code>&lt;transform-list&gt;</code> production
is a convenience form equivalent to <code>&lt;transform-function&gt;+</code>.
<span class=note>Note that <code>&lt;transform-list&gt;</code> may not
be followed by a <<syntax-multiplier>>.</span>

[=Whitespace=] is not allowed
between the angle bracket <<delim-token>>s (<code>&lt;</code> <code>&gt;</code>)
and the <<syntax-type>> they enclose,
nor is [=whitespace=] allowed to precede a <<syntax-multiplier>>.

Note: The [=whitespace=] restrictions also apply to <code>&lt;transform-list&gt;</code>.
are relevant.

0 comments on commit 45fc958

Please sign in to comment.