Implement associativity storage for operators.

This commit is contained in:
2018-02-17 16:00:39 -08:00
parent bf3c90bed2
commit b1aa2a4bf5
3 changed files with 11 additions and 6 deletions

View File

@@ -17,6 +17,10 @@ struct libab_operator_s {
* The precedence of the operator.
*/
int precedence;
/**
* The associativity of the operator.
*/
int associativity;
/**
* The functionality of the operator.
*/

View File

@@ -45,10 +45,11 @@ libab_result libab_init(libab* ab);
* @param ab the libabacus instance to reigster the operator with.
* @param op the operator string to register.
* @param precedence the precedence of the operator.
* @param associativity the associativity of the operator.
* @param func the function that describes the functionality of the operator.
* @return the result of the initialization.
*/
libab_result libab_register_operator_infix(libab* ab, const char* op, int precedence, libab_function_ptr func);
libab_result libab_register_operator_infix(libab* ab, const char* op, int precedence, int associativity, libab_function_ptr func);
/**
* Registers an operation with libabacus that appears
* before its operand.