YAP 7.1.0
Summary of YAP Predefined Operators

The Prolog syntax caters for operators of three main kinds: More...

Detailed Description

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

a + b * c

means

a + (b * c)

as + and * have the following types and precedences:

:-op(500,yfx,'+').
:-op(400,yfx,'*').

Now defining

:-op(700,xfy,'++').
:-op(700,xfx,'=:=').
a ++ b =:= c

means

a ++ (b =:= c)

The following is the list of the declarations of the predefined operators:

:-op(1200,fx,['?-', ':-']).
:-op(1200,xfx,[':-','-->']).
:-op(1150,fx,[block,dynamic,mode,public,multifile,meta_predicate,
sequential,table,initialization]).
:-op(1100,xfy,[';','|']).
:-op(1050,xfy,->).
:-op(1000,xfy,',').
:-op(999,xfy,'.').
:-op(900,fy,['\+', not]).
:-op(900,fx,[nospy, spy]).
:-op(700,xfx,[@>=,@=<,@<,@>,<,=,>,=:=,=\=,\==,>=,=<,==,\=,=..,is]).
:-op(500,yfx,['\/','/\','+','-']).
:-op(500,fx,['+','-']).
:-op(400,yfx,['<<','>>','//','*','/']).
:-op(300,xfx,mod).
:-op(200,xfy,['^','**']).
:-op(50,xfx,same).

Class Documentation

◆ OPSTRUCT

struct OPSTRUCT

Definition at line 346 of file init.c.

Public Attributes

char * opName
 
short int opType
 
short int opPrio
 

Member Data Documentation

◆ opName

char* opName

Definition at line 347 of file init.c.

◆ opPrio

short int opPrio

Definition at line 348 of file init.c.

◆ opType

short int opType

Definition at line 348 of file init.c.

Macro Definition Documentation

◆ fx

#define fx   6

Definition at line 196 of file init.c.

◆ fy

#define fy   7

Definition at line 197 of file init.c.

◆ xf

#define xf   4

Definition at line 194 of file init.c.

◆ xfx

#define xfx   1

Definition at line 191 of file init.c.

◆ xfy

#define xfy   2

Definition at line 192 of file init.c.

◆ yf

#define yf   5

Definition at line 195 of file init.c.

◆ yfx

#define yfx   3

Definition at line 193 of file init.c.

Function Documentation

◆ Yap_dup_op()

bool Yap_dup_op ( OpEntry op,
ModEntry she 
)

Definition at line 301 of file init.c.

◆ Yap_GetOp()

Atom Yap_GetOp ( OpEntry pp,
int *  prio,
int  fix 
)

Definition at line 316 of file init.c.

◆ Yap_IsOpType()

int Yap_IsOpType ( char *  type)

Definition at line 199 of file init.c.

◆ Yap_OpDec()

int Yap_OpDec ( int  p,
char *  type,
Atom  a,
Term  m 
)

Definition at line 289 of file init.c.

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)