Make a single "operator" token, and specialize after parse.

This commit is contained in:
2018-03-17 20:56:25 -07:00
parent 156c02908d
commit 9500a6f9b0
5 changed files with 42 additions and 36 deletions

View File

@@ -9,6 +9,16 @@
*/
typedef void(*libab_function_ptr)();
/**
* The variant of the operator that
* has been registered with libabacus.
*/
enum libab_operator_variant_e {
OPERATOR_PREFIX,
OPERATOR_INFIX,
OPERATOR_POSTFIX
};
/**
* The common information
* that both operators and functions shared.
@@ -34,7 +44,7 @@ struct libab_operator_s {
* Corresponds to token types associated with
* each operator.
*/
int type;
enum libab_operator_variant_e type;
/**
* The precedence of the operator.
*/
@@ -61,6 +71,7 @@ struct libab_function_s {
struct libab_behavior_s behavior;
};
typedef enum libab_operator_variant_e libab_operator_variant;
typedef struct libab_behavior_s libab_behavior;
typedef struct libab_operator_s libab_operator;
typedef struct libab_function_s libab_function;

View File

@@ -55,6 +55,7 @@ enum libab_lexer_token_e {
TOKEN_CHAR = 0,
TOKEN_ID,
TOKEN_NUM,
TOKEN_OP,
TOKEN_OP_INFIX,
TOKEN_OP_PREFIX,
TOKEN_OP_POSTFIX,