74 gArg2 = (
Vec_Int_t *)Vec_PtrPop( pStackFn );
75 gArg1 = (
Vec_Int_t *)Vec_PtrPop( pStackFn );
77 gFunc = Exp_And( pMan, nVars, gArg1, gArg2, 0, 0 );
79 gFunc = Exp_Or( pMan, nVars, gArg1, gArg2 );
81 gFunc = Exp_Xor( pMan, nVars, gArg1, gArg2 );
89 Vec_PtrPush( pStackFn, gFunc );
108 int Man = nVars, * pMan = &Man;
112 char * pTemp, * pName;
113 int nParans, fFound, Flag;
114 int Oper, Oper1, Oper2;
119 for ( pTemp = pFormInit; *pTemp; pTemp++ )
122 else if ( *pTemp ==
')' )
126 fprintf( stdout,
"Mio_ParseFormula(): Different number of opening and closing parentheses ().\n" );
132 sprintf( pFormula,
"(%s)", pFormInit );
135 pStackFn = Vec_PtrAlloc( 100 );
136 pStackOp = Vec_IntAlloc( 100 );
139 for ( pTemp = pFormula; *pTemp; pTemp++ )
150 Vec_PtrPush( pStackFn, Exp_Const0() );
153 fprintf( stdout,
"Mio_ParseFormula(): No operation symbol before constant 0.\n" );
160 Vec_PtrPush( pStackFn, Exp_Const1() );
163 fprintf( stdout,
"Mio_ParseFormula(): No operation symbol before constant 1.\n" );
180 fprintf( stdout,
"Mio_ParseFormula(): No variable is specified before the negation suffix.\n" );
185 Vec_PtrPush( pStackFn, Exp_Not( (
Vec_Int_t *)Vec_PtrPop(pStackFn) ) );
194 fprintf( stdout,
"Mio_ParseFormula(): There is no variable before AND, EXOR, or OR.\n" );
219 if ( Vec_IntSize( pStackOp ) != 0 )
223 if ( Vec_IntSize( pStackOp ) == 0 )
225 fprintf( stdout,
"Mio_ParseFormula(): There is no opening parenthesis\n" );
229 Oper = Vec_IntPop( pStackOp );
236 fprintf( stdout,
"Mio_ParseFormula(): Unknown operation\n" );
238 Vec_PtrFreeP( &pStackFn );
239 Vec_IntFreeP( &pStackOp );
246 fprintf( stdout,
"Mio_ParseFormula(): There is no opening parenthesis\n" );
257 for ( i = 0; pTemp[i] &&
258 pTemp[i] !=
' ' && pTemp[i] !=
'\t' && pTemp[i] !=
'\r' && pTemp[i] !=
'\n' &&
265 fprintf( stdout,
"Mio_ParseFormula(): The negation sign or an opening parenthesis inside the variable name.\n" );
273 for ( v = 0; v < nVars; v++ )
275 pName = ppVarNames[v];
276 if (
strncmp(pTemp, pName, i) == 0 &&
strlen(pName) == (
unsigned)i )
285 fprintf( stdout,
"Mio_ParseFormula(): The parser cannot find var \"%s\" in the input var list.\n", pTemp );
300 Vec_PtrPush( pStackFn, Exp_Var(v) );
312 if ( Vec_IntSize( pStackOp ) == 0 )
314 Oper = Vec_IntPop( pStackOp );
317 Vec_IntPush( pStackOp, Oper );
322 Vec_PtrPush( pStackFn, Exp_Not((
Vec_Int_t *)Vec_PtrPop(pStackFn)) );
329 Oper1 = Vec_IntPop( pStackOp );
330 if ( Vec_IntSize( pStackOp ) == 0 )
332 Vec_IntPush( pStackOp, Oper1 );
335 Oper2 = Vec_IntPop( pStackOp );
336 if ( Oper2 >= Oper1 )
340 fprintf( stdout,
"Mio_ParseFormula(): Unknown operation\n" );
342 Vec_PtrFreeP( &pStackFn );
343 Vec_IntFreeP( &pStackOp );
346 Vec_IntPush( pStackOp, Oper1 );
350 Vec_IntPush( pStackOp, Oper2 );
351 Vec_IntPush( pStackOp, Oper1 );
359 if ( Vec_PtrSize(pStackFn) != 0 )
361 gFunc = (
Vec_Int_t *)Vec_PtrPop(pStackFn);
362 if ( Vec_PtrSize(pStackFn) == 0 )
363 if ( Vec_IntSize( pStackOp ) == 0 )
367 Vec_PtrFreeP( &pStackFn );
368 Vec_IntFreeP( &pStackOp );
369 return Exp_Reverse(gFunc);
372 fprintf( stdout,
"Mio_ParseFormula(): Something is left in the operation stack\n" );
374 fprintf( stdout,
"Mio_ParseFormula(): Something is left in the function stack\n" );
377 fprintf( stdout,
"Mio_ParseFormula(): The input string is empty\n" );
380 Vec_PtrFreeP( &pStackFn );
381 Vec_IntFreeP( &pStackOp );
Vec_Int_t * Mio_ParseFormulaOper(int *pMan, int nVars, Vec_Ptr_t *pStackFn, int Oper)
FUNCTION DEFINITIONS ///.