1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
/*-----------------------------------------------------------------------
File : pcl_idents.c
Author: Stephan Schulz
Contents
Identifiers for PCL2 - lists on posititive numbers.
Copyright 1998, 1999 by the author.
This code is released under the GNU General Public Licence and
the GNU Lesser General Public License.
See the file COPYING in the main E directory for details..
Run "eprover -h" for contact information.
Changes
<1> Wed Mar 22 19:32:20 MET 2000
New
-----------------------------------------------------------------------*/
#include "pcl_idents.h"
/*---------------------------------------------------------------------*/
/* Global Variables */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Forward Declarations */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Internal Functions */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Exported Functions */
/*---------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
//
// Function: PCLIdParse()
//
// Parse a PCL-Identifier, i.e. a usually short list of pos-ints
// separated by spaces.
//
// Global Variables: -
//
// Side Effects : Input, memory allocation
//
/----------------------------------------------------------------------*/
PCLId_p PCLIdParse(Scanner_p in)
{
PCLId_p id;
long i;
CheckInpTok(in, PosInt);
id = PCLIdAlloc();
i=0;
PDArrayAssignInt(id,i++,AktToken(in)->numval);
NextToken(in);
while(TestInpTok(in, Fullstop))
{
AcceptInpTok(in, Fullstop);
PDArrayAssignInt(id,i++,AktToken(in)->numval);
AcceptInpTok(in, PosInt);
}
PDArrayAssignInt(id,i,NO_PCL_ID_ELEMENT);
return id;
}
/*-----------------------------------------------------------------------
//
// Function: PCLIdPrintFormatted()
//
// Print a PCL identifier.
//
// Global Variables: -
//
// Side Effects : Output
//
/----------------------------------------------------------------------*/
void PCLIdPrintFormatted(FILE* out, PCLId_p id, bool formatted)
{
long i;
assert(id);
assert(PDArrayElementInt(id,0)>=0);
assert(PDArrayElementInt(id,0)!=NO_PCL_ID_ELEMENT); /* Redundant,
bute
well...erm...*/
fprintf(out, formatted?"%7ld":"%ld", PDArrayElementInt(id,0));
for(i=1;PDArrayElementInt(id,i)!=NO_PCL_ID_ELEMENT;i++)
{
fprintf(out, ".%ld", PDArrayElementInt(id,i));
}
}
/*-----------------------------------------------------------------------
//
// Function: PCLIdPrintTSTP()
//
// Print a PCL identifier in a format suitable for TSTP. If a single
// number, print it, otherwise convert it to pclid<no1>_<no2>...
//
// Global Variables: -
//
// Side Effects : Output
//
/----------------------------------------------------------------------*/
void PCLIdPrintTSTP(FILE* out, PCLId_p id)
{
long i;
assert(id);
assert(PDArrayElementInt(id,0)>=0);
assert(PDArrayElementInt(id,0)!=NO_PCL_ID_ELEMENT); /* Redundant,
but
well...erm...*/
if(PDArrayElementInt(id,1)==NO_PCL_ID_ELEMENT)
{
fprintf(out, "%ld", PDArrayElementInt(id,0));
}
else
{
fprintf(out, "pclid%ld", PDArrayElementInt(id,0));
for(i=1;PDArrayElementInt(id,i)!=NO_PCL_ID_ELEMENT;i++)
{
fprintf(out, "_%ld", PDArrayElementInt(id,i));
}
}
}
/*-----------------------------------------------------------------------
//
// Function: PCLIdCompare()
//
// Compare two PCL identifiers lexicographically.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
int PCLIdCompare(PCLId_p id1, PCLId_p id2)
{
long i, e1,e2;
long res=0;
assert(id1&&id2);
for(i=0; !res; i++)
{
e1 = PDArrayElementInt(id1,i);
e2 = PDArrayElementInt(id2,i);
if((e1==NO_PCL_ID_ELEMENT) && (e2==NO_PCL_ID_ELEMENT))
{
assert(res==0);
break;
}
res = e1-e2;
}
return (int)res;
}
/*---------------------------------------------------------------------*/
/* End of File */
/*---------------------------------------------------------------------*/
|