Next: iklib syntaxes infix notes, Previous: iklib syntaxes infix syntax, Up: iklib syntaxes infix [Index]
To determine sensible precedences for operators, we make the following observations:
and
, or
, not
, …) are meant
to be applied to predicate operand expressions and they return a boolean
value.
=
, <
, >
, …) are
meant to be applied to numeric operand expressions and they return a
boolean value.
+
, -
, *
, /
, …)
are meant to be applied to numeric operand expressions and they return a
numeric value.
1 & 2 + ~ 3
meaning (1 & 2) +
(~ 3)
, in which bitwise operators take precedence over every other
operator.
1 < i and i < 4
meaning
(1 < i) and (i < 4)
, because it makes no sense to interpret it as
1 < (i and i) < 4
.
1 + 2 < 3 + 4
meaning
(1 + 2) < (3 + 4)
, because it makes no sense to interpret it as
1 + (2 < 3) + 4
.
So Vicare defines operators precedence as follows, from high precedence to low precedence:
bitwise-arithmetic-shift-left bitwise-arithmetic-shift-right fxarithmetic-shift-left fxarithmetic-shift-right
bitwise-not fxnot
bitwise-and bitwise-ior bitwise-xor fxand fxior fxxor
+ - ++ -- fx+ fx- fl+ fl-
++ -- !
expt flexpt
mod mod0 fxmod fxmod0
* / div div0 fl* fl/ fx* fxdiv fxdiv0
+ - fl+ fl- fx+ fx-
< > <= >= = != fx<? fx>? fx<=? fx>=? fx=? fl<? fl>? fl<=? fl>=? fl=? eq? eqv? equal?
not
and or xor
… ? … : …
.
Here some expansion examples:
(infix ! 2 + 3) → (not (2 + 3)) (infix (! 2) + 3) error→ expected numeric argument (infix fxnot 3) ⇒ -3 (infix fxnot 3 + 10) ⇒ 7 (infix ! cos(3)) → (not (cos 3))
Next: iklib syntaxes infix notes, Previous: iklib syntaxes infix syntax, Up: iklib syntaxes infix [Index]