Skip to content

Commit

Permalink
Explicitly define FunctionExpression
Browse files Browse the repository at this point in the history
This sets the stage for modifying it to fix #3245
  • Loading branch information
nex3 committed Jun 16, 2022
1 parent 2a0c99b commit 5e1ddbc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
22 changes: 22 additions & 0 deletions spec/functions.md
Expand Up @@ -44,6 +44,28 @@ matching is case-insensitive.
## Syntax

<x><pre>
**FunctionExpression**¹ ::= [CssMinMax]
&#32; | [SpecialFunctionExpression]
&#32; | [CalculationExpression]
&#32; | FunctionCall
**FunctionCall**² ::= [NamespacedIdentifier] ArgumentInvocation
</pre></x>

[CssMinMax]: types/calculation.md#cssminmax
[SpecialFunctionExpression]: syntax.md#specialfunctionexpression
[CalculationExpression]: types/calculation.md#calculationexpression
[NamespacedIdentifier]: modules.md#syntax

1: If both `CssMinMax` and `FunctionCall` could be consumed, `CssMinMax`
takes precedence.

2: `FunctionCall` may not have any whitespace between the `NamespacedIdentifier`
and the `ArgumentInvocation`. It may not start with [`SpecialFunctionName`],
`'calc('`, or `'clamp('` (case-insensitively).

[`SpecialFunctionName`]: #specialfunctionexpression

<x><pre>
**FunctionCall** ::= [NamespacedIdentifier][] ArgumentInvocation
</pre></x>
Expand Down
3 changes: 3 additions & 0 deletions spec/syntax.md
Expand Up @@ -9,6 +9,7 @@
* [`InterpolatedIdentifier`](#interpolatedidentifier)
* [`InterpolatedUrl`](#interpolatedurl)
* [`Name`](#name)
* [`FunctionExpression`](#functionexpression)
* [`SpecialFunctionExpression`](#specialfunctionexpression)
* [`PseudoSelector`](#pseudoselector)
* [Procedures](#procedures)
Expand Down Expand Up @@ -71,6 +72,8 @@ No whitespace is allowed between components of an `InterpolatedUnquotedUrlConten
[identifier code point]: https://drafts.csswg.org/css-syntax-3/#identifier-code-point
[escape]: https://drafts.csswg.org/css-syntax-3/#escape-diagram

### `FunctionExpression`

### `SpecialFunctionExpression`

> These functions are "special" in the sense that their arguments don't use the
Expand Down
18 changes: 5 additions & 13 deletions spec/types/calculation.md
Expand Up @@ -4,7 +4,7 @@

* [Syntax](#syntax)
* [`CalculationExpression`](#calculationexpression)
* [`MinMaxExpression`](#minmaxexpression)
* [`CssMinMax`](#cssminmax)
* [Types](#types)
* [Operations](#operations)
* [Equality](#equality)
Expand All @@ -18,7 +18,7 @@
* [Semantics](#semantics)
* [`CalcExpression`](#calcexpression)
* [`ClampExpression`](#clampexpression)
* [`CssMinMax`](#cssminmax)
* [`CssMinMax`](#cssminmax-1)
* [`CalcArgument`](#calcargument)
* [`CalcSum`](#calcsum)
* [`CalcProduct`](#calcproduct)
Expand Down Expand Up @@ -73,21 +73,13 @@ case-insensitively.
> expression regardless of syntax, for full compatibility it's necessary to
> parse it very expansively.
### `MinMaxExpression`

This production is parsed in a SassScript context when an expression is expected
and the input stream starts with an identifier with value `min` or `max`
(ignoring case) followed immediately by `(`.
### `CssMinMax`

<x><pre>
**MinMaxExpression**¹ ::= CssMinMax | FunctionExpression
**CssMinMax** ::= ('min(' | 'max(')² CalcArgument (',' CalcArgument)* ')'
**CssMinMax** ::= ('min(' | 'max(')¹ CalcArgument (',' CalcArgument)* ')'
</pre></x>

1: If both `CssMinMax` and `FunctionExpression` could be consumed, `CssMinMax`
takes precedence.

2: The strings `min(` and `max(` are matched case-insensitively.
1: The strings `min(` and `max(` are matched case-insensitively.

## Types

Expand Down

0 comments on commit 5e1ddbc

Please sign in to comment.