1 /* Copyright 2004,2007,2008,2014 IPB, Universite de Bordeaux, INRIA & CNRS 2 ** 3 ** This file is part of the Scotch software package for static mapping, 4 ** graph partitioning and sparse matrix ordering. 5 ** 6 ** This software is governed by the CeCILL-C license under French law 7 ** and abiding by the rules of distribution of free software. You can 8 ** use, modify and/or redistribute the software under the terms of the 9 ** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following 10 ** URL: "http://www.cecill.info". 11 ** 12 ** As a counterpart to the access to the source code and rights to copy, 13 ** modify and redistribute granted by the license, users are provided 14 ** only with a limited warranty and the software's author, the holder of 15 ** the economic rights, and the successive licensors have only limited 16 ** liability. 17 ** 18 ** In this respect, the user's attention is drawn to the risks associated 19 ** with loading, using, modifying and/or developing or reproducing the 20 ** software by the user in light of its specific status of free software, 21 ** that may mean that it is complicated to manipulate, and that also 22 ** therefore means that it is reserved for developers and experienced 23 ** professionals having in-depth computer knowledge. Users are therefore 24 ** encouraged to load and test the software's suitability as regards 25 ** their requirements in conditions enabling the security of their 26 ** systems and/or data to be ensured and, more generally, to use and 27 ** operate it in the same conditions as regards security. 28 ** 29 ** The fact that you are presently reading this means that you have had 30 ** knowledge of the CeCILL-C license and that you accept its terms. 31 */ 32 /************************************************************/ 33 /** **/ 34 /** NAME : parser.h **/ 35 /** **/ 36 /** AUTHOR : Francois PELLEGRINI **/ 37 /** **/ 38 /** FUNCTION : These lines are the declarations for **/ 39 /** the strategy lexical and syntactic **/ 40 /** analyzer. **/ 41 /** **/ 42 /** DATES : # Version 3.1 : from : 07 nov 1995 **/ 43 /** to 02 may 1996 **/ 44 /** # Version 3.2 : from : 07 oct 1996 **/ 45 /** to 19 oct 1996 **/ 46 /** # Version 3.3 : from : 01 oct 1998 **/ 47 /** to 01 oct 1998 **/ 48 /** # Version 4.0 : from : 20 dec 2001 **/ 49 /** to 11 jun 2004 **/ 50 /** # Version 5.1 : from : 20 feb 2008 **/ 51 /** to 20 feb 2008 **/ 52 /** # Version 6.0 : from : 30 sep 2014 **/ 53 /** to 30 sep 2014 **/ 54 /** **/ 55 /************************************************************/ 56 57 /* 58 ** The defines. 59 */ 60 61 #define PARSERSTRINGLEN 256 /*+ Length of parser strings +*/ 62 63 /* 64 ** The type definitions. 65 */ 66 67 /*+ Strategy node types. +*/ 68 69 typedef enum StratNodeType_ { 70 STRATNODECONCAT, /*+ Concatenation node +*/ 71 STRATNODECOND, /*+ Condition node +*/ 72 STRATNODEEMPTY, /*+ Empty strategy +*/ 73 STRATNODEMETHOD, /*+ Method +*/ 74 STRATNODESELECT, /*+ Selection node +*/ 75 STRATNODENBR /*+ Number of strategy nodes +*/ 76 } StratNodeType; 77 78 /*+ Method and graph parameter types. +*/ 79 80 typedef int StratParamType; /*+ Same type as enum +*/ 81 82 #define STRATPARAMCASE 0 /*+ Character; TRICK: FIRST +*/ 83 #define STRATPARAMDOUBLE 1 /*+ Double floating-point +*/ 84 #define STRATPARAMINT 2 /*+ Integer +*/ 85 #define STRATPARAMLOG 3 /*+ Logical value +*/ 86 #define STRATPARAMSTRAT 4 /*+ Strategy +*/ 87 #define STRATPARAMSTRING 5 /*+ String of characters +*/ 88 89 #define STRATPARAMDEPRECATED 8 /*+ Indicates deprecated parameter; can be merged with the above +*/ 90 91 /*+ Test types, ordered by ascending priority, 92 for proper writing of parentheses. Initial 93 value should be zero for proper indexing. +*/ 94 95 typedef enum StratTestType_ { 96 STRATTESTOR = 0, /*+ Or operator +*/ 97 STRATTESTAND, /*+ And operator +*/ 98 STRATTESTNOT, /*+ Not operator +*/ 99 STRATTESTEQ, /*+ Equal-to operator +*/ 100 STRATTESTGT, /*+ Greater-than operator +*/ 101 STRATTESTLT, /*+ Less-than operator +*/ 102 STRATTESTADD, /*+ Addition operator +*/ 103 STRATTESTSUB, /*+ Subtraction operator +*/ 104 STRATTESTMUL, /*+ Multiplication operator +*/ 105 STRATTESTMOD, /*+ Modulus operator +*/ 106 STRATTESTVAL, /*+ Constant value +*/ 107 STRATTESTVAR, /*+ Variable +*/ 108 STRATTESTNBR /*+ Number of test nodes +*/ 109 } StratTestType; 110 111 /*+ Method characteristics. +*/ 112 113 typedef struct StratMethodTab_ { 114 int meth; /*+ Method number in method table +*/ 115 char * name; /*+ Method name +*/ 116 int (* func) (); /*+ Pointer to bipartitioning method +*/ 117 void * data; /*+ Pointer to default parameters +*/ 118 } StratMethodTab; 119 120 /*+ Method parameter characteristics. +*/ 121 122 typedef struct StratParamTab_ { 123 int meth; /*+ Method number in method table +*/ 124 StratParamType type; /*+ Parameter type +*/ 125 char * name; /*+ Parameter name +*/ 126 byte * database; /*+ Pointer to data base in method +*/ 127 byte * dataofft; /*+ Pointer to data offset in method +*/ 128 void * datasltr; /*+ Pointer to data selector +*/ 129 } StratParamTab; 130 131 /*+ Strategy characteristics. +*/ 132 133 typedef struct StratTab_ { 134 StratMethodTab * methtab; /*+ Pointer to method table +*/ 135 StratParamTab * paratab; /*+ Pointer to parameter table +*/ 136 StratParamTab * condtab; /*+ Pointer to condition table +*/ 137 } StratTab; 138 139 /*+ Concatenation strategy node. +*/ 140 141 typedef struct StratNodeConcat_ { /*+ Concatenation node +*/ 142 struct Strat_ * strat[2]; /*+ Pointers to the two strategies to combine +*/ 143 } StratNodeConcat; 144 145 /*+ Condition and test strategy nodes. +*/ 146 147 typedef union StratTestVal_ { /*+ Constant value +*/ 148 double valdbl; /*+ Double value +*/ 149 INT valint; /*+ Integer value +*/ 150 int vallog; /*+ Logical value +*/ 151 } StratTestVal; 152 153 typedef struct StratTestVar_ { /*+ Condition variable +*/ 154 const StratTab * datatab; /*+ Pointer to data parameter table +*/ 155 int datadisp; /*+ Displacement with respect to beginning +*/ 156 } StratTestVar; 157 158 typedef struct StratTest_ { /*+ Test node +*/ 159 StratTestType typetest; /*+ Test type +*/ 160 StratParamType typenode; /*+ Node type +*/ 161 union { 162 struct StratTest_ * test[2]; /*+ Logical/relational branches +*/ 163 StratTestVal val; /*+ Value +*/ 164 StratTestVar var; /*+ Variable +*/ 165 } data; 166 } StratTest; 167 168 typedef struct StratNodeCond_ { /*+ Test node +*/ 169 StratTest * test; /*+ Test condition +*/ 170 struct Strat_ * strat[2]; /*+ Then/else strategies +*/ 171 } StratNodeCond; 172 173 /*+ Data structure of the empty strategy operator node. +*/ 174 175 typedef struct StratNodeEmpty_ { /*+ Empty node +*/ 176 byte dummy; /*+ Dummy data +*/ 177 } StratNodeEmpty; 178 179 /*+ Data structure of the empty strategy operator node. +*/ 180 181 typedef double StratNodeMethodData[10]; /*+ Reserved padded space for method data */ 182 183 typedef struct StratNodeMethod_ { /*+ Method node +*/ 184 int meth; /*+ Index in method table +*/ 185 StratNodeMethodData data; /*+ Method data +*/ 186 } StratNodeMethod; 187 188 /*+ Data structure of the selection strategy operator node. +*/ 189 190 typedef struct StratNodeSelect_ { /*+ Selection node +*/ 191 struct Strat_ * strat[2]; /*+ Pointers to the two strategies to test +*/ 192 } StratNodeSelect; 193 194 /*+ The strategy node data structure. +*/ 195 196 typedef struct Strat_ { 197 const StratTab * tabl; /*+ Pointer to parsing strategy table +*/ 198 StratNodeType type; /*+ Method type +*/ 199 union { /*+ Method data +*/ 200 double padding; /*+ Padding for double alignment +*/ 201 StratNodeConcat concat; /*+ Concatenation node data +*/ 202 StratNodeCond cond; /*+ Condition node data +*/ 203 StratNodeEmpty empty; /*+ Empty node data +*/ 204 StratNodeMethod method; /*+ Method node data +*/ 205 StratNodeSelect select; /*+ Selection node data +*/ 206 } data; 207 } Strat; 208 209 /* 210 ** The external declarations. 211 */ 212 213 extern Strat stratdummy; /*+ Dummy empty strategy node +*/ 214 215 /* 216 ** The function prototypes. 217 */ 218 219 #ifndef PARSER 220 #define static 221 #endif 222 223 Strat * stratInit (const StratTab * const , const char * const); 224 int stratExit (Strat * const); 225 int stratSave (const Strat * const, FILE * const); 226 227 int stratTestEval (const StratTest * const, StratTest * const, const void * const); 228 static int stratTestEvalCast (StratTest * const, StratTest * const); 229 int stratTestExit (StratTest * const); 230 int stratTestSave (const StratTest * const, FILE * const); 231 232 #undef static 233