![]() |
YAP 7.1.0
|
The Prolog syntax caters for operators of three main kinds: More...
The Prolog syntax caters for operators of three main kinds:
Each operator has precedence in the range 1 to 1200, and this precedence is used to disambiguate expressions where the structure of the term denoted is not made explicit using brackets The operator of higher precedence is the main functor
If there are two operators with the highest precedence, the ambiguity is solved analyzing the types of the operators The possible infix types are: xfx, xfy, and yfx
With an operator of type xfx both sub-expressions must have lower precedence than the operator itself, unless they are bracketed (which assigns to them zero precedence) With an operator type xfy only the left-hand sub-expression must have lower precedence The opposite happens for yfx type
A prefix operator can be of type fx or fy A postfix operator can be of type xf or yf The meaning of the notation is analogous to the above
means
as + and * have the following types and precedences:
Now defining
means
The following is the list of the declarations of the predefined operators:
struct OPSTRUCT |
Macros | |
#define | xfx 1 |
#define | xfy 2 |
#define | yfx 3 |
#define | xf 4 |
#define | yf 5 |
#define | fx 6 |
#define | fy 7 |
Typedefs | |
typedef struct OPSTRUCT | Opdef |
Functions | |
int | Yap_IsOpType (char *type) |
int | Yap_OpDec (int p, char *type, Atom a, Term m) |
bool | Yap_dup_op (OpEntry *op, ModEntry *she) |
Atom | Yap_GetOp (OpEntry *pp, int *prio, int fix) |