[SLP-Homepage]
[Source Modules]
[Manual]
[Run]
[Examples]
Logical Operators in Formulas (And, Or, ...)
This module defines a class op_c.
The objects of this class correspond to logical operator types in formulas.
So there are currently exactly 7 objects of this class,
namely
- Classical Negation:
~
- Conjunction (logical and):
&
, ,
- Disjunction (logical or):
|
, ;
, v
- Implication From Right to Left (logical if):
:-
, <-
- Implication From Left to Right:
->
- Equivalence (logical iff):
<->
- Default Negation:
not
The class was created to store information about the operators
like their name, their priority, and their associativity.
Exported Constants:
- OP_MAX_PRIO:
-
static const int OP_MAX_PRIO = 4;
;
This is the maximal value returned by prio
below.
Exported Enumeration Types:
- op_kind_t:
-
typedef enum {
OP_NOT,
OP_AND,
OP_OR,
OP_IF,
OP_THEN,
OP_EQUIV,
OP_DEFNEG
} op_kind_t;
;
This is an enumeration type that lists the various kinds of
logical operators.
Class Methods:
The 7 objects are preconstructed.
The class has methods for accessing them:
- op_not:
-
static op_c *op_not(void)
;
This method returns the object corresponding to
the classical negation operator.
- op_or:
-
static op_c *op_or(void)
;
This method returns the object corresponding to
the disjunction (logical or) operator.
- op_and:
-
static op_c *op_and(void)
;
This method returns the object corresponding to
the conjunction (logical and) operator.
- op_if:
-
static op_c *op_if(void)
;
This method returns the object corresponding to
the "implication from right to left" (logical if) operator.
- op_then:
-
static op_c *op_then(void)
;
This method returns the object corresponding to
the "implicationfrom left to right" (logical then) operator.
- op_equiv:
-
static op_c *op_equiv(void)
;
This method returns the object corresponding to
the equivalence (logical iff) operator.
- op_defneg:
-
static op_c *op_defneg(void)
;
This method returns the object corresponding to
the default negation operator.
Object Methods:
- kind:
-
op_kind_t kind(void) const
;
This method returns the kind of the operator
as an element of the above enumeration type
(e.g. OP_NOT
, OP_AND
).
- name:
-
str_t name(void) const
;
This method returns a string representation of the operator
(with spaces).
- is_binary:
-
bool_t is_binary(void) const
;
This method returns BOOL_TRUE
if this operator is binary
or BOOL_FALSE
if it is unary.
- prio:
-
int prio(void) const
;
This method returns the priority (binding strength, precedence)
of the operator.
Note that a smaller numeric value means higher binding strength.
- assoc:
-
assoc_t assoc(void) const
;
This method returns the associativity of the operator,
see assoc_t.
Implementation:
Stefan Brass
(sbrass@sis.pitt.edu),
October 3, 2001.
[HTML 3.2 Checked]