Fix code to stick to proper naming convention.

This commit is contained in:
2018-02-11 21:09:41 -08:00
parent 732ff47f44
commit e5351c17a2
10 changed files with 57 additions and 57 deletions

View File

@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <ctype.h>
libab_result lexer_init(lexer* lexer) {
libab_result libab_lexer_init(libab_lexer* lexer) {
size_t i;
libab_result result = LIBAB_SUCCESS;
const char* words[] = {
@@ -23,7 +23,7 @@ libab_result lexer_init(lexer* lexer) {
"for",
"return"
};
lexer_token tokens[] = {
libab_lexer_token tokens[] = {
TOKEN_CHAR,
TOKEN_ID,
TOKEN_TRUE,
@@ -39,11 +39,11 @@ libab_result lexer_init(lexer* lexer) {
TOKEN_KW_FOR,
TOKEN_KW_RETURN
};
const size_t count = sizeof(tokens)/sizeof(lexer_token);
const size_t count = sizeof(tokens)/sizeof(libab_lexer_token);
eval_config_init(&lexer->config);
for(i = 0; i < count && result == LIBAB_SUCCESS; i++) {
result = convert_lex_result(
result = libab_convert_lex_result(
eval_config_add(&lexer->config, words[i], tokens[i]));
}
@@ -58,7 +58,7 @@ struct lexer_state {
};
int _lexer_foreach_convert_match(void* data, va_list args) {
libab_result result = LIBAB_SUCCESS;
lexer_match* new_match;
libab_lexer_match* new_match;
match* match = data;
struct lexer_state* state = va_arg(args, struct lexer_state*);
char first_char = state->source[match->from];
@@ -73,7 +73,7 @@ int _lexer_foreach_convert_match(void* data, va_list args) {
new_match->to = match->to;
new_match->line_from = state->line_from;
new_match->line = state->line;
result = convert_ds_result(ll_append(state->matches, new_match));
result = libab_convert_ds_result(ll_append(state->matches, new_match));
if(result != LIBAB_SUCCESS) {
free(new_match);
}
@@ -83,7 +83,7 @@ int _lexer_foreach_convert_match(void* data, va_list args) {
return result;
}
libab_result lexer_lex(lexer* lexer, const char* string, ll* lex_into) {
libab_result libab_lexer_lex(libab_lexer* lexer, const char* string, ll* lex_into) {
libab_result result;
ll raw_matches;
struct lexer_state state;
@@ -95,7 +95,7 @@ libab_result lexer_lex(lexer* lexer, const char* string, ll* lex_into) {
state.matches = lex_into;
state.source = string;
result = convert_lex_result(
result = libab_convert_lex_result(
eval_all(string, 0, &lexer->config, &raw_matches));
if(result == LIBAB_SUCCESS) {
@@ -104,7 +104,7 @@ libab_result lexer_lex(lexer* lexer, const char* string, ll* lex_into) {
}
if(result != LIBAB_SUCCESS) {
ll_foreach(lex_into, NULL, compare_always, lexer_foreach_match_free);
ll_foreach(lex_into, NULL, compare_always, libab_lexer_foreach_match_free);
}
ll_foreach(&raw_matches, NULL, compare_always, eval_foreach_match_free);
@@ -112,10 +112,10 @@ libab_result lexer_lex(lexer* lexer, const char* string, ll* lex_into) {
return result;
}
libab_result lexer_free(lexer* lexer) {
return convert_lex_result(eval_config_free(&lexer->config));
libab_result libab_lexer_free(libab_lexer* lexer) {
return libab_convert_lex_result(eval_config_free(&lexer->config));
}
int lexer_foreach_match_free(void* data, va_list args) {
free((lexer_match*) data);
int libab_lexer_foreach_match_free(void* data, va_list args) {
free((libab_lexer_match*) data);
return 0;
}

View File

@@ -1,6 +1,6 @@
#include "libabacus_util.h"
libab_result convert_lex_result(liblex_result to_convert) {
libab_result libab_convert_lex_result(liblex_result to_convert) {
libab_result result = LIBAB_SUCCESS;
if(to_convert == LIBLEX_MALLOC) {
result = LIBAB_MALLOC;
@@ -11,7 +11,7 @@ libab_result convert_lex_result(liblex_result to_convert) {
}
return result;
}
libab_result convert_ds_result(libds_result to_convert) {
libab_result libab_convert_ds_result(libds_result to_convert) {
libab_result result = LIBAB_SUCCESS;
if(to_convert == LIBDS_MALLOC) {
result = LIBAB_MALLOC;

View File

@@ -7,7 +7,7 @@
struct parser_state {
ll_node* current_node;
lexer_match* current_match;
libab_lexer_match* current_match;
const char* string;
};
@@ -33,7 +33,7 @@ int _parser_is_char(struct parser_state* state, char to_expect) {
state->string[state->current_match->from] == to_expect);
}
int _parser_is_type(struct parser_state* state, lexer_token to_expect) {
int _parser_is_type(struct parser_state* state, libab_lexer_token to_expect) {
return (state->current_match && state->current_match->type == to_expect);
}
@@ -54,9 +54,9 @@ libab_result _parser_consume_char(struct parser_state* state, char to_consume) {
return result;
}
libab_result _parse_block(struct parser_state*, tree**, int);
libab_result _parse_block(struct parser_state*, libab_tree**, int);
libab_result _parser_extract_token(struct parser_state* state, char** into, lexer_match* match) {
libab_result _parser_extract_token(struct parser_state* state, char** into, libab_lexer_match* match) {
libab_result result = LIBAB_SUCCESS;
size_t string_size = match->to - match->from;
if((*into = malloc(string_size + 1))) {
@@ -68,12 +68,12 @@ libab_result _parser_extract_token(struct parser_state* state, char** into, lexe
return result;
}
libab_result _parse_expression(struct parser_state* state, tree** store_into) {
libab_result _parse_expression(struct parser_state* state, libab_tree** store_into) {
libab_result result = LIBAB_SUCCESS;
return result;
}
libab_result _parse_statement(struct parser_state* state, tree** store_into) {
libab_result _parse_statement(struct parser_state* state, libab_tree** store_into) {
libab_result result = LIBAB_SUCCESS;
if(_parser_is_char(state, '{')) result = _parse_block(state, store_into, 1);
@@ -93,7 +93,7 @@ libab_result _parse_statement(struct parser_state* state, tree** store_into) {
}
libab_result _parse_block(struct parser_state* state,
tree** store_into, int expect_braces) {
libab_tree** store_into, int expect_braces) {
libab_result result = LIBAB_SUCCESS;
if((*store_into = malloc(sizeof(**store_into))) == NULL) result = LIBAB_MALLOC;
@@ -109,7 +109,7 @@ libab_result _parse_block(struct parser_state* state,
return result;
}
libab_result parse_tokens(ll* tokens, const char* string, tree** store_into) {
libab_result libab_parse_tokens(ll* tokens, const char* string, libab_tree** store_into) {
libab_result result = LIBAB_SUCCESS;
struct parser_state state;
_parser_state_init(&state, tokens, string);

View File

@@ -1,11 +1,11 @@
#include "table.h"
#include <stdlib.h>
void table_init(table* table) {
void table_init(libab_table* table) {
ht_init(&table->table);
table->parent = NULL;
}
table_entry* table_search(table* table, const char* string) {
libab_table_entry* table_search(libab_table* table, const char* string) {
void* to_return = NULL;
do {
to_return = ht_get(&table->table, string);
@@ -13,6 +13,6 @@ table_entry* table_search(table* table, const char* string) {
} while(table && to_return == NULL);
return to_return;
}
void table_free(table* table) {
void table_free(libab_table* table) {
ht_free(&table->table);
}