abc/src/map/mapper/mapperSuper.c
/**Function*************************************************************

  Synopsis    [Performs one step of parsing the formula into parts.]

  Description [This function will eventually be replaced when the
  tree-supergate library representation will become standard.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Performs one step of parsing the formula into parts.]

Description [This function will eventually be replaced when the
tree-supergate library representation will become standard.]




Function Synopsis [ Performs one step of parsing the formula into parts . ] Description [ This function will eventually be replaced when the tree - supergate library representation will become standard . ]
char * Map_LibraryReadFormulaStep( char * pFormula, char * pStrings[], int * pnStrings )
{
    char * pName, * pPar1, * pPar2, * pCur;
    int nStrings, CountPars;
    for ( pName = pFormula; *pName && *pName == ' '; pName++ );
    assert( *pName );
    for ( pPar1 = pName; *pPar1 && *pPar1 != '('; pPar1++ );
    if ( *pPar1 == 0 )
    {
        *pnStrings = 0;
        return pName;
    }
    assert( *pPar1 == '(' );
    *pPar1 = 0;
    for ( CountPars = 1, pPar2 = pPar1 + 1; *pPar2 && CountPars; pPar2++ )
        if ( *pPar2 == '(' )
            CountPars++;
        else if ( *pPar2 == ')' )
            CountPars--;
    pPar2--;
    assert( CountPars == 0 );
    assert( *pPar2 == ')' );
    *pPar2 = 0;
    nStrings = 0;
    pCur = pPar1 + 1;
    while ( 1 )
    {
        pStrings[ nStrings++ ] = pCur;
        for ( CountPars = 0; *pCur && (CountPars || *pCur != ','); pCur++ )
            if ( *pCur == '(' )
                CountPars++;
            else if ( *pCur == ')' )
                CountPars--;
        if ( *pCur == 0 )
            break;
        assert( *pCur == ',' );
        *pCur = 0;
        pCur++;
    }
    *pnStrings = nStrings;
    return pName;
}
char * Map_LibraryReadFormulaStep ( char * pFormula , char * pStrings [ ] , int * pnStrings ) { char * pName , * pPar1 , * pPar2 , * pCur ; int nStrings , CountPars ; for ( pName = pFormula ; * pName && * pName == ' ' ; pName ++ ) ; assert ( * pName ) ; for ( pPar1 = pName ; * pPar1 && * pPar1 != ' ' ; pPar1 ++ ) ; if ( * pPar1 == 0 ) { * pnStrings = 0 ; return pName ; } assert ( * pPar1 == ' ' ) ; * pPar1 = 0 ; for ( CountPars = 1 , pPar2 = pPar1 + 1 ; * pPar2 && CountPars ; pPar2 ++ ) if ( * pPar2 == ' ' ) CountPars ++ ; else if ( * pPar2 == ' ' ) CountPars -- ; pPar2 -- ; assert ( CountPars == 0 ) ; assert ( * pPar2 == ' ' ) ; * pPar2 = 0 ; nStrings = 0 ; pCur = pPar1 + 1 ; while ( 1 ) { pStrings [ nStrings ++ ] = pCur ; for ( CountPars = 0 ; * pCur && ( CountPars || * pCur != ' ' ) ; pCur ++ ) if ( * pCur == ' ' ) CountPars ++ ; else if ( * pCur == ' ' ) CountPars -- ; if ( * pCur == 0 ) break ; assert ( * pCur == ' ' ) ; * pCur = 0 ; pCur ++ ; } * pnStrings = nStrings ; return pName ; }
Function
Synopsis    [Performs one step of parsing the formula into parts.]
Function Synopsis [ Performs one step of parsing the formula into parts . ]
// skip leading spaces // find the first opening parenthesis // overwrite it with space // find the corresponding closing parenthesis // overwrite it with space // save the intervals between the commas // save the current string // find the beginning of the next string // save the results and return