124 lines
2.1 KiB
C
124 lines
2.1 KiB
C
#ifndef OPERATOR_H_
|
|
#define OPERATOR_H_
|
|
|
|
enum operator_precedence {
|
|
PRECEDENCE_MINIMUM = 0,
|
|
PRECEDENCE_ASSIGN,
|
|
PRECEDENCE_PIPELINE,
|
|
PRECEDENCE_LOGICAL,
|
|
PRECEDENCE_BITWISE,
|
|
PRECEDENCE_COMPARISON,
|
|
PRECEDENCE_ADDITION,
|
|
PRECEDENCE_MULTIPLICATION,
|
|
PRECEDENCE_NEGATE,
|
|
PRECEDENCE_FORMAT,
|
|
PRECEDENCE_RANGE,
|
|
PRECEDENCE_NOT,
|
|
PRECEDENCE_INCREMENT,
|
|
PRECEDENCE_ARRAY,
|
|
PRECEDENCE_JOIN,
|
|
PRECEDENCE_SPLIT,
|
|
PRECEDENCE_CAST,
|
|
PRECEDENCE_SUBSCRIPT,
|
|
PRECEDENCE_STATIC_ACCESS,
|
|
PRECEDENCE_MEMBER_ACCESS,
|
|
PRECEDENCE_PARENTHESIS,
|
|
};
|
|
|
|
enum operator_associativity {
|
|
ASSOCIATIVITY_LEFT,
|
|
ASSOCIATIVITY_RIGHT,
|
|
};
|
|
|
|
enum operator_location {
|
|
OPL_PREFIX,
|
|
OPL_INFIX,
|
|
OPL_POSTFIX,
|
|
};
|
|
|
|
enum operator_arity {
|
|
OPA_UNARY,
|
|
OPA_BINARY,
|
|
};
|
|
|
|
enum operator_id {
|
|
OP_NONE = 0,
|
|
OP_ADD,
|
|
OP_SUBTRACT,
|
|
OP_MULTIPLY,
|
|
OP_DIVIDE,
|
|
OP_MODULO,
|
|
OP_INCREMENT,
|
|
OP_DECREMENT,
|
|
OP_LEFT_SHIFT,
|
|
OP_RIGHT_SHIFT,
|
|
OP_BINARY_AND,
|
|
OP_BINARY_OR,
|
|
OP_BINARY_XOR,
|
|
OP_BINARY_NOT,
|
|
OP_LESS_THAN,
|
|
OP_GREATER_THAN,
|
|
OP_EQUAL,
|
|
OP_NOT_EQUAL,
|
|
OP_LESS_EQUAL,
|
|
OP_GREATER_EQUAL,
|
|
OP_ASSIGN,
|
|
OP_ADD_ASSIGN,
|
|
OP_SUBTRACT_ASSIGN,
|
|
OP_MULTIPLY_ASSIGN,
|
|
OP_DIVIDE_ASSIGN,
|
|
OP_MODULO_ASSIGN,
|
|
OP_LOGICAL_AND,
|
|
OP_LOGICAL_OR,
|
|
OP_LOGICAL_XOR,
|
|
OP_LOGICAL_NOT,
|
|
OP_RANGE,
|
|
OP_MATCH,
|
|
OP_NOTMATCH,
|
|
OP_REPLACE,
|
|
OP_LIKE,
|
|
OP_NOTLIKE,
|
|
OP_IN,
|
|
OP_NOTIN,
|
|
OP_FORMAT,
|
|
OP_CONTAINS,
|
|
OP_NOTCONTAINS,
|
|
OP_USPLIT,
|
|
OP_BSPLIT,
|
|
OP_UJOIN,
|
|
OP_BJOIN,
|
|
OP_IS,
|
|
OP_ISNOT,
|
|
OP_AS,
|
|
|
|
OP_SUBSCRIPT,
|
|
OP_CONDITIONAL_SUBSCRIPT,
|
|
|
|
OP_ARRAY_DELIMITER,
|
|
OP_ACCESS,
|
|
OP_STATIC_ACCESS,
|
|
OP_CONDITIONAL_ACCESS,
|
|
|
|
/* these are not real operators, and are just used internally by the
|
|
* parser. */
|
|
OP_CAST,
|
|
OP_SUBEXPR,
|
|
OP_PAREN,
|
|
OP_ARRAY_START,
|
|
OP_HASHTABLE_START,
|
|
};
|
|
|
|
struct operator_info {
|
|
enum operator_id op_id;
|
|
enum operator_precedence op_precedence;
|
|
enum operator_associativity op_associativity;
|
|
enum operator_location op_location;
|
|
enum operator_arity op_arity;
|
|
};
|
|
|
|
extern const struct operator_info *operator_get_by_id(enum operator_id id);
|
|
extern const struct operator_info *operator_get_by_token(unsigned int token);
|
|
extern const char *operator_id_to_string(enum operator_id op);
|
|
|
|
#endif
|