module Level: sig
.. end
Level of precedence of operators (also specifies their
associativity).
type
unary
type
binary
type 'a
t
A precedence level. Can be for unary or binary operators.
Precedence levels know their associativity.
type
arity =
Arity of a level. Levels for unary and binary operators are
different (unary operators always bind more tightly than
binary ones).
type
assoc = Camlp4.Sig.Grammar.assoc
=
Possible associativity values for binary infix operators.
type 'a
precedence =
| |
Highest |
| |
Higher of 'a t |
| |
Lower of 'a t |
| |
Lowest |
Relative precedence of new levels.
exception Bad_arity
Bad_arity
is raised if the type of level required by a function
is not respected.
val compare : 'a t -> 'b t -> int
Total ordering on Level.t
val binary : ?name:string ->
?assoc:assoc ->
binary precedence ->
binary t
binary prec
creates a new level for infix operators at the
level specified by prec
.
Raises Bad_arity
if a '_a precedence
is given which does not
turn out to be a binary precedence
.
name
: the name of the new level (only used for error reporting).
assoc
: the associativity of the new level. By default,
the associativity is inherited from the the level given in
prec
or is NonA
for Highest
and Lowest
.
val unary : ?name:string ->
unary precedence ->
unary t
unnary prec
creates a new level for prefix or postfix
operators at the level specified by prec
.
Raises Bad_arity
if a '_a precedence
is given which does not
turn out to be a unary precedence
.
name
: the name of the new level.
val name : 'a t -> string
name l
returns the possible name given to the level l
.
val arity : 'a t -> arity
arity l
returns the arity of that level.
val assoc : 'a t -> assoc
assoc l
returns the associativity of that level.
val assignment : binary t
Level of ":="
val disjunction : binary t
Level of "||"
val conjunction : binary t
Level of "&&"
val comparison : binary t
Level of "<", "<=", "=",...
val concatenation : binary t
Level of "^"
val addition : binary t
Level of "+", "-",...
val multiplication : binary t
Level of "*", "/", "land",...
and it is also the default level of
alphabetic operators.
val exponentiation : binary t
Level of "**", "lsl",...
val default_unary : unary t
Level of "!"