edfb3e24a3
bshell: the front-end binary bshell.runtime: contains the parser, compiler, and classes needed to run bshell scripts bshell.core: contains the builtin commandlets and aliases
127 lines
2.9 KiB
C
127 lines
2.9 KiB
C
#ifndef BSHELL_RUNTIME_OPERATOR_H_
|
|
#define BSHELL_RUNTIME_OPERATOR_H_
|
|
|
|
enum bshell_operator_precedence {
|
|
BSHELL_PRECEDENCE_MINIMUM = 0,
|
|
BSHELL_PRECEDENCE_ASSIGN,
|
|
BSHELL_PRECEDENCE_PIPELINE,
|
|
BSHELL_PRECEDENCE_LOGICAL,
|
|
BSHELL_PRECEDENCE_BITWISE,
|
|
BSHELL_PRECEDENCE_COMPARISON,
|
|
BSHELL_PRECEDENCE_ADDITION,
|
|
BSHELL_PRECEDENCE_MULTIPLICATION,
|
|
BSHELL_PRECEDENCE_NEGATE,
|
|
BSHELL_PRECEDENCE_FORMAT,
|
|
BSHELL_PRECEDENCE_RANGE,
|
|
BSHELL_PRECEDENCE_NOT,
|
|
BSHELL_PRECEDENCE_INCREMENT,
|
|
BSHELL_PRECEDENCE_ARRAY,
|
|
BSHELL_PRECEDENCE_JOIN,
|
|
BSHELL_PRECEDENCE_SPLIT,
|
|
BSHELL_PRECEDENCE_CAST,
|
|
BSHELL_PRECEDENCE_SUBSCRIPT,
|
|
BSHELL_PRECEDENCE_STATIC_ACCESS,
|
|
BSHELL_PRECEDENCE_MEMBER_ACCESS,
|
|
BSHELL_PRECEDENCE_PARENTHESIS,
|
|
};
|
|
|
|
enum bshell_operator_associativity {
|
|
BSHELL_ASSOCIATIVITY_LEFT,
|
|
BSHELL_ASSOCIATIVITY_RIGHT,
|
|
};
|
|
|
|
enum bshell_operator_location {
|
|
BSHELL_OPL_PREFIX,
|
|
BSHELL_OPL_INFIX,
|
|
BSHELL_OPL_POSTFIX,
|
|
};
|
|
|
|
enum bshell_operator_arity {
|
|
BSHELL_OPA_UNARY,
|
|
BSHELL_OPA_BINARY,
|
|
};
|
|
|
|
enum bshell_operator_id {
|
|
BS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_OP_ISNOT,
|
|
BSHELL_OP_AS,
|
|
|
|
BSHELL_OP_SUBSCRIPT,
|
|
BSHELL_OP_CONDITIONAL_SUBSCRIPT,
|
|
|
|
BSHELL_OP_ARRAY_DELIMITER,
|
|
BSHELL_OP_ACCESS,
|
|
BSHELL_OP_STATIC_ACCESS,
|
|
BSHELL_OP_CONDITIONAL_ACCESS,
|
|
|
|
/* these are not real operators, and are just used internally by the
|
|
* parser. */
|
|
BSHELL_OP_CAST,
|
|
BSHELL_OP_SUBEXPR,
|
|
BSHELL_OP_PAREN,
|
|
BSHELL_OP_SCRIPTBLOCK,
|
|
BSHELL_OP_ARRAY_START,
|
|
BSHELL_OP_HASHTABLE_START,
|
|
};
|
|
|
|
struct bshell_operator_info {
|
|
enum bshell_operator_id op_id;
|
|
enum bshell_operator_precedence op_precedence;
|
|
enum bshell_operator_associativity op_associativity;
|
|
enum bshell_operator_location op_location;
|
|
enum bshell_operator_arity op_arity;
|
|
};
|
|
|
|
extern const struct bshell_operator_info *bshell_operator_get_by_id(
|
|
enum bshell_operator_id id);
|
|
extern const struct bshell_operator_info *bshell_operator_get_by_token(
|
|
unsigned int token);
|
|
extern const char *bshell_operator_id_to_string(enum bshell_operator_id op);
|
|
|
|
#endif
|