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
|
/*-----------------------------------------------------------------------
File : pcl_positions.c
Author: Stephan Schulz
Contents
Positions in PCL2 clauses.
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_positions.h"
/*---------------------------------------------------------------------*/
/* Global Variables */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Forward Declarations */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Internal Functions */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Exported Functions */
/*---------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
//
// Function: PCL2PosAlloc()
//
// Allocate an initialized PCL2 position data structure.
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
PCL2Pos_p PCL2PosAlloc(void)
{
PCL2Pos_p handle = PCL2PosCellAlloc();
handle->literal = -1;
handle->side = NoSide;
handle->termposlen = 0;
handle->termpos = NULL;
return handle;
}
/*-----------------------------------------------------------------------
//
// Function: PCL2PosFree()
//
// Free a PCL2 position.
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
void PCL2PosFree(PCL2Pos_p pos)
{
assert(pos);
if(pos->termpos)
{
PDArrayFree(pos->termpos);
}
PCL2PosCellFree(pos);
}
/*-----------------------------------------------------------------------
//
// Function: PCL2PosParse()
//
// Parse a PCL2 position of the format
// <pos-int> [. L|R [ .<pos-int> ]*].
//
// Global Variables: -
//
// Side Effects : Input, memory operations
//
/----------------------------------------------------------------------*/
PCL2Pos_p PCL2PosParse(Scanner_p in)
{
PCL2Pos_p handle = PCL2PosAlloc();
long i;
handle->literal = AktToken(in)->numval;
AcceptInpTok(in, PosInt);
if(TestInpTok(in, Fullstop))
{
NextToken(in);
CheckInpId(in, "L|R");
if(TestInpId(in, "L"))
{
handle->side = LeftSide;
}
else
{
handle->side = RightSide;
}
NextToken(in);
if(TestInpTok(in, Fullstop))
{
handle->termpos = PDArrayAlloc(5,10);
}
i=0;
while(TestInpTok(in, Fullstop))
{
NextToken(in);
PDArrayAssignInt(handle->termpos,i++,AktToken(in)->numval);
AcceptInpTok(in, PosInt);
}
handle->termposlen=i;
}
return handle;
}
/*-----------------------------------------------------------------------
//
// Function: PCL2PosPrint()
//
// Print a PCL2 position.
//
// Global Variables: -
//
// Side Effects : Output
//
/----------------------------------------------------------------------*/
void PCL2PosPrint(FILE* out, PCL2Pos_p pos)
{
long i;
assert(pos);
fprintf(out, "%ld", pos->literal);
if(pos->side!=NoSide)
{
assert((pos->side==LeftSide) || (pos->side==RightSide));
fprintf(out, ".%c", (pos->side==LeftSide)?'L':'R');
i=0;
while(i<pos->termposlen)
{
assert(pos->termpos);
fprintf(out, "%ld", PDArrayElementInt(pos->termpos,i++));
}
}
}
/*---------------------------------------------------------------------*/
/* End of File */
/*---------------------------------------------------------------------*/
|