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 74e62b5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
25 changes: 25 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,30 @@ 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`

<x><pre>
**FunctionExpression**¹ ::= [CssMinMax]
&#32; | SpecialFunctionExpression
&#32; | [CalculationExpression]
&#32; | FunctionCall
**FunctionCall** ::= FunctionName FunctionArguments ')'
**FunctionName**² ::= [NamespacedIdentifier] '('
</pre></x>

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

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

2: `FunctionName` may not contain any whitespace, may not match
[`SpecialFunctionName`], and may not be case-insensitively equal to `'calc('`
or `'clamp('`.

[`SpecialFunctionName`]: #specialfunctionexpression

### `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 74e62b5

Please sign in to comment.