Module Syncom.Operator

Description of user-defined operators.

type t

The type of description for infix, prefix and postfix operators.

Destructors

val arity : t -> int

arity operator is the number of arguments operator is expected to be applied with.

  • If fixity operator = Fixity.Prefix, then arity operator = 1.
  • If fixity operator = Fixity.Infix, then arity operator = 2.
  • If 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 fixity : t -> Fixity.t

fixity operator is the fixity of operator.

val associativity : t -> Associativity.t

associativity operator is the associativity of operator.

  • If fixity operator = Fixity.Prefix, then associativity operator = Associativity.Right_associative.
  • If fixity operator = Fixity.Postfix, then associativity operator = Associativity.Left_associative.

Constructors

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.

Predicates

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.

Instances

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
val equal : t -> t -> bool

equal a b is true if and only if a and b are equal. This should satisfy the following properties:

  • Reflexivity: equal a a = true
  • Symmetry: equal a b is equivalent to equal b a
  • Transitivity: if equal a b = true and equal b c = true, then equal a c = true
val (=) : t -> t -> bool

Operator alias of equal.

val (<>) : t -> t -> bool

Negation of operator (=).