Added config syntax error warnings
parent
a56b7575b7
commit
cc80e081ff
|
@ -344,6 +344,7 @@ struct Config_Line{
|
||||||
int32_t val_array_start;
|
int32_t val_array_start;
|
||||||
int32_t val_array_end;
|
int32_t val_array_end;
|
||||||
int32_t val_array_count;
|
int32_t val_array_count;
|
||||||
|
String error_str;
|
||||||
bool32 read_success;
|
bool32 read_success;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -387,20 +388,21 @@ read_config_token(Cpp_Token_Array array, int32_t *i_ptr){
|
||||||
}
|
}
|
||||||
|
|
||||||
static Config_Line
|
static Config_Line
|
||||||
read_config_line(Cpp_Token_Array array, int32_t *i_ptr){
|
read_config_line(Cpp_Token_Array array, int32_t *i_ptr, char *text){
|
||||||
Config_Line config_line = {0};
|
Config_Line config_line = {0};
|
||||||
|
|
||||||
int32_t i = *i_ptr;
|
int32_t i = *i_ptr;
|
||||||
|
|
||||||
config_line.id_token = read_config_token(array, &i);
|
config_line.id_token = read_config_token(array, &i);
|
||||||
|
int32_t text_index_start = config_line.id_token.start;
|
||||||
if (config_line.id_token.type == CPP_TOKEN_IDENTIFIER){
|
if (config_line.id_token.type == CPP_TOKEN_IDENTIFIER){
|
||||||
++i;
|
++i;
|
||||||
if (i < array.count){
|
if (i < array.count){
|
||||||
Cpp_Token token = read_config_token(array, &i);
|
Cpp_Token token = read_config_token(array, &i);
|
||||||
|
|
||||||
bool32 subscript_success = true;
|
bool32 lvalue_success = true;
|
||||||
if (token.type == CPP_TOKEN_BRACKET_OPEN){
|
if (token.type == CPP_TOKEN_BRACKET_OPEN){
|
||||||
subscript_success = false;
|
lvalue_success = false;
|
||||||
++i;
|
++i;
|
||||||
if (i < array.count){
|
if (i < array.count){
|
||||||
config_line.subscript_token = read_config_token(array, &i);
|
config_line.subscript_token = read_config_token(array, &i);
|
||||||
|
@ -412,7 +414,7 @@ read_config_line(Cpp_Token_Array array, int32_t *i_ptr){
|
||||||
++i;
|
++i;
|
||||||
if (i < array.count){
|
if (i < array.count){
|
||||||
token = read_config_token(array, &i);
|
token = read_config_token(array, &i);
|
||||||
subscript_success = true;
|
lvalue_success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -420,16 +422,16 @@ read_config_line(Cpp_Token_Array array, int32_t *i_ptr){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subscript_success){
|
if (lvalue_success){
|
||||||
if (token.type == CPP_TOKEN_EQ){
|
if (token.type == CPP_TOKEN_EQ){
|
||||||
config_line.eq_token = read_config_token(array, &i);
|
config_line.eq_token = read_config_token(array, &i);
|
||||||
++i;
|
++i;
|
||||||
if (i < array.count){
|
if (i < array.count){
|
||||||
Cpp_Token val_token = read_config_token(array, &i);
|
Cpp_Token val_token = read_config_token(array, &i);
|
||||||
|
|
||||||
bool32 array_success = true;
|
bool32 rvalue_success = true;
|
||||||
if (val_token.type == CPP_TOKEN_BRACE_OPEN){
|
if (val_token.type == CPP_TOKEN_BRACE_OPEN){
|
||||||
array_success = false;
|
rvalue_success = false;
|
||||||
++i;
|
++i;
|
||||||
if (i < array.count){
|
if (i < array.count){
|
||||||
config_line.val_array_start = i;
|
config_line.val_array_start = i;
|
||||||
|
@ -442,7 +444,7 @@ read_config_line(Cpp_Token_Array array, int32_t *i_ptr){
|
||||||
}
|
}
|
||||||
if (array_token.type == CPP_TOKEN_BRACE_CLOSE){
|
if (array_token.type == CPP_TOKEN_BRACE_CLOSE){
|
||||||
config_line.val_array_end = i;
|
config_line.val_array_end = i;
|
||||||
array_success = true;
|
rvalue_success = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -465,13 +467,13 @@ read_config_line(Cpp_Token_Array array, int32_t *i_ptr){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_success){
|
if (rvalue_success){
|
||||||
config_line.val_token = val_token;
|
config_line.val_token = val_token;
|
||||||
++i;
|
++i;
|
||||||
if (i < array.count){
|
if (i < array.count){
|
||||||
Cpp_Token semicolon_token = read_config_token(array, &i);
|
Cpp_Token semicolon_token = read_config_token(array, &i);
|
||||||
if (semicolon_token.type == CPP_TOKEN_SEMICOLON){
|
if (semicolon_token.type == CPP_TOKEN_SEMICOLON){
|
||||||
config_line.read_success = 1;
|
config_line.read_success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,6 +484,22 @@ read_config_line(Cpp_Token_Array array, int32_t *i_ptr){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config_line.read_success){
|
if (!config_line.read_success){
|
||||||
|
Cpp_Token token = {0};
|
||||||
|
if (i < array.count){
|
||||||
|
token = array.tokens[i];
|
||||||
|
}
|
||||||
|
int32_t text_index_current = token.start + token.size;
|
||||||
|
if (text_index_current <= text_index_start){
|
||||||
|
if (array.count > 0){
|
||||||
|
token = array.tokens[array.count - 1];
|
||||||
|
text_index_current = token.start + token.size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text_index_current > text_index_start){
|
||||||
|
config_line.error_str = make_string(text + text_index_start, text_index_current - text_index_start);
|
||||||
|
}
|
||||||
|
|
||||||
for (; i < array.count; ++i){
|
for (; i < array.count; ++i){
|
||||||
Cpp_Token token = read_config_token(array, &i);
|
Cpp_Token token = read_config_token(array, &i);
|
||||||
if (token.type == CPP_TOKEN_SEMICOLON){
|
if (token.type == CPP_TOKEN_SEMICOLON){
|
||||||
|
@ -864,7 +882,7 @@ process_config_file(Application_Links *app){
|
||||||
lexer_keywords_default_init(part, &kw_table, &pp_table);
|
lexer_keywords_default_init(part, &kw_table, &pp_table);
|
||||||
|
|
||||||
Cpp_Lex_Data S = cpp_lex_data_init(false, kw_table, pp_table);
|
Cpp_Lex_Data S = cpp_lex_data_init(false, kw_table, pp_table);
|
||||||
Cpp_Lex_Result result = cpp_lex_step(&S, mem, size+1, HAS_NULL_TERM, &array, NO_OUT_LIMIT);
|
Cpp_Lex_Result result = cpp_lex_step(&S, mem, size + 1, HAS_NULL_TERM, &array, NO_OUT_LIMIT);
|
||||||
|
|
||||||
if (result == LexResult_Finished){
|
if (result == LexResult_Finished){
|
||||||
int32_t new_wrap_width = default_wrap_width;
|
int32_t new_wrap_width = default_wrap_width;
|
||||||
|
@ -872,7 +890,7 @@ process_config_file(Application_Links *app){
|
||||||
bool32 lalt_lctrl_is_altgr = false;
|
bool32 lalt_lctrl_is_altgr = false;
|
||||||
|
|
||||||
for (int32_t i = 0; i < array.count; ++i){
|
for (int32_t i = 0; i < array.count; ++i){
|
||||||
Config_Line config_line = read_config_line(array, &i);
|
Config_Line config_line = read_config_line(array, &i, mem);
|
||||||
|
|
||||||
if (config_line.read_success){
|
if (config_line.read_success){
|
||||||
Config_Item item = get_config_item(config_line, mem, array);
|
Config_Item item = get_config_item(config_line, mem, array);
|
||||||
|
@ -908,6 +926,14 @@ process_config_file(Application_Links *app){
|
||||||
|
|
||||||
config_bool_var(item, "lalt_lctrl_is_altgr", 0, &lalt_lctrl_is_altgr);
|
config_bool_var(item, "lalt_lctrl_is_altgr", 0, &lalt_lctrl_is_altgr);
|
||||||
}
|
}
|
||||||
|
else if (config_line.error_str.str != 0){
|
||||||
|
char space[2048];
|
||||||
|
String str = make_fixed_width_string(space);
|
||||||
|
copy(&str, "WARNING: bad syntax in 4coder.config at ");
|
||||||
|
append(&str, config_line.error_str);
|
||||||
|
append(&str, "\n");
|
||||||
|
print_message(app, str.str, str.size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
adjust_all_buffer_wrap_widths(app, new_wrap_width, new_min_base_width);
|
adjust_all_buffer_wrap_widths(app, new_wrap_width, new_min_base_width);
|
||||||
|
@ -947,7 +973,7 @@ load_color_theme_file(Application_Links *app, char *file_name){
|
||||||
file = fopen(str.str, "rb");
|
file = fopen(str.str, "rb");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file){
|
if (file != 0){
|
||||||
Temp_Memory temp = begin_temp_memory(part);
|
Temp_Memory temp = begin_temp_memory(part);
|
||||||
|
|
||||||
char *mem = 0;
|
char *mem = 0;
|
||||||
|
@ -967,7 +993,7 @@ load_color_theme_file(Application_Links *app, char *file_name){
|
||||||
lexer_keywords_default_init(part, &kw_table, &pp_table);
|
lexer_keywords_default_init(part, &kw_table, &pp_table);
|
||||||
|
|
||||||
Cpp_Lex_Data S = cpp_lex_data_init(false, kw_table, pp_table);
|
Cpp_Lex_Data S = cpp_lex_data_init(false, kw_table, pp_table);
|
||||||
Cpp_Lex_Result result = cpp_lex_step(&S, mem, size+1, HAS_NULL_TERM, &array, NO_OUT_LIMIT);
|
Cpp_Lex_Result result = cpp_lex_step(&S, mem, size + 1, HAS_NULL_TERM, &array, NO_OUT_LIMIT);
|
||||||
|
|
||||||
if (result == LexResult_Finished){
|
if (result == LexResult_Finished){
|
||||||
success = true;
|
success = true;
|
||||||
|
@ -978,7 +1004,7 @@ load_color_theme_file(Application_Links *app, char *file_name){
|
||||||
init_theme_zero(&theme);
|
init_theme_zero(&theme);
|
||||||
|
|
||||||
for (int32_t i = 0; i < array.count; ++i){
|
for (int32_t i = 0; i < array.count; ++i){
|
||||||
Config_Line config_line = read_config_line(array, &i);
|
Config_Line config_line = read_config_line(array, &i, mem);
|
||||||
if (config_line.read_success){
|
if (config_line.read_success){
|
||||||
Config_Item item = get_config_item(config_line, mem, array);
|
Config_Item item = get_config_item(config_line, mem, array);
|
||||||
config_string_var(item, "name", 0, &name_str);
|
config_string_var(item, "name", 0, &name_str);
|
||||||
|
@ -1005,6 +1031,14 @@ load_color_theme_file(Application_Links *app, char *file_name){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (config_line.error_str.str != 0){
|
||||||
|
char space[2048];
|
||||||
|
String str = make_fixed_width_string(space);
|
||||||
|
copy(&str, "WARNING: bad syntax in 4coder.config at ");
|
||||||
|
append(&str, config_line.error_str);
|
||||||
|
append(&str, "\n");
|
||||||
|
print_message(app, str.str, str.size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name_str.size == 0){
|
if (name_str.size == 0){
|
||||||
|
|
|
@ -206,7 +206,7 @@ load_project_from_config_data(Application_Links *app, Partition *part, char *con
|
||||||
lexer_keywords_default_init(part, &kw_table, &pp_table);
|
lexer_keywords_default_init(part, &kw_table, &pp_table);
|
||||||
|
|
||||||
Cpp_Lex_Data S = cpp_lex_data_init(false, kw_table, pp_table);
|
Cpp_Lex_Data S = cpp_lex_data_init(false, kw_table, pp_table);
|
||||||
Cpp_Lex_Result result = cpp_lex_step(&S, mem, size+1, HAS_NULL_TERM, &array, NO_OUT_LIMIT);
|
Cpp_Lex_Result result = cpp_lex_step(&S, mem, size + 1, HAS_NULL_TERM, &array, NO_OUT_LIMIT);
|
||||||
|
|
||||||
if (result == LexResult_Finished){
|
if (result == LexResult_Finished){
|
||||||
// Clear out current project
|
// Clear out current project
|
||||||
|
@ -227,7 +227,7 @@ load_project_from_config_data(Application_Links *app, Partition *part, char *con
|
||||||
|
|
||||||
// Read the settings from project.4coder
|
// Read the settings from project.4coder
|
||||||
for (int32_t i = 0; i < array.count; ++i){
|
for (int32_t i = 0; i < array.count; ++i){
|
||||||
Config_Line config_line = read_config_line(array, &i);
|
Config_Line config_line = read_config_line(array, &i, mem);
|
||||||
if (config_line.read_success){
|
if (config_line.read_success){
|
||||||
Config_Item item = get_config_item(config_line, mem, array);
|
Config_Item item = get_config_item(config_line, mem, array);
|
||||||
|
|
||||||
|
@ -365,6 +365,14 @@ load_project_from_config_data(Application_Links *app, Partition *part, char *con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (config_line.error_str.str != 0){
|
||||||
|
char space[2048];
|
||||||
|
String str = make_fixed_width_string(space);
|
||||||
|
copy(&str, "WARNING: bad syntax in 4coder.config at ");
|
||||||
|
append(&str, config_line.error_str);
|
||||||
|
append(&str, "\n");
|
||||||
|
print_message(app, str.str, str.size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_project.close_all_files_when_project_opens){
|
if (current_project.close_all_files_when_project_opens){
|
||||||
|
|
Loading…
Reference in New Issue