50 #define PARSE_SYM_OPEN '(' // opening paranthesis
51 #define PARSE_SYM_CLOSE ')' // closing paranthesis
52 #define PARSE_SYM_LOWER '[' // shifts one rank down
53 #define PARSE_SYM_RAISE ']' // shifts one rank up
54 #define PARSE_SYM_CONST0 '0' // constant 0
55 #define PARSE_SYM_CONST1 '1' // constant 1
56 #define PARSE_SYM_NEGBEF1 '!' // negation before the variable
57 #define PARSE_SYM_NEGBEF2 '~' // negation before the variable
58 #define PARSE_SYM_NEGAFT '\'' // negation after the variable
59 #define PARSE_SYM_AND1 '&' // logic AND
60 #define PARSE_SYM_AND2 '*' // logic AND
61 #define PARSE_SYM_XOR1 '<' // logic EXOR (the 1st symbol)
62 #define PARSE_SYM_XOR2 '+' // logic EXOR (the 2nd symbol)
63 #define PARSE_SYM_XOR3 '>' // logic EXOR (the 3rd symbol)
64 #define PARSE_SYM_XOR '^' // logic XOR
65 #define PARSE_SYM_OR1 '+' // logic OR
66 #define PARSE_SYM_OR2 '|' // logic OR
67 #define PARSE_SYM_EQU1 '<' // equvalence (the 1st symbol)
68 #define PARSE_SYM_EQU2 '=' // equvalence (the 2nd symbol)
69 #define PARSE_SYM_EQU3 '>' // equvalence (the 3rd symbol)
70 #define PARSE_SYM_FLR1 '=' // implication (the 1st symbol)
71 #define PARSE_SYM_FLR2 '>' // implication (the 2nd symbol)
72 #define PARSE_SYM_FLL1 '<' // backward imp (the 1st symbol)
73 #define PARSE_SYM_FLL2 '=' // backward imp (the 2nd symbol)
77 #define PARSE_OPER_NEG 10 // negation
78 #define PARSE_OPER_AND 9 // logic AND
79 #define PARSE_OPER_XOR 8 // logic EXOR (a'b | ab')
80 #define PARSE_OPER_OR 7 // logic OR
81 #define PARSE_OPER_EQU 6 // equvalence (a'b'| ab )
82 #define PARSE_OPER_FLR 5 // implication ( a' | b )
83 #define PARSE_OPER_FLL 4 // backward imp ( 'b | a )
84 #define PARSE_OPER_MARK 1 // OpStack token standing for an opening paranthesis
87 #define PARSE_FLAG_START 1 // after the opening parenthesis
88 #define PARSE_FLAG_VAR 2 // after operation is received
89 #define PARSE_FLAG_OPER 3 // after operation symbol is received
90 #define PARSE_FLAG_ERROR 4 // when error is detected
92 #define STACKSIZE 1000
124 int nParans, fFound, Flag;
125 int Oper, Oper1, Oper2;
130 if ( nVars * (nRanks + 1) > dd->
size )
132 printf(
"Parse_FormulaParser(): The BDD manager does not have enough variables.\n" );
138 for ( pTemp = pFormulaInit; *pTemp; pTemp++ )
141 else if ( *pTemp ==
')' )
145 fprintf( pOutput,
"Parse_FormulaParser(): Different number of opening and closing parantheses ().\n" );
150 for ( pTemp = pFormulaInit; *pTemp; pTemp++ )
153 else if ( *pTemp ==
']' )
157 fprintf( pOutput,
"Parse_FormulaParser(): Different number of opening and closing brackets [].\n" );
163 sprintf( pFormula,
"(%s)", pFormulaInit );
171 for ( pTemp = pFormula; *pTemp; pTemp++ )
187 fprintf( pOutput,
"Parse_FormulaParser(): No operation symbol before constant 0.\n" );
199 fprintf( pOutput,
"Parse_FormulaParser(): No operation symbol before constant 1.\n" );
219 fprintf( pOutput,
"Parse_FormulaParser(): No variable is specified before the negation suffix.\n" );
234 fprintf( pOutput,
"Parse_FormulaParser(): There is no variable before AND, EXOR, or OR.\n" );
250 fprintf( pOutput,
"Parse_FormulaParser(): There is no variable before Equivalence or Implication\n" );
283 fprintf( pOutput,
"Parse_FormulaParser(): Wrong symbol after \"%c\"\n",
PARSE_SYM_EQU1 );
293 fprintf( pOutput,
"Parse_FormulaParser(): There is no variable before Reverse Implication\n" );
304 fprintf( pOutput,
"Parse_FormulaParser(): Wrong symbol after \"%c\"\n",
PARSE_SYM_EQU2 );
329 fprintf( pOutput,
"Parse_FormulaParser(): There is no opening paranthesis\n" );
340 fprintf( pOutput,
"Parse_FormulaParser(): Unknown operation\n" );
356 fprintf( pOutput,
"Parse_FormulaParser(): There is no opening paranthesis\n" );
385 for ( i = 0; pTemp[i] && pTemp[i] !=
' ' && pTemp[i] !=
'\t' && pTemp[i] !=
'\r' && pTemp[i] !=
'\n' &&
392 for ( v = 0; v < nVars; v++ )
394 if (
strncmp( pTemp, ppVarNames[v], i ) == 0 &&
strlen(ppVarNames[v]) == (
unsigned)(i) )
404 fprintf( pOutput,
"Parse_FormulaParser(): The parser cannot find var \"%s\" in the input var list.\n", pTemp );
447 if ( Oper2 >= Oper1 )
452 fprintf( pOutput,
"Parse_FormulaParser(): Unknown operation\n" );
482 fprintf( pOutput,
"Parse_FormulaParser(): Something is left in the operation stack\n" );
484 fprintf( pOutput,
"Parse_FormulaParser(): Something is left in the function stack\n" );
487 fprintf( pOutput,
"Parse_FormulaParser(): The input string is empty\n" );
506 DdNode * bArg1, * bArg2, * bFunc;
#define PARSE_SYM_OPEN
DECLARATIONS ///.
Parse_StackOp_t * Parse_StackOpStart(int nDepth)
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
#define PARSE_SYM_NEGBEF2
void * Parse_StackFnPop(Parse_StackFn_t *p)
void Cudd_Deref(DdNode *node)
#define ABC_ALLOC(type, num)
void Parse_StackFnFree(Parse_StackFn_t *p)
int Parse_StackFnIsEmpty(Parse_StackFn_t *p)
DdNode * Parse_FormulaParser(FILE *pOutput, char *pFormulaInit, int nVars, int nRanks, char *ppVarNames[], DdManager *dd, DdNode *pbVars[])
FUNCTION DEFINITIONS ///.
int Parse_StackOpIsEmpty(Parse_StackOp_t *p)
static DdNode * Parse_ParserPerformTopOp(DdManager *dd, Parse_StackFn_t *pStackFn, int Oper)
#define PARSE_SYM_NEGBEF1
#define ABC_NAMESPACE_IMPL_END
void Parse_StackOpPush(Parse_StackOp_t *p, int Oper)
DdNode * Cudd_bddXnor(DdManager *dd, DdNode *f, DdNode *g)
DdNode * Cudd_bddOr(DdManager *dd, DdNode *f, DdNode *g)
typedefABC_NAMESPACE_HEADER_START struct ParseStackFnStruct Parse_StackFn_t
INCLUDES ///.
#define ABC_NAMESPACE_IMPL_START
void Parse_StackOpFree(Parse_StackOp_t *p)
DdNode * Cudd_bddXor(DdManager *dd, DdNode *f, DdNode *g)
void Parse_StackFnPush(Parse_StackFn_t *p, void *bFunc)
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Parse_StackFn_t * Parse_StackFnStart(int nDepth)
GLOBAL VARIABLES ///.
int Parse_StackOpPop(Parse_StackOp_t *p)