@@ -863,10 +863,22 @@ <h4 id=the-calc-min-and-max-functions><span class=secno>6.3.3. </span>The
863863min : "min(" S* sum [ "," S* sum ]* )"" S*;
864864max : "max(" S* sum [ "," S* sum ]* ")" S*;
865865sum : product [ [ "+" | "-" ] S* product ]*;
866+ product : unit [[ "*" S* unit ] | [ "/" S* NUMBER ]] *;
867+ unit : ["+"|"-"]? [ NUMBER S* | DIMENSION S* | PERCENTAGE S* |
868+ min | max | "(" S* sum ")" S* ];
869+ </ pre >
870+ <!--
871+ <pre>
872+ S : calc | min | max;
873+ calc : "calc(" S* sum ")" S*;
874+ min : "min(" S* sum [ "," S* sum ]* )"" S*;
875+ max : "max(" S* sum [ "," S* sum ]* ")" S*;
876+ sum : product [ [ "+" | "-" ] S* product ]*;
866877product : unit [ [ "*" | "/" | "mod" ] S* unit ]*;
867878unit : ["+"|"-"]? [ NUMBER S* | DIMENSION S* | PERCENTAGE S* |
868879 min | max | "(" S* sum ")" S* ];
869880</pre>
881+ -->
870882
871883 < p > The semantic constraints are as follows: The context of the expression
872884 imposes a target type, which is one of length, frequency, angle, time, or
@@ -886,73 +898,9 @@ <h4 id=the-calc-min-and-max-functions><span class=secno>6.3.3. </span>The
886898 check: at least one side is "number" return: the type of the other side
887899
888900 < li > At "/":< br >
889- check: either right side is "number," or both have the same type< br >
890- return: if the former, type of left side; otherwise "number"
891-
892- < li > At "mod": < br >
893- check: both sides have the same type< br >
894- return: "number"
901+ check: right side is "number"< br >
902+ return: the type of the left side
895903 </ ol >
896- <!--
897- <p>A value is ignored if a division by zero or other mathematical
898- errors occur in the calculation.
899-
900- <div class="example">
901- <p>In this example, the second declaration will be ignored due to a
902- division by zero.
903- <pre>
904- p {
905- margin: 1em;
906- margin: calc(1em-2px) calc(1em/0)
907- }
908- </pre>
909- </div>
910-
911- <p class=issue>Issue: At a later date new operators such as min/max, conditionals, new constants, division by length units etc. may be added.
912-
913-
914- <p>The expression language is defined by ‘<code class=property>length-expression</code>’ below:
915-
916- <pre>
917- <length> := calc( <length-expression> ) | <atomic-length>
918-
919- <length-expression> := S* <length-additive-expression> S*
920-
921- <length-additive-expression> :=
922- <length-multiplicative-expression> |
923- <length-additive-expression> S+ '+' S+ <length-multiplicative-expression> |
924- <length-additive-expression> S+ '-' S+ <length-multiplicative-expression>
925-
926- <length-multiplicative-expression>
927- <length-term> |
928- <length-multiplicative-expression> S* '*' S* <number-term> |
929- <number-multiplicative-expression> S* '*' S* <length-term> |
930- <length-multiplicative-expression> S* '/' S* <number-term> |
931- <length-multiplicative-expression> S+ 'mod' S+ <number-term>
932-
933- <length-term> := '(' <length-expression> ')' | <atomic-length>
934-
935- <number-additive-expression> :=
936- <number-multiplicative-expression> |
937- <number-additive-expression> S+ '+' S+ <number-multiplicative-expression> |
938- <number-additive-expression> S+ '-' S+ <number-multiplicative-expression>
939-
940- <number-multiplicative-expression> :=
941- <number-term> |
942- <length-multiplicative-expression> S* '/' S* <length-term> |
943- <length-multiplicative-expression> S+ 'mod' S+ <length-term>
944-
945- <number-term> := '(' *S <number-additive-expression> *S ')' | <number>
946-
947- <atomic-length> := <number><length-unit>
948- </pre>
949-
950- <div class="note">Note that ‘<code class=property>mod</code>’ is used instead of ‘<code class=css>%</code>’ for modulus since it is very easy to
951- get confused about whether ‘<code class=css>%</code>’ is acting as a unit or an operator. At
952- least with ‘<code class=property>mod</code>’ it always causes a parse error — invalid unit — in the
953- otherwise ambiguous cases.
954- </div>
955- -->
956904
957905 < h3 id =ltstringgt > < span class =secno > 6.4. </ span > <string></ h3 >
958906
0 commit comments