32 #define PARSE_EQN_SYM_OPEN '(' // opening paranthesis
33 #define PARSE_EQN_SYM_CLOSE ')' // closing paranthesis
34 #define PARSE_EQN_SYM_CONST0 '0' // constant 0
35 #define PARSE_EQN_SYM_CONST1 '1' // constant 1
36 #define PARSE_EQN_SYM_NEG '!' // negation before the variable
37 #define PARSE_EQN_SYM_AND '*' // logic AND
38 #define PARSE_EQN_SYM_OR '+' // logic OR
41 #define PARSE_EQN_OPER_NEG 10 // negation
42 #define PARSE_EQN_OPER_AND 9 // logic AND
43 #define PARSE_EQN_OPER_OR 7 // logic OR
44 #define PARSE_EQN_OPER_MARK 1 // OpStack token standing for an opening paranthesis
47 #define PARSE_EQN_FLAG_START 1 // after the opening parenthesis
48 #define PARSE_EQN_FLAG_VAR 2 // after operation is received
49 #define PARSE_EQN_FLAG_OPER 3 // after operation symbol is received
50 #define PARSE_EQN_FLAG_ERROR 4 // when error is detected
52 #define PARSE_EQN_STACKSIZE 1000
78 char * pTemp, * pName;
79 int nParans, fFound, Flag;
80 int Oper, Oper1, Oper2;
85 for ( pTemp = pFormInit; *pTemp; pTemp++ )
88 else if ( *pTemp ==
')' )
92 fprintf( pOutput,
"Parse_FormulaParserEqn(): Different number of opening and closing parantheses ().\n" );
98 sprintf( pFormula,
"(%s)", pFormInit );
105 for ( pTemp = pFormula; *pTemp; pTemp++ )
119 fprintf( pOutput,
"Parse_FormulaParserEqn(): No operation symbol before constant 0.\n" );
129 fprintf( pOutput,
"Parse_FormulaParserEqn(): No operation symbol before constant 1.\n" );
147 fprintf( pOutput,
"Parse_FormulaParserEqn(): There is no variable before AND, EXOR, or OR.\n" );
161 fprintf( pOutput,
"Parse_FormulaParserEqn(): An opening paranthesis follows a var without operation sign.\n" );
176 fprintf( pOutput,
"Parse_FormulaParserEqn(): There is no opening paranthesis\n" );
189 fprintf( pOutput,
"Parse_FormulaParserEqn(): Unknown operation\n" );
197 fprintf( pOutput,
"Parse_FormulaParserEqn(): There is no opening paranthesis\n" );
208 for ( i = 0; pTemp[i] &&
209 pTemp[i] !=
' ' && pTemp[i] !=
'\t' && pTemp[i] !=
'\r' && pTemp[i] !=
'\n' &&
214 fprintf( pOutput,
"Parse_FormulaParserEqn(): The negation sign or an opening paranthesis inside the variable name.\n" );
222 if (
strncmp(pTemp, pName, i) == 0 &&
strlen(pName) == (
unsigned)i )
230 fprintf( pOutput,
"Parse_FormulaParserEqn(): The parser cannot find var \"%s\" in the input var list.\n", pTemp );
236 fprintf( pOutput,
"Parse_FormulaParserEqn(): The variable name \"%s\" follows another var without operation sign.\n", pTemp );
276 if ( Oper2 >= Oper1 )
280 fprintf( pOutput,
"Parse_FormulaParserEqn(): Unknown operation\n" );
312 fprintf( pOutput,
"Parse_FormulaParserEqn(): Something is left in the operation stack\n" );
314 fprintf( pOutput,
"Parse_FormulaParserEqn(): Something is left in the function stack\n" );
317 fprintf( pOutput,
"Parse_FormulaParserEqn(): The input string is empty\n" );
341 gFunc =
Hop_And( pMan, gArg1, gArg2 );
343 gFunc =
Hop_Or( pMan, gArg1, gArg2 );
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define PARSE_EQN_SYM_NEG
#define PARSE_EQN_FLAG_OPER
Hop_Obj_t * Hop_Or(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Parse_StackOp_t * Parse_StackOpStart(int nDepth)
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
void * Parse_StackFnPop(Parse_StackFn_t *p)
#define PARSE_EQN_SYM_AND
#define PARSE_EQN_OPER_OR
#define ABC_ALLOC(type, num)
void Parse_StackFnFree(Parse_StackFn_t *p)
static Hop_Obj_t * Hop_Not(Hop_Obj_t *p)
int Parse_StackFnIsEmpty(Parse_StackFn_t *p)
int Parse_StackOpIsEmpty(Parse_StackOp_t *p)
#define PARSE_EQN_SYM_CLOSE
#define ABC_NAMESPACE_IMPL_END
static Hop_Obj_t * Parse_ParserPerformTopOp(Hop_Man_t *pMan, Parse_StackFn_t *pStackFn, int Oper)
#define PARSE_EQN_FLAG_START
void Parse_StackOpPush(Parse_StackOp_t *p, int Oper)
#define PARSE_EQN_SYM_CONST1
#define PARSE_EQN_FLAG_VAR
typedefABC_NAMESPACE_HEADER_START struct ParseStackFnStruct Parse_StackFn_t
INCLUDES ///.
#define PARSE_EQN_FLAG_ERROR
#define ABC_NAMESPACE_IMPL_START
#define PARSE_EQN_STACKSIZE
#define PARSE_EQN_SYM_OPEN
DECLARATIONS ///.
#define PARSE_EQN_OPER_AND
void Parse_StackOpFree(Parse_StackOp_t *p)
Hop_Obj_t * Parse_FormulaParserEqn(FILE *pOutput, char *pFormInit, Vec_Ptr_t *vVarNames, Hop_Man_t *pMan)
FUNCTION DEFINITIONS ///.
void Parse_StackFnPush(Parse_StackFn_t *p, void *bFunc)
#define PARSE_EQN_OPER_MARK
Parse_StackFn_t * Parse_StackFnStart(int nDepth)
GLOBAL VARIABLES ///.
#define PARSE_EQN_SYM_CONST0
static Hop_Obj_t * Hop_ManConst0(Hop_Man_t *p)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
int Parse_StackOpPop(Parse_StackOp_t *p)
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
#define PARSE_EQN_OPER_NEG