Program Listing for File operators.h¶
↰ Return to documentation for file (src/lovejoy/operators.h
)
#include "common.h"
enum Associativity {
ASSOC_NEITHER = 0,
ASSOC_LEFT,
ASSOC_RIGHT,
};
unqualify(enum, Associativity);
enum Fixity {
PREFIX = 1 << 0,
INFIX = 1 << 1,
POSTFIX = 1 << 2
};
unqualify(enum, Fixity);
struct Operator {
u16 precedence;
Associativity associativity;
Fixity fixity;
string name;
};
unqualify(struct, Operator);
newarray(OperatorTable, Operator);
OperatorTable DefaultOperators();
u0 new_operator(OperatorTable *, string, u16, Associativity, Fixity);
Operator *get_operator(OperatorTable, string, Fixity);
inline
bool is_prefix(Operator* op)
{ return (op->fixity & PREFIX) != 0; }
inline
bool is_infix(Operator* op)
{ return (op->fixity & INFIX) != 0; }
inline
bool is_postfix(Operator* op)
{ return (op->fixity & POSTFIX) != 0; }