Add function to compile a type from its string.

This commit is contained in:
2018-04-20 14:54:23 -07:00
parent 8214aa8344
commit 7692d4541f
2 changed files with 26 additions and 4 deletions

View File

@@ -50,7 +50,7 @@ libab_result libab_init(libab* ab);
* @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, int associativity, const char* type, libab_function_ptr func);
libab_result libab_register_operator_infix(libab* ab, const char* op, int precedence, int associativity, libab_ref* type, libab_function_ptr func);
/**
* Registers an operation with libabacus that appears
* before its operand.
@@ -60,7 +60,7 @@ libab_result libab_register_operator_infix(libab* ab, const char* op, int preced
* @param func the function that describes the functionality of the operator.
* @return the result of the registration.
*/
libab_result libab_register_operator_prefix(libab* ab, const char* op, const char* type, libab_function_ptr func);
libab_result libab_register_operator_prefix(libab* ab, const char* op, libab_ref* type, libab_function_ptr func);
/**
* Registers an operation with libabacus that appears
* after its operand.
@@ -70,7 +70,7 @@ libab_result libab_register_operator_prefix(libab* ab, const char* op, const cha
* @param func the function that describes the functionality of the operator.
* @return the result of the registration.
*/
libab_result libab_register_operator_postfix(libab* ab, const char* op, const char* type, libab_function_ptr func);
libab_result libab_register_operator_postfix(libab* ab, const char* op, libab_ref* type, libab_function_ptr func);
/**
* Registers a function with libabacus.
@@ -80,7 +80,7 @@ libab_result libab_register_operator_postfix(libab* ab, const char* op, const ch
* @param func the function that describes the functionality of the function.
* @return the result of the registration.
*/
libab_result libab_register_function(libab* ab, const char* name, const char* type, libab_function_ptr func);
libab_result libab_register_function(libab* ab, const char* name, libab_ref* type, libab_function_ptr func);
/**
* Registers a base type with abacus.
* @param ab the libabacus instance used to keep state.
@@ -89,6 +89,15 @@ libab_result libab_register_function(libab* ab, const char* name, const char* ty
* @return the result of the registration.
*/
libab_result libab_register_basetype(libab* ab, const char* name, libab_basetype* basetype);
/**
* Constructs and resolves a parse type, similarly to how it's done in the
* parser.
* @param ab the libab instance to use for constructing the type.
* @param into the reference to populate with the given type.
* @param type the type to parse.
* @return the result of the operation.
*/
libab_result libab_create_type(libab* ab, libab_ref* into, const char* type);
/**
* Releases all the resources allocated by libabacus.
* @param ab the libabacus instance to release.