GNU PROLOG with UTF8 support
oper.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------*
2  * GNU Prolog *
3  * *
4  * Part : Prolog engine *
5  * File : oper.h *
6  * Descr.: operator table management - header file *
7  * Author: Daniel Diaz *
8  * *
9  * Copyright (C) 1999-2015 Daniel Diaz *
10  * *
11  * This file is part of GNU Prolog *
12  * *
13  * GNU Prolog is free software: you can redistribute it and/or *
14  * modify it under the terms of either: *
15  * *
16  * - the GNU Lesser General Public License as published by the Free *
17  * Software Foundation; either version 3 of the License, or (at your *
18  * option) any later version. *
19  * *
20  * or *
21  * *
22  * - the GNU General Public License as published by the Free *
23  * Software Foundation; either version 2 of the License, or (at your *
24  * option) any later version. *
25  * *
26  * or both in parallel, as here. *
27  * *
28  * GNU Prolog is distributed in the hope that it will be useful, *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
31  * General Public License for more details. *
32  * *
33  * You should have received copies of the GNU General Public License and *
34  * the GNU Lesser General Public License along with this program. If *
35  * not, see http://www.gnu.org/licenses/. *
36  *-------------------------------------------------------------------------*/
37 
38 
39 /*---------------------------------*
40  * Constants *
41  *---------------------------------*/
42 
43 #define MAX_PREC 1200
44 #define MAX_ARG_OF_FUNCTOR_PREC 999
45 
46 
47 #define Make_Oper_Key(a, t) (((PlULong) (a) << 2) | (t))
48 #define Atom_Of_Oper(k) ((PlULong) (k) >> 2)
49 #define Type_Of_Oper(k) ((PlULong) (k) & 3)
50 
51 
52 
53 
54  /* operator type */
55 
56 #define PREFIX 0
57 #define POSTFIX 1
58 #define INFIX 2
59 
60 
61 
62 
63 #define Make_Op_Mask(type) (1<<(type))
64 
65 
66 
67 
68 /*---------------------------------*
69  * Type Definitions *
70  *---------------------------------*/
71 
72 typedef struct /* Operator information */
73 { /* ------------------------------ */
74  PlLong a_t; /* key is <atom,operator type> */
75  int prec; /* precedence of the operator */
76  int left; /* precedence of the operator lhs */
77  int right; /* precedence of the operator rhs */
78 }
79 OperInf;
80 
81 
82 
83 
84 /*---------------------------------*
85  * Global Variables *
86  *---------------------------------*/
87 
88 #ifdef OPER_FILE
89 
90 char *pl_oper_tbl;
91 
92 #else
93 
94 extern char *pl_oper_tbl;
95 
96 #endif
97 
98 
99 /*---------------------------------*
100  * Function Prototypes *
101  *---------------------------------*/
102 
103 void Pl_Init_Oper(void);
104 
105 OperInf *Pl_Create_Oper(int atom_op, int type, int prec, int left, int right);
106 
107 OperInf *Pl_Lookup_Oper(int atom_op, int type);
108 
109 OperInf *Pl_Lookup_Oper_Any_Type(int atom_op);
110 
111 OperInf *Pl_Delete_Oper(int atom_op, int type);
112 
113 
114 
115 #define Check_Oper(atom_op, type) \
116  (pl_atom_tbl[(atom_op)].prop.op_mask & Make_Op_Mask(type))
117 
118 
119 
120 #define Check_Oper_Any_Type(atom_op) \
121  (pl_atom_tbl[(atom_op)].prop.op_mask)
PlLong a_t
Definition: oper.h:74
Definition: oper.h:72
int right
Definition: oper.h:77
char * pl_oper_tbl
intptr_t PlLong
Definition: gprolog.h:88
OperInf * Pl_Delete_Oper(int atom_op, int type)
Definition: oper.c:259
int prec
Definition: oper.h:75
OperInf * Pl_Lookup_Oper(int atom_op, int type)
Definition: oper.c:219
int left
Definition: oper.h:76
OperInf * Pl_Lookup_Oper_Any_Type(int atom_op)
Definition: oper.c:235
void Pl_Init_Oper(void)
Definition: oper.c:90
OperInf * Pl_Create_Oper(int atom_op, int type, int prec, int left, int right)
Definition: oper.c:191