src/base/ver/ver.h File Reference

#include <stdio.h>
#include "abc.h"
Include dependency graph for ver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Ver_Man_t_

Typedefs

typedef struct Ver_Man_t_ Ver_Man_t
typedef struct Ver_Stream_t_ Ver_Stream_t

Functions

Abc_Lib_tVer_ParseFile (char *pFileName, Abc_Lib_t *pGateLib, int fCheck, int fUseMemMan)
void Ver_ParsePrintErrorMessage (Ver_Man_t *p)
void * Ver_FormulaParser (char *pFormula, void *pMan, Vec_Ptr_t *vNames, Vec_Ptr_t *vStackFn, Vec_Int_t *vStackOp, char *pErrorMessage)
void * Ver_FormulaReduction (char *pFormula, void *pMan, Vec_Ptr_t *vNames, char *pErrorMessage)
int Ver_ParseSkipComments (Ver_Man_t *p)
char * Ver_ParseGetName (Ver_Man_t *p)
Ver_Stream_tVer_StreamAlloc (char *pFileName)
void Ver_StreamFree (Ver_Stream_t *p)
char * Ver_StreamGetFileName (Ver_Stream_t *p)
int Ver_StreamGetFileSize (Ver_Stream_t *p)
int Ver_StreamGetCurPosition (Ver_Stream_t *p)
int Ver_StreamGetLineNumber (Ver_Stream_t *p)
int Ver_StreamIsOkey (Ver_Stream_t *p)
char Ver_StreamScanChar (Ver_Stream_t *p)
char Ver_StreamPopChar (Ver_Stream_t *p)
void Ver_StreamSkipChars (Ver_Stream_t *p, char *pCharsToSkip)
void Ver_StreamSkipToChars (Ver_Stream_t *p, char *pCharsToStop)
char * Ver_StreamGetWord (Ver_Stream_t *p, char *pCharsToStop)

Typedef Documentation

typedef struct Ver_Man_t_ Ver_Man_t

CFile****************************************************************

FileName [ver.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Verilog parser.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - August 19, 2006.]

Revision [

Id
ver.h,v 1.00 2006/08/19 00:00:00 alanmi Exp

] INCLUDES /// PARAMETERS /// BASIC TYPES ///

Definition at line 43 of file ver.h.

typedef struct Ver_Stream_t_ Ver_Stream_t

Definition at line 44 of file ver.h.


Function Documentation

void* Ver_FormulaParser ( char *  pFormula,
void *  pMan,
Vec_Ptr_t vNames,
Vec_Ptr_t vStackFn,
Vec_Int_t vStackOp,
char *  pErrorMessage 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Parser of the formula encountered in assign statements.]

Description []

SideEffects []

SeeAlso []

Definition at line 73 of file verFormula.c.

00074 {
00075     char * pTemp;
00076     Hop_Obj_t * bFunc, * bTemp;
00077     int nParans, Flag;
00078         int Oper, Oper1, Oper2;
00079     int v;
00080 
00081     // clear the stacks and the names
00082     Vec_PtrClear( vNames );
00083     Vec_PtrClear( vStackFn );
00084     Vec_IntClear( vStackOp );
00085 
00086     if ( !strcmp(pFormula, "0") || !strcmp(pFormula, "1\'b0") )
00087         return Hop_ManConst0(pMan);
00088     if ( !strcmp(pFormula, "1") || !strcmp(pFormula, "1\'b1") )
00089         return Hop_ManConst1(pMan);
00090 
00091     // make sure that the number of opening and closing parantheses is the same
00092     nParans = 0;
00093     for ( pTemp = pFormula; *pTemp; pTemp++ )
00094         if ( *pTemp == '(' )
00095             nParans++;
00096         else if ( *pTemp == ')' )
00097             nParans--;
00098     if ( nParans != 0 )
00099     {
00100         sprintf( pErrorMessage, "Parse_FormulaParser(): Different number of opening and closing parantheses ()." );
00101         return NULL;
00102     }
00103  
00104     // add parantheses
00105     pTemp = pFormula + strlen(pFormula) + 2;
00106     *pTemp-- = 0; *pTemp = ')';
00107     while ( --pTemp != pFormula )
00108         *pTemp = *(pTemp - 1);
00109     *pTemp = '(';
00110 
00111     // perform parsing
00112     Flag = VER_PARSE_FLAG_START;
00113     for ( pTemp = pFormula; *pTemp; pTemp++ )
00114         {
00115                 switch ( *pTemp )
00116             {
00117                 // skip all spaces, tabs, and end-of-lines
00118         case ' ':
00119         case '\t':
00120         case '\r':
00121         case '\n':
00122                         continue;
00123 /*
00124                 // treat Constant 0 as a variable
00125                 case VER_PARSE_SYM_CONST0:
00126                     Vec_PtrPush( vStackFn, Hop_ManConst0(pMan) );  // Cudd_Ref( Hop_ManConst0(pMan) );
00127                         if ( Flag == VER_PARSE_FLAG_VAR )
00128                         {
00129                                 sprintf( pErrorMessage, "Parse_FormulaParser(): No operation symbol before constant 0." );
00130                                 Flag = VER_PARSE_FLAG_ERROR; 
00131                 break;
00132                         }
00133             Flag = VER_PARSE_FLAG_VAR; 
00134             break;
00135 
00136                 // the same for Constant 1
00137                 case VER_PARSE_SYM_CONST1:
00138                     Vec_PtrPush( vStackFn, Hop_ManConst1(pMan) );  //  Cudd_Ref( Hop_ManConst1(pMan) );
00139                         if ( Flag == VER_PARSE_FLAG_VAR )
00140                         {
00141                                 sprintf( pErrorMessage, "Parse_FormulaParser(): No operation symbol before constant 1." );
00142                                 Flag = VER_PARSE_FLAG_ERROR; 
00143                 break;
00144                         }
00145             Flag = VER_PARSE_FLAG_VAR; 
00146             break;
00147 */
00148                 case VER_PARSE_SYM_NEGBEF1:
00149                 case VER_PARSE_SYM_NEGBEF2:
00150                         if ( Flag == VER_PARSE_FLAG_VAR )
00151                         {// if NEGBEF follows a variable, AND is assumed
00152                                 sprintf( pErrorMessage, "Parse_FormulaParser(): Variable before negation." );
00153                                 Flag = VER_PARSE_FLAG_ERROR; 
00154                 break;
00155                         }
00156                 Vec_IntPush( vStackOp, VER_PARSE_OPER_NEG );
00157                         break;
00158 
00159         case VER_PARSE_SYM_AND:
00160         case VER_PARSE_SYM_OR:
00161         case VER_PARSE_SYM_XOR:
00162         case VER_PARSE_SYM_MUX1:
00163         case VER_PARSE_SYM_MUX2:
00164                         if ( Flag != VER_PARSE_FLAG_VAR )
00165                         {
00166                                 sprintf( pErrorMessage, "Parse_FormulaParser(): There is no variable before AND, EXOR, or OR." );
00167                                 Flag = VER_PARSE_FLAG_ERROR; 
00168                 break;
00169                         }
00170                         if ( *pTemp == VER_PARSE_SYM_AND )
00171                                 Vec_IntPush( vStackOp, VER_PARSE_OPER_AND );
00172                         else if ( *pTemp == VER_PARSE_SYM_OR )
00173                                 Vec_IntPush( vStackOp, VER_PARSE_OPER_OR );
00174                         else if ( *pTemp == VER_PARSE_SYM_XOR )
00175                                 Vec_IntPush( vStackOp, VER_PARSE_OPER_XOR );
00176                         else if ( *pTemp == VER_PARSE_SYM_MUX1 )
00177                                 Vec_IntPush( vStackOp, VER_PARSE_OPER_MUX );
00178 //                      else if ( *pTemp == VER_PARSE_SYM_MUX2 )
00179 //                              Vec_IntPush( vStackOp, VER_PARSE_OPER_MUX );
00180                         Flag = VER_PARSE_FLAG_OPER; 
00181             break;
00182 
00183         case VER_PARSE_SYM_OPEN:
00184                         if ( Flag == VER_PARSE_FLAG_VAR )
00185                         {
00186                                 sprintf( pErrorMessage, "Parse_FormulaParser(): Variable before a paranthesis." );
00187                                 Flag = VER_PARSE_FLAG_ERROR; 
00188                 break;
00189                         }
00190                         Vec_IntPush( vStackOp, VER_PARSE_OPER_MARK );
00191                         // after an opening bracket, it feels like starting over again
00192                         Flag = VER_PARSE_FLAG_START; 
00193             break;
00194 
00195                 case VER_PARSE_SYM_CLOSE:
00196                         if ( Vec_IntSize( vStackOp ) )
00197             {
00198                                 while ( 1 )
00199                             {
00200                                     if ( !Vec_IntSize( vStackOp ) )
00201                                         {
00202                                                 sprintf( pErrorMessage, "Parse_FormulaParser(): There is no opening paranthesis\n" );
00203                                                 Flag = VER_PARSE_FLAG_ERROR; 
00204                         break;
00205                                         }
00206                                         Oper = Vec_IntPop( vStackOp );
00207                                         if ( Oper == VER_PARSE_OPER_MARK )
00208                                                 break;
00209                     // skip the second MUX operation
00210 //                    if ( Oper == VER_PARSE_OPER_MUX2 )
00211 //                    {
00212 //                                          Oper = Vec_IntPop( vStackOp );
00213 //                        assert( Oper == VER_PARSE_OPER_MUX1 );
00214 //                    }
00215 
00216                     // perform the given operation
00217                     if ( Ver_FormulaParserTopOper( pMan, vStackFn, Oper ) == NULL )
00218                         {
00219                                 sprintf( pErrorMessage, "Parse_FormulaParser(): Unknown operation\n" );
00220                                 return NULL;
00221                         }
00222                             }
00223             }
00224                     else
00225                         {
00226                                 sprintf( pErrorMessage, "Parse_FormulaParser(): There is no opening paranthesis\n" );
00227                                 Flag = VER_PARSE_FLAG_ERROR; 
00228                 break;
00229                         }
00230                         if ( Flag != VER_PARSE_FLAG_ERROR )
00231                             Flag = VER_PARSE_FLAG_VAR; 
00232                         break;
00233 
00234 
00235                 default:
00236             // scan the next name
00237             v = Ver_FormulaParserFindVar( pTemp, vNames );
00238             if ( *pTemp == '\\' )
00239                 pTemp++;
00240             pTemp += (int)Vec_PtrEntry( vNames, 2*v ) - 1;
00241 
00242                         // assume operation AND, if vars follow one another
00243                         if ( Flag == VER_PARSE_FLAG_VAR )
00244             {
00245                         sprintf( pErrorMessage, "Parse_FormulaParser(): Incorrect state." );
00246                 return NULL;
00247             }
00248             bTemp = Hop_IthVar( pMan, v );
00249                         Vec_PtrPush( vStackFn, bTemp ); //  Cudd_Ref( bTemp );
00250             Flag = VER_PARSE_FLAG_VAR; 
00251             break;
00252             }
00253 
00254                 if ( Flag == VER_PARSE_FLAG_ERROR )
00255                         break;      // error exit
00256                 else if ( Flag == VER_PARSE_FLAG_START )
00257                         continue;  //  go on parsing
00258                 else if ( Flag == VER_PARSE_FLAG_VAR )
00259                         while ( 1 )
00260                         {  // check if there are negations in the OpStack     
00261                                 if ( !Vec_IntSize(vStackOp) )
00262                                         break;
00263                 Oper = Vec_IntPop( vStackOp );
00264                                 if ( Oper != VER_PARSE_OPER_NEG )
00265                 {
00266                                         Vec_IntPush( vStackOp, Oper );
00267                                         break;
00268                 }
00269                                 else
00270                                 {
00271 //                                      Vec_PtrPush( vStackFn, Cudd_Not(Vec_PtrPop(vStackFn)) );
00272                                 Vec_PtrPush( vStackFn, Hop_Not(Vec_PtrPop(vStackFn)) );
00273                                 }
00274                         }
00275                 else // if ( Flag == VER_PARSE_FLAG_OPER )
00276                         while ( 1 )
00277                         {  // execute all the operations in the OpStack
00278                            // with precedence higher or equal than the last one
00279                                 Oper1 = Vec_IntPop( vStackOp ); // the last operation
00280                                 if ( !Vec_IntSize(vStackOp) ) 
00281                                 {  // if it is the only operation, push it back
00282                                         Vec_IntPush( vStackOp, Oper1 );
00283                                         break;
00284                                 }
00285                                 Oper2 = Vec_IntPop( vStackOp ); // the operation before the last one
00286                                 if ( Oper2 >= Oper1 && !(Oper1 == Oper2 && Oper1 == VER_PARSE_OPER_MUX) )  
00287                                 {  // if Oper2 precedence is higher or equal, execute it
00288                     if ( Ver_FormulaParserTopOper( pMan, vStackFn, Oper2 ) == NULL )
00289                         {
00290                                 sprintf( pErrorMessage, "Parse_FormulaParser(): Unknown operation\n" );
00291                                 return NULL;
00292                         }
00293                                         Vec_IntPush( vStackOp,  Oper1 );     // push the last operation back
00294                                 }
00295                                 else
00296                                 {  // if Oper2 precedence is lower, push them back and done
00297                                         Vec_IntPush( vStackOp, Oper2 );
00298                                         Vec_IntPush( vStackOp, Oper1 );
00299                                         break;
00300                                 }
00301                         }
00302     }
00303 
00304         if ( Flag != VER_PARSE_FLAG_ERROR )
00305     {
00306                 if ( Vec_PtrSize(vStackFn) )
00307             {   
00308                         bFunc = Vec_PtrPop(vStackFn);
00309                         if ( !Vec_PtrSize(vStackFn) )
00310                                 if ( !Vec_IntSize(vStackOp) )
00311                 {
00312 //                    Cudd_Deref( bFunc );
00313                                         return bFunc;
00314                 }
00315                                 else
00316                                         sprintf( pErrorMessage, "Parse_FormulaParser(): Something is left in the operation stack\n" );
00317                         else
00318                                 sprintf( pErrorMessage, "Parse_FormulaParser(): Something is left in the function stack\n" );
00319             }
00320             else
00321                         sprintf( pErrorMessage, "Parse_FormulaParser(): The input string is empty\n" );
00322     }
00323 //    Cudd_Ref( bFunc );
00324 //    Cudd_RecursiveDeref( dd, bFunc );
00325         return NULL;
00326 }

void* Ver_FormulaReduction ( char *  pFormula,
void *  pMan,
Vec_Ptr_t vNames,
char *  pErrorMessage 
)

Function*************************************************************

Synopsis [Returns the AIG representation of the reduction formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 432 of file verFormula.c.

00433 {
00434     Hop_Obj_t * pRes;
00435     int v, fCompl;
00436     char Symbol;
00437 
00438     // get the operation
00439     Symbol = *pFormula++;
00440     fCompl = ( Symbol == '~' );
00441     if ( fCompl )
00442         Symbol = *pFormula++;
00443     // check the operation
00444     if ( Symbol != '&' && Symbol != '|' && Symbol != '^' )
00445     {
00446                 sprintf( pErrorMessage, "Ver_FormulaReduction(): Unknown operation (%c)\n", Symbol );
00447                 return NULL;
00448     }
00449     // skip the brace
00450     while ( *pFormula++ != '{' );
00451     // parse the names
00452     Vec_PtrClear( vNames );
00453     while ( *pFormula != '}' )
00454     {
00455         v = Ver_FormulaParserFindVar( pFormula, vNames );
00456         pFormula += (int)Vec_PtrEntry( vNames, 2*v );
00457         while ( *pFormula == ' ' || *pFormula == ',' )
00458             pFormula++;
00459     }
00460     // compute the function
00461     if ( Symbol == '&' )
00462         pRes = Hop_CreateAnd( pMan, Vec_PtrSize(vNames)/2 );
00463     else if ( Symbol == '|' )
00464         pRes = Hop_CreateOr( pMan, Vec_PtrSize(vNames)/2 );
00465     else if ( Symbol == '^' )
00466         pRes = Hop_CreateExor( pMan, Vec_PtrSize(vNames)/2 );
00467     return Hop_NotCond( pRes, fCompl );
00468 }

Abc_Lib_t* Ver_ParseFile ( char *  pFileName,
Abc_Lib_t pGateLib,
int  fCheck,
int  fUseMemMan 
)

MACRO DEFINITIONS /// ITERATORS /// FUNCTION DECLARATIONS ///

Function*************************************************************

Synopsis [File parser.]

Description []

SideEffects []

SeeAlso []

Definition at line 155 of file verCore.c.

00156 {
00157     Ver_Man_t * p;
00158     Abc_Lib_t * pDesign;
00159     // start the parser
00160     p = Ver_ParseStart( pFileName, pGateLib );
00161     p->fMapped    = glo_fMapped;
00162     p->fCheck     = fCheck;
00163     p->fUseMemMan = fUseMemMan;
00164     if ( glo_fMapped )
00165     {
00166         Hop_ManStop(p->pDesign->pManFunc);
00167         p->pDesign->pManFunc = NULL;
00168     }
00169     // parse the file
00170     Ver_ParseInternal( p );
00171     // save the result
00172     pDesign = p->pDesign;
00173     p->pDesign = NULL;
00174     // stop the parser
00175     Ver_ParseStop( p );
00176     return pDesign;
00177 }

char* Ver_ParseGetName ( Ver_Man_t pMan  ) 

Function*************************************************************

Synopsis [Parses a Verilog name that can be being with a slash.]

Description []

SideEffects []

SeeAlso []

Definition at line 88 of file verParse.c.

00089 {
00090     Ver_Stream_t * p = pMan->pReader;
00091     char Symbol;
00092     char * pWord;
00093     pMan->fNameLast = 0;
00094     if ( !Ver_StreamIsOkey(p) )
00095         return NULL;
00096     if ( !Ver_ParseSkipComments( pMan ) )
00097         return NULL;
00098     Symbol = Ver_StreamScanChar( p );
00099     if ( Symbol == '\\' )
00100     {
00101         pMan->fNameLast = 1;
00102         Ver_StreamPopChar( p );
00103         pWord = Ver_StreamGetWord( p, " \r\n" );
00104     }
00105     else
00106         pWord = Ver_StreamGetWord( p, " \t\n\r(),;" );
00107     if ( !Ver_ParseSkipComments( pMan ) )
00108         return NULL;
00109     return pWord;
00110 }

void Ver_ParsePrintErrorMessage ( Ver_Man_t p  ) 

Function*************************************************************

Synopsis [Prints the error message including the file name and line number.]

Description []

SideEffects []

SeeAlso []

Definition at line 268 of file verCore.c.

00269 {
00270     p->fError = 1;
00271     if ( p->fTopLevel ) // the line number is not given
00272         fprintf( p->Output, "%s: %s\n", p->pFileName, p->sError );
00273     else // print the error message with the line number
00274         fprintf( p->Output, "%s (line %d): %s\n", 
00275             p->pFileName, Ver_StreamGetLineNumber(p->pReader), p->sError );
00276     // free the data
00277     Ver_ParseFreeData( p );
00278 }

int Ver_ParseSkipComments ( Ver_Man_t pMan  ) 

CFile****************************************************************

FileName [verParse.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Verilog parser.]

Synopsis [Performs some Verilog parsing tasks.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - August 19, 2006.]

Revision [

Id
verParse.c,v 1.00 2006/08/19 00:00:00 alanmi Exp

] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Skips the comments of they are present.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file verParse.c.

00043 {
00044     Ver_Stream_t * p = pMan->pReader;
00045     char Symbol;
00046     // skip spaces
00047     Ver_StreamSkipChars( p, " \t\n\r" );
00048     if ( !Ver_StreamIsOkey(pMan->pReader) )
00049         return 1;
00050     // read the first symbol
00051     Symbol = Ver_StreamScanChar( p );
00052     if ( Symbol != '/' )
00053         return 1;
00054     Ver_StreamPopChar( p );
00055     // read the second symbol
00056     Symbol = Ver_StreamScanChar( p );
00057     if ( Symbol == '/' )
00058     { // skip till the end of line
00059         Ver_StreamSkipToChars( p, "\n" );
00060         return Ver_ParseSkipComments( pMan );
00061     }
00062     if ( Symbol == '*' )
00063     { // skip till the next occurance of */
00064         Ver_StreamPopChar( p );
00065         do {
00066             Ver_StreamSkipToChars( p, "*" );
00067             Ver_StreamPopChar( p );
00068         } while ( Ver_StreamScanChar( p ) != '/' );
00069         Ver_StreamPopChar( p );
00070         return Ver_ParseSkipComments( pMan );
00071     }
00072     sprintf( pMan->sError, "Cannot parse after symbol \"/\"." );
00073     Ver_ParsePrintErrorMessage( pMan );
00074     return 0;
00075 }

Ver_Stream_t* Ver_StreamAlloc ( char *  pFileName  ) 

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Starts the file reader for the given file.]

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file verStream.c.

00072 {
00073     Ver_Stream_t * p;
00074     FILE * pFile;
00075     int nCharsToRead;
00076     // check if the file can be opened
00077     pFile = fopen( pFileName, "rb" );
00078     if ( pFile == NULL )
00079     {
00080         printf( "Ver_StreamAlloc(): Cannot open input file \"%s\".\n", pFileName );
00081         return NULL;
00082     }
00083     // start the file reader    
00084     p = ALLOC( Ver_Stream_t, 1 );
00085     memset( p, 0, sizeof(Ver_Stream_t) );
00086     p->pFileName   = pFileName;
00087     p->pFile       = pFile;
00088     // get the file size, in bytes
00089     fseek( pFile, 0, SEEK_END );  
00090     p->nFileSize = ftell( pFile );  
00091     rewind( pFile ); 
00092     // allocate the buffer
00093     p->pBuffer = ALLOC( char, VER_BUFFER_SIZE+1 );
00094     p->nBufferSize = VER_BUFFER_SIZE;
00095     p->pBufferCur  = p->pBuffer;
00096     // determine how many chars to read
00097     nCharsToRead = VER_MINIMUM(p->nFileSize, VER_BUFFER_SIZE);
00098     // load the first part into the buffer
00099     fread( p->pBuffer, nCharsToRead, 1, p->pFile );
00100     p->nFileRead = nCharsToRead;
00101     // set the ponters to the end and the stopping point
00102     p->pBufferEnd  = p->pBuffer + nCharsToRead;
00103     p->pBufferStop = (p->nFileRead == p->nFileSize)? p->pBufferEnd : p->pBuffer + VER_BUFFER_SIZE - VER_OFFSET_SIZE;
00104     // start the arrays
00105     p->nLineCounter = 1; // 1-based line counting
00106     return p;
00107 }

void Ver_StreamFree ( Ver_Stream_t p  ) 

Function*************************************************************

Synopsis [Stops the file reader.]

Description []

SideEffects []

SeeAlso []

Definition at line 152 of file verStream.c.

00153 {
00154     if ( p->pFile )
00155         fclose( p->pFile );
00156     FREE( p->pBuffer );
00157     free( p );
00158 }

int Ver_StreamGetCurPosition ( Ver_Stream_t p  ) 

Function*************************************************************

Synopsis [Returns the current reading position.]

Description []

SideEffects []

SeeAlso []

Definition at line 203 of file verStream.c.

00204 {
00205     return p->nFileRead - (p->pBufferEnd - p->pBufferCur);
00206 }

char* Ver_StreamGetFileName ( Ver_Stream_t p  ) 

Function*************************************************************

Synopsis [Returns the file size.]

Description []

SideEffects []

SeeAlso []

Definition at line 171 of file verStream.c.

00172 {
00173     return p->pFileName;
00174 }

int Ver_StreamGetFileSize ( Ver_Stream_t p  ) 

Function*************************************************************

Synopsis [Returns the file size.]

Description []

SideEffects []

SeeAlso []

Definition at line 187 of file verStream.c.

00188 {
00189     return p->nFileSize;
00190 }

int Ver_StreamGetLineNumber ( Ver_Stream_t p  ) 

Function*************************************************************

Synopsis [Returns the line number for the given token.]

Description []

SideEffects []

SeeAlso []

Definition at line 219 of file verStream.c.

00220 {
00221     return p->nLineCounter;
00222 }

char* Ver_StreamGetWord ( Ver_Stream_t p,
char *  pCharsToStop 
)

Function*************************************************************

Synopsis [Returns current word delimited by the set of symbols.]

Description [Modifies the stream by inserting 0 at the first encounter of one of the symbols in the list.]

SideEffects []

SeeAlso []

Definition at line 392 of file verStream.c.

00393 {
00394     char * pChar, * pTemp;
00395     if ( p->fStop )
00396         return NULL;
00397     assert( pCharsToStop != NULL );
00398     // check if the new data should to be loaded
00399     if ( p->pBufferCur > p->pBufferStop )
00400         Ver_StreamReload( p );
00401     // skip the symbols
00402     p->nChars = 0;
00403     for ( pChar = p->pBufferCur; pChar < p->pBufferEnd; pChar++ )
00404     {
00405         // skip symbols as long as they are NOT in the list
00406         for ( pTemp = pCharsToStop; *pTemp; pTemp++ )
00407             if ( *pChar == *pTemp )
00408                 break;
00409         if ( *pTemp == 0 ) // pChar is not found in the list
00410         {
00411             p->pChars[p->nChars++] = *pChar;
00412             if ( p->nChars == VER_WORD_SIZE )
00413             {
00414                 printf( "Ver_StreamGetWord(): The buffer size is exceeded.\n" );
00415                 return NULL;
00416             }
00417             // count the lines
00418             if ( *pChar == '\n' )
00419                 p->nLineCounter++;
00420             continue;
00421         }
00422         // the symbol is found - move the position, set the word end, return the word
00423         p->pBufferCur = pChar;
00424         p->pChars[p->nChars] = 0;
00425         return p->pChars;
00426     }
00427     // the file is finished or the last part continued 
00428     // through VER_OFFSET_SIZE chars till the end of the buffer
00429     if ( p->pBufferStop == p->pBufferEnd ) // end of file
00430     {
00431         p->fStop = 1;
00432         p->pChars[p->nChars] = 0;
00433         return p->pChars;
00434     }
00435     printf( "Ver_StreamGetWord() failed to parse the file \"%s\".\n", p->pFileName );
00436     return NULL;
00437 }

int Ver_StreamIsOkey ( Ver_Stream_t p  ) 

Function*************************************************************

Synopsis [Returns current symbol.]

Description []

SideEffects []

SeeAlso []

Definition at line 237 of file verStream.c.

00238 {
00239     return !p->fStop;
00240 }

char Ver_StreamPopChar ( Ver_Stream_t p  ) 

Function*************************************************************

Synopsis [Returns current symbol and moves to the next.]

Description []

SideEffects []

SeeAlso []

Definition at line 270 of file verStream.c.

00271 {
00272     assert( !p->fStop );
00273     // check if the new data should to be loaded
00274     if ( p->pBufferCur > p->pBufferStop )
00275         Ver_StreamReload( p );
00276     // check if there are symbols left
00277     if ( p->pBufferCur == p->pBufferEnd ) // end of file
00278     {
00279         p->fStop = 1;
00280         return -1;
00281     }
00282     // count the lines
00283     if ( *p->pBufferCur == '\n' )
00284         p->nLineCounter++;
00285     return *p->pBufferCur++;
00286 }

char Ver_StreamScanChar ( Ver_Stream_t p  ) 

Function*************************************************************

Synopsis [Returns current symbol.]

Description []

SideEffects []

SeeAlso []

Definition at line 253 of file verStream.c.

00254 {
00255     assert( !p->fStop );
00256     return *p->pBufferCur;
00257 }

void Ver_StreamSkipChars ( Ver_Stream_t p,
char *  pCharsToSkip 
)

Function*************************************************************

Synopsis [Skips the current symbol and all symbols from the list.]

Description []

SideEffects []

SeeAlso []

Definition at line 299 of file verStream.c.

00300 {
00301     char * pChar, * pTemp;
00302     assert( !p->fStop );
00303     assert( pCharsToSkip != NULL );
00304     // check if the new data should to be loaded
00305     if ( p->pBufferCur > p->pBufferStop )
00306         Ver_StreamReload( p );
00307     // skip the symbols
00308     for ( pChar = p->pBufferCur; pChar < p->pBufferEnd; pChar++ )
00309     {
00310         // skip symbols as long as they are in the list
00311         for ( pTemp = pCharsToSkip; *pTemp; pTemp++ )
00312             if ( *pChar == *pTemp )
00313                 break;
00314         if ( *pTemp == 0 ) // pChar is not found in the list
00315         {
00316             p->pBufferCur = pChar;
00317             return;
00318         }
00319         // count the lines
00320         if ( *pChar == '\n' )
00321             p->nLineCounter++;
00322     }
00323     // the file is finished or the last part continued 
00324     // through VER_OFFSET_SIZE chars till the end of the buffer
00325     if ( p->pBufferStop == p->pBufferEnd ) // end of file
00326     {
00327         p->fStop = 1;
00328         return;
00329     }
00330     printf( "Ver_StreamSkipSymbol() failed to parse the file \"%s\".\n", p->pFileName );
00331 }

void Ver_StreamSkipToChars ( Ver_Stream_t p,
char *  pCharsToStop 
)

Function*************************************************************

Synopsis [Skips all symbols until encountering one from the list.]

Description []

SideEffects []

SeeAlso []

Definition at line 344 of file verStream.c.

00345 {
00346     char * pChar, * pTemp;
00347     assert( !p->fStop );
00348     assert( pCharsToStop != NULL );
00349     // check if the new data should to be loaded
00350     if ( p->pBufferCur > p->pBufferStop )
00351         Ver_StreamReload( p );
00352     // skip the symbols
00353     for ( pChar = p->pBufferCur; pChar < p->pBufferEnd; pChar++ )
00354     {
00355         // skip symbols as long as they are NOT in the list
00356         for ( pTemp = pCharsToStop; *pTemp; pTemp++ )
00357             if ( *pChar == *pTemp )
00358                 break;
00359         if ( *pTemp == 0 ) // pChar is not found in the list
00360         {
00361             // count the lines
00362             if ( *pChar == '\n' )
00363                 p->nLineCounter++;
00364             continue;
00365         }
00366         // the symbol is found - move position and return
00367         p->pBufferCur = pChar;
00368         return;
00369     }
00370     // the file is finished or the last part continued 
00371     // through VER_OFFSET_SIZE chars till the end of the buffer
00372     if ( p->pBufferStop == p->pBufferEnd ) // end of file
00373     {
00374         p->fStop = 1;
00375         return;
00376     }
00377     printf( "Ver_StreamSkipToSymbol() failed to parse the file \"%s\".\n", p->pFileName );
00378 }


Generated on Tue Jan 5 12:18:50 2010 for abc70930 by  doxygen 1.6.1