Syncom.Operator
Description of user-defined operators.
val arity : t -> int
arity operator
is the number of arguments operator
is expected to be applied with.
fixity operator = Fixity.Prefix
, then arity operator = 1
.fixity operator = Fixity.Infix
, then arity operator = 2
.fixity operator = Fixity.Postfix
, then arity operator = 1
.val precedence : t -> int
precedence operator
is the user-defined value for parsing the order of operations when operands and arguments are juxtaposed.
If precedence o1 < precedence o2
, then o2
precedes o1
such that a o1 b o2 c
is parsed as a o1 (b o2 c)
, where a
, b
and c
are operands.
val associativity : t -> Associativity.t
associativity operator
is the associativity of operator
.
fixity operator = Fixity.Prefix
, then associativity operator = Associativity.Right_associative
.fixity operator = Fixity.Postfix
, then associativity operator = Associativity.Left_associative
.val make_prefix : precedence:int -> t
make_prefix ~precedence
is a description for a prefix operator with ~precedence
.
val make_infix : associativity:Associativity.t -> precedence:int -> t
make_infix ~associativity ~precedence
is a description for an infix operator with ~associativity
and ~precedence
.
val make_postfix : precedence:int -> t
make_postfix ~precedence
is a description for a postfix operator with ~precedence
.
val is_prefix : t -> bool
is_prefix operator
is true
if and only if fixity operator = Fixity.Prefix
.
val is_infix : t -> bool
is_infix operator
is true
if and only if fixity operator = Fixity.Infix
.
val is_postfix : t -> bool
is_postfix operator
is true
if and only if fixity operator = Fixity.Postfix
.
val is_unary : t -> bool
is_unary operator
is true
if and only if arity operator = 1
.
val is_binary : t -> bool
is_binary operator
is true
if and only if arity operator = 2
.
val is_left_associative : t -> bool
is_left_associative operator
is true
if and only if associativity operator = Associativity.Left_associative
.
val is_right_associative : t -> bool
is_right_associative operator
is true
if and only if associativity operator = Associativity.Right_associative
.
val is_non_associative : t -> bool
is_non_associative operator
is true
if and only if associativity operator = Associativity.Non_associative
.
Structural equality instance. That is, operators are equal if they have the same arity, precedence, fixity and associativity.
include Support.Eq.EQ with type t := t
equal a b
is true
if and only if a
and b
are equal. This should satisfy the following properties:
equal a a = true
equal a b
is equivalent to equal b a
equal a b = true
and equal b c = true
, then equal a c = true