I am really sorry. I forgot to include the definitions and what-not. And yes, to be more specific, I would like the conditional statement to be translated into a macro that would have the same result as the if statement.
Code:
/* enable (1) or disable (0) parentheses checking in parsing strings */
/* leave disabled for part (a); enable for part (b) */
#define PARSE_PARENS 0
/* type of token */
enum token_type {
OPERAND, /* number */
OPERATOR, /* operator: +, -, *, / */
#if PARSE_PARENS
LPARENS, /* left parentheses ( */
RPARENS /* right parentheses ) */
#endif
};
/* operator identifiers (opcodes) */
enum op {
ADD, /* a+b */
SUBTRACT, /* a-b (binary) */
MULTIPLY, /* a*b */
DIVIDE, /* a/b */
NEGATE /* -a (unary) */
};
/* direction of evaluation (associativity) */
enum assoc {
LEFT, /* left-to-right (+, binary -, *, /) */
RIGHT /* right-to-left (unary -) */
};
/* number of operands for each operator type */
const unsigned int op_operands[] = {2, 2, 2, 2, 1};
/* order-of-operations (precedence) (0 = evaluated last) */
const unsigned int op_precedences[] = {0, 0, 1, 1, 2};
/* evaluation direction (associativity) for each precedence level */
const enum assoc op_associativity[] = {LEFT, LEFT, RIGHT};
/* contains value of token */
union token_value {
double operand; /* numeric value for operand */
enum op op_code; /* opcode for operators */
};
/* data structure for token */
typedef struct s_expr_token {
union token_value value; /* numeric value or opcode */
enum token_type type; /* type of token */
struct s_expr_token * linked_token; /* linked token in stack/queue */
} * p_expr_token; /* p_expr_token is shorthand for "struct s_expr_token *" */
Those are global to the whole program.
This is declared within the function I am writing, which is where I would declare the macro. I only need this macro inside this function.
Code:
p_expr_token * pstack;*pstack = NULL; /* holds pointer to top of token stack */
p_expr_token ptoken; /* current token */
EDIT: I am just lazy as all get-out, and don't want to retype that long if statement when I could shorten it to a small macro.