/* Generator attributes */
#define GEN_NOPUSH 0x01 /* Don't push lhs */
+#define GEN_COMM 0x02 /* Operator is commutative */
/* Map a generator function and its attributes to a token */
typedef struct {
/* A typecast */
TypeCast (Expr);
-
+
} else {
/* An expression */
/* Process * and / operators. */
{
static const GenDesc hie9_ops[] = {
- { TOK_STAR, GEN_NOPUSH, g_mul },
- { TOK_DIV, GEN_NOPUSH, g_div },
- { TOK_MOD, GEN_NOPUSH, g_mod },
- { TOK_INVALID, 0, 0 }
+ { TOK_STAR, GEN_NOPUSH | GEN_COMM, g_mul },
+ { TOK_DIV, GEN_NOPUSH, g_div },
+ { TOK_MOD, GEN_NOPUSH, g_mod },
+ { TOK_INVALID, 0, 0 }
};
int UsedGen;
/* Handle & (bitwise and) */
{
static const GenDesc hie4_ops[] = {
- { TOK_AND, GEN_NOPUSH, g_and },
- { TOK_INVALID, 0, 0 }
+ { TOK_AND, GEN_NOPUSH | GEN_COMM, g_and },
+ { TOK_INVALID, 0, 0 }
};
int UsedGen;
/* Handle ^ (bitwise exclusive or) */
{
static const GenDesc hie3_ops[] = {
- { TOK_XOR, GEN_NOPUSH, g_xor },
- { TOK_INVALID, 0, 0 }
+ { TOK_XOR, GEN_NOPUSH | GEN_COMM, g_xor },
+ { TOK_INVALID, 0, 0 }
};
int UsedGen;
/* Handle | (bitwise or) */
{
static const GenDesc hie2_ops[] = {
- { TOK_OR, GEN_NOPUSH, g_or },
- { TOK_INVALID, 0, 0 }
+ { TOK_OR, GEN_NOPUSH | GEN_COMM, g_or },
+ { TOK_INVALID, 0, 0 }
};
int UsedGen;