Skip to content

Commit c235348

Browse files
committed
removed mod operator, restricted / operator
1 parent 94d0b5f commit c235348

1 file changed

Lines changed: 16 additions & 66 deletions

File tree

css3-values/Overview.src.html

Lines changed: 16 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,18 @@ <h4>The 'calc', 'min' and 'max' functions</h4>
518518
<p>The expression language of these functions is described by
519519
the grammar and prose below.
520520

521+
<pre>
522+
S : calc | min | max;
523+
calc : "calc(" S* sum ")" S*;
524+
min : "min(" S* sum [ "," S* sum ]* )"" S*;
525+
max : "max(" S* sum [ "," S* sum ]* ")" S*;
526+
sum : product [ [ "+" | "-" ] S* product ]*;
527+
product : unit [[ "*" S* unit ] | [ "/" S* NUMBER ]] *;
528+
unit : ["+"|"-"]? [ NUMBER S* | DIMENSION S* | PERCENTAGE S* |
529+
min | max | "(" S* sum ")" S* ];
530+
</pre>
531+
532+
<!--
521533
<pre>
522534
S : calc | min | max;
523535
calc : "calc(" S* sum ")" S*;
@@ -528,6 +540,8 @@ <h4>The 'calc', 'min' and 'max' functions</h4>
528540
unit : ["+"|"-"]? [ NUMBER S* | DIMENSION S* | PERCENTAGE S* |
529541
min | max | "(" S* sum ")" S* ];
530542
</pre>
543+
-->
544+
531545

532546
<p>The semantic constraints are as follows: The context of the
533547
expression imposes a target type, which is one of length, frequency,
@@ -546,75 +560,11 @@ <h4>The 'calc', 'min' and 'max' functions</h4>
546560
<li>At "*":<br>
547561
check: at least one side is "number" return: the type of the other side
548562
<li>At "/":<br>
549-
check: either right side is "number," or both have the same type<br>
550-
return: if the former, type of left side; otherwise "number"
551-
<li>At "mod": <br>
552-
check: both sides have the same type<br>
553-
return: "number"
563+
check: right side is "number"<br>
564+
return: the type of the left side
554565
</ol>
555566

556567

557-
<!--
558-
<p>A value is ignored if a division by zero or other mathematical
559-
errors occur in the calculation.
560-
561-
<div class="example">
562-
<p>In this example, the second declaration will be ignored due to a
563-
division by zero.
564-
<pre>
565-
p {
566-
margin: 1em;
567-
margin: calc(1em-2px) calc(1em/0)
568-
}
569-
</pre>
570-
</div>
571-
572-
<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.
573-
574-
575-
<p>The expression language is defined by 'length-expression' below:
576-
577-
<pre>
578-
&lt;length> := calc( &lt;length-expression> ) | &lt;atomic-length>
579-
580-
&lt;length-expression> := S* &lt;length-additive-expression> S*
581-
582-
&lt;length-additive-expression> :=
583-
&lt;length-multiplicative-expression> |
584-
&lt;length-additive-expression> S+ '+' S+ &lt;length-multiplicative-expression> |
585-
&lt;length-additive-expression> S+ '-' S+ &lt;length-multiplicative-expression>
586-
587-
&lt;length-multiplicative-expression>
588-
&lt;length-term> |
589-
&lt;length-multiplicative-expression> S* '*' S* &lt;number-term> |
590-
&lt;number-multiplicative-expression> S* '*' S* &lt;length-term> |
591-
&lt;length-multiplicative-expression> S* '/' S* &lt;number-term> |
592-
&lt;length-multiplicative-expression> S+ 'mod' S+ &lt;number-term>
593-
594-
&lt;length-term> := '(' &lt;length-expression> ')' | &lt;atomic-length>
595-
596-
&lt;number-additive-expression> :=
597-
&lt;number-multiplicative-expression> |
598-
&lt;number-additive-expression> S+ '+' S+ &lt;number-multiplicative-expression> |
599-
&lt;number-additive-expression> S+ '-' S+ &lt;number-multiplicative-expression>
600-
601-
&lt;number-multiplicative-expression> :=
602-
&lt;number-term> |
603-
&lt;length-multiplicative-expression> S* '/' S* &lt;length-term> |
604-
&lt;length-multiplicative-expression> S+ 'mod' S+ &lt;length-term>
605-
606-
&lt;number-term> := '(' *S &lt;number-additive-expression> *S ')' | &lt;number>
607-
608-
&lt;atomic-length> := &lt;number>&lt;length-unit>
609-
</pre>
610-
611-
<div class="note">Note that 'mod' is used instead of '%' for modulus since it is very easy to
612-
get confused about whether '%' is acting as a unit or an operator. At
613-
least with 'mod' it always causes a parse error &mdash; invalid unit &mdash; in the
614-
otherwise ambiguous cases.
615-
</div>
616-
-->
617-
618568

619569
<h3>&lt;string&gt;</h3>
620570

0 commit comments

Comments
 (0)