Next: , Previous: , Up: infix   [Contents][Index]


3.2 Operators precedence

To determine sensible precedences for operators, we make the following observations:

So MMCK Infix defines operators precedence as follows, from high precedence to low precedence:

  1. Procedure application: the left parenthesis preceeded by an identifier starts a procedure application.
  2. Binary infix bitwise shift operators:
    bitwise-arithmetic-shift-left
    bitwise-arithmetic-shift-right
    fxshl
    fxshr
    
  3. Unary prefix bitwise operators:
    bitwise-not fxnot
    
  4. Binary infix bitwise operators:
    bitwise-and bitwise-ior bitwise-xor
    fxand fxior fxxor
    
  5. Unary prefix arithmetic operators:
    + - ++ -- fx+ fx- fp+ fp-
    
  6. Unary postfix arithmetic operators:
    ++ -- !
    
  7. Binary infix arithmetic exponentiation operators:
    expt fpexpt
    
  8. Binary infix arithmetic modulo operators:
    quotient modulo remainder
    
  9. Binary infix multiplication and division arithmetic operators:
    * / fp* fp/ fx* fx/
    
  10. Binary infix addition and subtraction arithmetic operators:
    + - fp+ fp- fx+ fx-
    
  11. Comparison operators:
    < > <= >= = !=
    fx< fx> fx<= fx>= fx=
    fp< fp> fp<= fp>= fp=
    eq? eqv? equal?
    
  12. Unary prefix logical operators:
    not
    
  13. Binary infix logical operators:
    and or xor
    
  14. Ternary conditional operator … ? … : ….
  15. Procedure application arguments separator, which is the comma.

Here some expansion examples:

(infix ! 2 + 3)         → (not (2 + 3))
(infix (! 2) + 3)       error→ expected numeric argument

(infix fxnot 3)         ⇒ -4
(infix fxnot 3 + 10)    ⇒ 6

(infix ! cos(3))        → (not (cos 3))

Precedence exceptions

The Pratt parser allows the same operator to have different precedence when it is present in prefix position or in postfix position. So under (mmck infix) the following expansion takes place:

(infix ! 1 + 2)         → (not (+ 1 2))

Next: , Previous: , Up: infix   [Contents][Index]

This document describes version 0.1.0-devel.0 of MMCK Infix.