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

@@ -149,6 +149,19 @@ libab_result libab_register_basetype(libab* ab, const char* name, libab_basetype
return result;
}
libab_result libab_create_type(libab* ab, libab_ref* into, const char* type) {
libab_result result;
ll tokens;
ll_init(&tokens);
result = libab_lexer_lex(&ab->lexer, type, &tokens);
if(result == LIBAB_SUCCESS) {
result = libab_parser_parse_type(&ab->parser, &tokens, type, into);
}
ll_foreach(&tokens, NULL, compare_always, libab_lexer_foreach_match_free);
ll_free(&tokens);
return result;
}
libab_result libab_free(libab* ab) {
libab_table_free(&ab->table);
libab_parser_free(&ab->parser);