From bc5b1e232b4be6dd6af3b0edcfefb612f44b0a28 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Mon, 23 Sep 2024 16:31:05 +0800 Subject: [PATCH] fix: parse error for 'int main(int argc, char* argv[])', delete some unused code --- core/scf_function.c | 1 - core/scf_lex_word.h | 76 ++--------------- core/scf_node.c | 24 ++++-- core/scf_node.h | 4 +- examples/main_argv.c | 2 +- parse/scf_dfa_function.c | 137 ++++++++++++++++++----------- parse/scf_dfa_init_data.c | 1 - parse/scf_dfa_parse.c | 13 +-- parse/scf_dfa_util.h | 175 -------------------------------------- parse/scf_dfa_var.c | 1 - 10 files changed, 121 insertions(+), 313 deletions(-) diff --git a/core/scf_function.c b/core/scf_function.c index 0725b09..ff2884a 100644 --- a/core/scf_function.c +++ b/core/scf_function.c @@ -294,4 +294,3 @@ error: scf_string_free(s); return -1; } - diff --git a/core/scf_lex_word.h b/core/scf_lex_word.h index 7543477..24a92ed 100644 --- a/core/scf_lex_word.h +++ b/core/scf_lex_word.h @@ -55,8 +55,14 @@ enum scf_lex_words SCF_LEX_WORD_LA, // << left angle brackets SCF_LEX_WORD_RA, // >> right angle brackets + SCF_LEX_WORD_KEY_SIZEOF, // sizeof + SCF_LEX_WORD_KEY_CREATE, // create class object + SCF_LEX_WORD_KEY_CONTAINER, // container_of + SCF_LEX_WORD_KEY_VA_ARG, // va_arg + SCF_LEX_WORD_ARROW, // -> arrow SCF_LEX_WORD_DOT, // . dot + SCF_LEX_WORD_RANGE, // .. range SCF_LEX_WORD_VAR_ARGS, // ... variable args @@ -74,62 +80,33 @@ enum scf_lex_words // key words SCF_LEX_WORD_KEY_IF, // if SCF_LEX_WORD_KEY_ELSE, // else - SCF_LEX_WORD_KEY_THEN, // then - SCF_LEX_WORD_KEY_ELSIF, // else if - SCF_LEX_WORD_KEY_END_IF, // end if SCF_LEX_WORD_KEY_FOR, // for - SCF_LEX_WORD_KEY_TO, // to - SCF_LEX_WORD_KEY_BY, // by SCF_LEX_WORD_KEY_DO, // do - SCF_LEX_WORD_KEY_END_FOR, // end for - SCF_LEX_WORD_KEY_WHILE, // while - SCF_LEX_WORD_KEY_END_WHILE, // end while - - SCF_LEX_WORD_KEY_REPEAT, // repeat - SCF_LEX_WORD_KEY_UNTIL, // until - SCF_LEX_WORD_KEY_END_REPEAT,// SCF_LEX_WORD_KEY_BREAK, // break SCF_LEX_WORD_KEY_CONTINUE, // continue - SCF_LEX_WORD_KEY_EXIT, // exit SCF_LEX_WORD_KEY_SWITCH, // switch SCF_LEX_WORD_KEY_CASE, // case SCF_LEX_WORD_KEY_DEFAULT, // default - SCF_LEX_WORD_KEY_END_CASE, // end case SCF_LEX_WORD_KEY_RETURN, // return SCF_LEX_WORD_KEY_GOTO, // goto - SCF_LEX_WORD_KEY_SIZEOF, // sizeof - - SCF_LEX_WORD_KEY_CREATE, // create class object - - SCF_LEX_WORD_KEY_CONTAINER, // container_of - SCF_LEX_WORD_KEY_OF, // of - SCF_LEX_WORD_KEY_AT, // at - SCF_LEX_WORD_KEY_EN, // enable - SCF_LEX_WORD_KEY_ENO, // enable output SCF_LEX_WORD_KEY_OPERATOR, // operator - SCF_LEX_WORD_KEY_UNDERLINE, // _ underline SCF_LEX_WORD_KEY_INCLUDE, // include + SCF_LEX_WORD_KEY_DEFINE, // define // data types SCF_LEX_WORD_KEY_CHAR, // char SCF_LEX_WORD_KEY_BIT, // bit - SCF_LEX_WORD_KEY_TIME, // time - SCF_LEX_WORD_KEY_TIME_OF_DATE, // time of date - SCF_LEX_WORD_KEY_DATE, // date - SCF_LEX_WORD_KEY_DATE_AND_TIME, // date and time - SCF_LEX_WORD_KEY_STRING, // string - SCF_LEX_WORD_KEY_INT, // int SCF_LEX_WORD_KEY_FLOAT, // float SCF_LEX_WORD_KEY_DOUBLE, // double @@ -150,7 +127,6 @@ enum scf_lex_words SCF_LEX_WORD_KEY_VOID, // void SCF_LEX_WORD_KEY_VA_START, // va_start - SCF_LEX_WORD_KEY_VA_ARG, // va_arg SCF_LEX_WORD_KEY_VA_END, // va_end // class @@ -168,38 +144,8 @@ enum scf_lex_words SCF_LEX_WORD_KEY_ENUM, // enum SCF_LEX_WORD_KEY_UNION, // union SCF_LEX_WORD_KEY_STRUCT, // struct - SCF_LEX_WORD_KEY_END_STRUCT,// end struct - SCF_LEX_WORD_KEY_ARRAY, // array - - SCF_LEX_WORD_KEY_TASK, // task - - SCF_LEX_WORD_KEY_TON, // ton - SCF_LEX_WORD_KEY_F_TRIG, // f trig - - SCF_LEX_WORD_KEY_CONFIG, // config - SCF_LEX_WORD_KEY_END_CONFIG, // end config - - SCF_LEX_WORD_KEY_RESOURCE, // config - SCF_LEX_WORD_KEY_END_RESOURCE, // end config - - SCF_LEX_WORD_KEY_PROGRAM, // program - SCF_LEX_WORD_KEY_END_PROGRAM, - - SCF_LEX_WORD_KEY_FUNCTION, // function - SCF_LEX_WORD_KEY_END_FUNCTION, - - SCF_LEX_WORD_KEY_FUNCTION_BLOCK, // function block - SCF_LEX_WORD_KEY_END_FUNCTION_BLOCK, - SCF_LEX_WORD_KEY_VAR, // var - SCF_LEX_WORD_KEY_VAR_INPUT, // var input - SCF_LEX_WORD_KEY_VAR_OUTPUT, // var output - SCF_LEX_WORD_KEY_VAR_IN_OUT, // var in out - SCF_LEX_WORD_KEY_VAR_GLOBAL, // var global - SCF_LEX_WORD_KEY_VAR_EXTERNAL, // var external - SCF_LEX_WORD_KEY_VAR_TEMP, // var temp - SCF_LEX_WORD_KEY_VAR_CONSTANT, // var const - SCF_LEX_WORD_KEY_END_VAR, + SCF_LEX_WORD_KEY_VAR, // var // const literal value SCF_LEX_WORD_CONST_CHAR, @@ -253,11 +199,7 @@ static inline int scf_lex_is_identity(scf_lex_word_t* w) static inline int scf_lex_is_operator(scf_lex_word_t* w) { - return (w->type >= SCF_LEX_WORD_PLUS && w->type <= SCF_LEX_WORD_DOT) - || SCF_LEX_WORD_KEY_SIZEOF == w->type - || SCF_LEX_WORD_KEY_VA_ARG == w->type - || SCF_LEX_WORD_KEY_CREATE == w->type - || SCF_LEX_WORD_KEY_CONTAINER == w->type; + return w->type >= SCF_LEX_WORD_PLUS && w->type <= SCF_LEX_WORD_DOT; } static inline int scf_lex_is_const(scf_lex_word_t* w) diff --git a/core/scf_node.c b/core/scf_node.c index eafdcba..dd111da 100644 --- a/core/scf_node.c +++ b/core/scf_node.c @@ -130,10 +130,8 @@ scf_node_t* scf_node_alloc_label(scf_label_t* l) int scf_node_add_child(scf_node_t* parent, scf_node_t* child) { - if (!parent) { - scf_loge("invalid, parent is NULL\n"); - return -1; - } + if (!parent) + return -EINVAL; void* p = realloc(parent->nodes, sizeof(scf_node_t*) * (parent->nb_nodes + 1)); if (!p) { @@ -150,6 +148,23 @@ int scf_node_add_child(scf_node_t* parent, scf_node_t* child) return 0; } +void scf_node_del_child(scf_node_t* parent, scf_node_t* child) +{ + if (!parent) + return; + + int i; + for (i = 0; i < parent->nb_nodes; i++) { + if (child == parent->nodes[i]) + break; + } + + for (++i; i < parent->nb_nodes; i++) + parent->nodes[i - 1] = parent->nodes[i]; + + parent->nodes[--parent->nb_nodes] = NULL; +} + void scf_node_free_data(scf_node_t* node) { if (!node) @@ -354,4 +369,3 @@ failed: checked = NULL; return ret; } - diff --git a/core/scf_node.h b/core/scf_node.h index e39fe4d..1ad8432 100644 --- a/core/scf_node.h +++ b/core/scf_node.h @@ -64,7 +64,8 @@ scf_node_t* scf_node_alloc_label(scf_label_t* l); scf_node_t* scf_node_clone(scf_node_t* node); -int scf_node_add_child(scf_node_t* parent, scf_node_t* child); +int scf_node_add_child(scf_node_t* parent, scf_node_t* child); +void scf_node_del_child(scf_node_t* parent, scf_node_t* child); void scf_node_free(scf_node_t* node); void scf_node_free_data(scf_node_t* node); @@ -82,4 +83,3 @@ scf_label_t* scf_label_alloc(scf_lex_word_t* w); void scf_label_free(scf_label_t* l); #endif - diff --git a/examples/main_argv.c b/examples/main_argv.c index fe50ca8..888e092 100644 --- a/examples/main_argv.c +++ b/examples/main_argv.c @@ -1,7 +1,7 @@ int printf(const char* fmt, ...); -int main(int argc, char** argv, char** envp) +int main(int argc, char* argv[], char** envp) { int i; for (i = 0; i < argc; i++) diff --git a/parse/scf_dfa_function.c b/parse/scf_dfa_function.c index 916edba..30ffda1 100644 --- a/parse/scf_dfa_function.c +++ b/parse/scf_dfa_function.c @@ -18,16 +18,20 @@ int _function_add_function(scf_dfa_t* dfa, dfa_parse_data_t* d) } scf_parse_t* parse = dfa->priv; + scf_ast_t* ast = parse->ast; dfa_identity_t* id = scf_stack_pop(d->current_identities); + dfa_fun_data_t* fd = d->module_datas[dfa_module_function.index]; + scf_function_t* f; scf_variable_t* v; + scf_block_t* b; if (!id || !id->identity) { scf_loge("function identity not found\n"); return SCF_DFA_ERROR; } - scf_block_t* b = parse->ast->current_block; + b = ast->current_block; while (b) { if (b->node.type >= SCF_STRUCT) break; @@ -103,6 +107,13 @@ int _function_add_function(scf_dfa_t* dfa, dfa_parse_data_t* d) SCF_XCHG(f->rets->data[i], f->rets->data[j]); } + scf_scope_push_function(ast->current_block->scope, f); + + scf_node_add_child((scf_node_t*)ast->current_block, (scf_node_t*)f); + + fd ->parent_block = ast->current_block; + ast->current_block = (scf_block_t*)f; + d->current_function = f; return SCF_DFA_NEXT_WORD; @@ -144,12 +155,35 @@ int _function_add_arg(scf_dfa_t* dfa, dfa_parse_data_t* d) return SCF_DFA_ERROR; } - arg = SCF_VAR_ALLOC_BY_TYPE(w, t->type, t->const_flag, t->nb_pointers, t->func_ptr); - if (!arg) - return SCF_DFA_ERROR; + if (!d->current_var) { + arg = SCF_VAR_ALLOC_BY_TYPE(w, t->type, t->const_flag, t->nb_pointers, t->func_ptr); + if (!arg) + return SCF_DFA_ERROR; + + scf_scope_push_var(d->current_function->scope, arg); + } else { + arg = d->current_var; + + if (arg->nb_dimentions > 0) { + arg->nb_pointers += arg->nb_dimentions; + arg->nb_dimentions = 0; + } + + if (arg->dimentions) { + free(arg->dimentions); + arg->dimentions = NULL; + } + + arg->const_literal_flag = 0; + + d->current_var = NULL; + } + + scf_logi("d->argc: %d, arg->nb_pointers: %d, arg->nb_dimentions: %d\n", + d->argc, arg->nb_pointers, arg->nb_dimentions); scf_vector_add(d->current_function->argv, arg); - scf_scope_push_var(d->current_function->scope, arg); + arg->refs++; arg->arg_flag = 1; arg->local_flag = 1; @@ -195,10 +229,12 @@ static int _function_action_lp(scf_dfa_t* dfa, scf_vector_t* words, void* data) assert(!d->current_node); + d->current_var = NULL; + if (_function_add_function(dfa, d) < 0) return SCF_DFA_ERROR; - SCF_DFA_PUSH_HOOK(scf_dfa_find_node(dfa, "function_rp"), SCF_DFA_HOOK_PRE); + SCF_DFA_PUSH_HOOK(scf_dfa_find_node(dfa, "function_rp"), SCF_DFA_HOOK_PRE); SCF_DFA_PUSH_HOOK(scf_dfa_find_node(dfa, "function_comma"), SCF_DFA_HOOK_PRE); d->argc = 0; @@ -212,6 +248,8 @@ static int _function_action_rp(scf_dfa_t* dfa, scf_vector_t* words, void* data) scf_parse_t* parse = dfa->priv; dfa_parse_data_t* d = data; dfa_fun_data_t* fd = d->module_datas[dfa_module_function.index]; + scf_function_t* f = d->current_function; + scf_function_t* fprev = NULL; d->nb_rps++; @@ -225,11 +263,12 @@ static int _function_action_rp(scf_dfa_t* dfa, scf_vector_t* words, void* data) return SCF_DFA_ERROR; } - scf_function_t* f = NULL; + scf_list_del(&f->list); + scf_node_del_child((scf_node_t*)fd->parent_block, (scf_node_t*)f); - if (parse->ast->current_block->node.type >= SCF_STRUCT) { + if (fd->parent_block->node.type >= SCF_STRUCT) { - scf_type_t* t = (scf_type_t*)parse->ast->current_block; + scf_type_t* t = (scf_type_t*)fd->parent_block; if (!t->node.class_flag) { scf_loge("only class has member function\n"); @@ -238,66 +277,65 @@ static int _function_action_rp(scf_dfa_t* dfa, scf_vector_t* words, void* data) assert(t->scope); - if (!strcmp(d->current_function->node.w->text->data, "__init")) { - - f = scf_scope_find_same_function(t->scope, d->current_function); + if (!strcmp(f->node.w->text->data, "__init")) { - } else if (!strcmp(d->current_function->node.w->text->data, "__release")) { + fprev = scf_scope_find_same_function(t->scope, f); - f = scf_scope_find_function(t->scope, d->current_function->node.w->text->data); + } else if (!strcmp(f->node.w->text->data, "__release")) { - if (f && !scf_function_same(f, d->current_function)) { + fprev = scf_scope_find_function(t->scope, f->node.w->text->data); + if (fprev && !scf_function_same(fprev, f)) { scf_loge("function '%s' can't be overloaded, repeated declare first in line: %d, second in line: %d\n", - f->node.w->text->data, f->node.w->line, d->current_function->node.w->line); + f->node.w->text->data, fprev->node.w->line, f->node.w->line); return SCF_DFA_ERROR; } } else { - scf_loge("class member function must be '__init()' or '__release()'\n"); + scf_loge("class member function must be '__init()' or '__release()', file: %s, line: %d\n", f->node.w->file->data, f->node.w->line); return SCF_DFA_ERROR; } } else { - scf_block_t* b = parse->ast->current_block; + scf_block_t* b = fd->parent_block; - while (b) { - if (!b->node.root_flag && !b->node.file_flag) { - scf_loge("function should be defined in file or global, or class\n"); - return SCF_DFA_ERROR; - } + if (!b->node.root_flag && !b->node.file_flag) { + scf_loge("function should be defined in file, global, or class\n"); + return SCF_DFA_ERROR; + } - assert(b->scope); + assert(b->scope); - f = scf_scope_find_function(b->scope, d->current_function->node.w->text->data); - if (f) { - if (scf_function_same(f, d->current_function)) - break; + if (f->static_flag) + fprev = scf_scope_find_function(b->scope, f->node.w->text->data); + else { + int ret = scf_ast_find_global_function(&fprev, parse->ast, f->node.w->text->data); + if (ret < 0) + return ret; + } - scf_loge("repeated declare function '%s', first in line: %d, second in line: %d, function overloading only can do in class\n", - f->node.w->text->data, f->node.w->line, d->current_function->node.w->line); - return SCF_DFA_ERROR; - } + if (fprev && !scf_function_same(fprev, f)) { - b = (scf_block_t*)b->node.parent; + scf_loge("repeated declare function '%s', first in line: %d, second in line: %d, function overloading only can do in class\n", + f->node.w->text->data, fprev->node.w->line, f->node.w->line); + return SCF_DFA_ERROR; } } - if (f) { - if (!f->node.define_flag) { + if (fprev) { + if (!fprev->node.define_flag) { int i; + scf_variable_t* v0; + scf_variable_t* v1; - for (i = 0; i < f->argv->size; i++) { - scf_variable_t* v0 = f->argv->data[i]; - scf_variable_t* v1 = d->current_function->argv->data[i]; + for (i = 0; i < fprev->argv->size; i++) { + v0 = fprev->argv->data[i]; + v1 = f ->argv->data[i]; - if (v1->w) { - if (v0->w) - scf_lex_word_free(v0->w); - v0->w = scf_lex_word_clone(v1->w); - } + if (v1->w) + SCF_XCHG(v0->w, v1->w); } - scf_function_free(d->current_function); - d->current_function = f; + scf_function_free(f); + d->current_function = fprev; } else { scf_lex_word_t* w = dfa->ops->pop_word(dfa); @@ -305,7 +343,7 @@ static int _function_action_rp(scf_dfa_t* dfa, scf_vector_t* words, void* data) if (SCF_LEX_WORD_SEMICOLON != w->type) { scf_loge("repeated define function '%s', first in line: %d, second in line: %d\n", - f->node.w->text->data, f->node.w->line, d->current_function->node.w->line); + f->node.w->text->data, fprev->node.w->line, f->node.w->line); dfa->ops->push_word(dfa, w); return SCF_DFA_ERROR; @@ -314,13 +352,13 @@ static int _function_action_rp(scf_dfa_t* dfa, scf_vector_t* words, void* data) dfa->ops->push_word(dfa, w); } } else { - scf_scope_push_function(parse->ast->current_block->scope, d->current_function); - scf_node_add_child((scf_node_t*)parse->ast->current_block, (scf_node_t*)d->current_function); + scf_scope_push_function(fd->parent_block->scope, f); + + scf_node_add_child((scf_node_t*)fd->parent_block, (scf_node_t*)f); } SCF_DFA_PUSH_HOOK(scf_dfa_find_node(dfa, "function_end"), SCF_DFA_HOOK_END); - fd->parent_block = parse->ast->current_block; parse->ast->current_block = (scf_block_t*)d->current_function; return SCF_DFA_NEXT_WORD; @@ -446,4 +484,3 @@ scf_dfa_module_t dfa_module_function = .fini_module = _dfa_fini_module_function, }; - diff --git a/parse/scf_dfa_init_data.c b/parse/scf_dfa_init_data.c index 22eb030..62fc35a 100644 --- a/parse/scf_dfa_init_data.c +++ b/parse/scf_dfa_init_data.c @@ -279,4 +279,3 @@ scf_dfa_module_t dfa_module_init_data = .init_module = _dfa_init_module_init_data, .init_syntax = _dfa_init_syntax_init_data, }; - diff --git a/parse/scf_dfa_parse.c b/parse/scf_dfa_parse.c index 0ae935f..b6805a5 100644 --- a/parse/scf_dfa_parse.c +++ b/parse/scf_dfa_parse.c @@ -30,14 +30,14 @@ extern scf_dfa_module_t dfa_module_do; extern scf_dfa_module_t dfa_module_for; extern scf_dfa_module_t dfa_module_switch; -#if 1 + extern scf_dfa_module_t dfa_module_break; extern scf_dfa_module_t dfa_module_continue; extern scf_dfa_module_t dfa_module_return; extern scf_dfa_module_t dfa_module_goto; extern scf_dfa_module_t dfa_module_label; extern scf_dfa_module_t dfa_module_async; -#endif + extern scf_dfa_module_t dfa_module_block; scf_dfa_module_t* dfa_modules[] = @@ -167,13 +167,7 @@ static void dfa_free_word(void* word) scf_lex_word_t* w = word; scf_lex_word_free(w); } -#if 0 -static int dfa_same_type(void* word, scf_dfa_word_t* dfa_word) -{ - scf_lex_word_t* w = word; - return w->type == dfa_word->type; -} -#endif + scf_dfa_ops_t dfa_ops_parse = { .name = "parse", @@ -181,5 +175,4 @@ scf_dfa_ops_t dfa_ops_parse = .pop_word = dfa_pop_word, .push_word = dfa_push_word, .free_word = dfa_free_word, -// .same_type = dfa_same_type, }; diff --git a/parse/scf_dfa_util.h b/parse/scf_dfa_util.h index 17ad513..d8f75fd 100644 --- a/parse/scf_dfa_util.h +++ b/parse/scf_dfa_util.h @@ -81,13 +81,6 @@ static inline int scf_dfa_is_union(scf_dfa_t* dfa, void* word) return SCF_LEX_WORD_KEY_UNION == w->type; } -static inline int scf_dfa_is_end_struct(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_END_STRUCT == w->type; -} - static inline int scf_dfa_is_colon(scf_dfa_t* dfa, void* word) { scf_lex_word_t* w = word; @@ -109,20 +102,6 @@ static inline int scf_dfa_is_assign(scf_dfa_t* dfa, void* word) return SCF_LEX_WORD_ASSIGN == w->type; } -static inline int scf_dfa_is_array(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_ARRAY == w->type; -} - -static inline int scf_dfa_is_of(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_OF == w->type; -} - static inline int scf_dfa_is_identity(scf_dfa_t* dfa, void* word) { scf_lex_word_t* w = word; @@ -235,27 +214,6 @@ static inline int scf_dfa_is_else(scf_dfa_t* dfa, void* word) return SCF_LEX_WORD_KEY_ELSE == w->type; } -static inline int scf_dfa_is_then(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_THEN == w->type; -} - -static inline int scf_dfa_is_elsif(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_ELSIF == w->type; -} - -static inline int scf_dfa_is_end_if(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_END_IF == w->type; -} - static inline int scf_dfa_is_continue(scf_dfa_t* dfa, void* word) { scf_lex_word_t* w = word; @@ -284,13 +242,6 @@ static inline int scf_dfa_is_goto(scf_dfa_t* dfa, void* word) return SCF_LEX_WORD_KEY_GOTO == w->type; } -static inline int scf_dfa_is_exit(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_EXIT == w->type; -} - static inline int scf_dfa_is_while(scf_dfa_t* dfa, void* word) { scf_lex_word_t* w = word; @@ -305,27 +256,6 @@ static inline int scf_dfa_is_do(scf_dfa_t* dfa, void* word) return SCF_LEX_WORD_KEY_DO == w->type; } -static inline int scf_dfa_is_to(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_TO == w->type; -} - -static inline int scf_dfa_is_by(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_BY == w->type; -} - -static inline int scf_dfa_is_end_while(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_END_WHILE == w->type; -} - static inline int scf_dfa_is_for(scf_dfa_t* dfa, void* word) { scf_lex_word_t* w = word; @@ -333,13 +263,6 @@ static inline int scf_dfa_is_for(scf_dfa_t* dfa, void* word) return SCF_LEX_WORD_KEY_FOR == w->type; } -static inline int scf_dfa_is_end_for(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_END_FOR == w->type; -} - static inline int scf_dfa_is_switch(scf_dfa_t* dfa, void* word) { scf_lex_word_t* w = word; @@ -361,48 +284,6 @@ static inline int scf_dfa_is_case(scf_dfa_t* dfa, void* word) return SCF_LEX_WORD_KEY_CASE == w->type; } -static inline int scf_dfa_is_end_case(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_END_CASE == w->type; -} - -static inline int scf_dfa_is_repeat(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_REPEAT == w->type; -} - -static inline int scf_dfa_is_until(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_UNTIL == w->type; -} - -static inline int scf_dfa_is_end_repeat(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_END_REPEAT == w->type; -} - -static inline int scf_dfa_is_function(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_FUNCTION == w->type; -} - -static inline int scf_dfa_is_end_function(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_END_FUNCTION == w->type; -} - static inline int scf_dfa_is_var(scf_dfa_t* dfa, void* word) { scf_lex_word_t* w = word; @@ -410,60 +291,4 @@ static inline int scf_dfa_is_var(scf_dfa_t* dfa, void* word) return SCF_LEX_WORD_KEY_VAR == w->type; } -static inline int scf_dfa_is_var_input(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_VAR_INPUT == w->type; -} - -static inline int scf_dfa_is_var_output(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_VAR_OUTPUT == w->type; -} - -static inline int scf_dfa_is_var_in_out(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_VAR_IN_OUT == w->type; -} - -static inline int scf_dfa_is_var_temp(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_VAR_TEMP == w->type; -} - -static inline int scf_dfa_is_var_const(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_VAR_CONSTANT == w->type; -} - -static inline int scf_dfa_is_var_global(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_VAR_GLOBAL == w->type; -} - -static inline int scf_dfa_is_var_external(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_VAR_EXTERNAL == w->type; -} - -static inline int scf_dfa_is_end_var(scf_dfa_t* dfa, void* word) -{ - scf_lex_word_t* w = word; - - return SCF_LEX_WORD_KEY_END_VAR == w->type; -} - #endif diff --git a/parse/scf_dfa_var.c b/parse/scf_dfa_var.c index a2ef7cb..00d0282 100644 --- a/parse/scf_dfa_var.c +++ b/parse/scf_dfa_var.c @@ -348,7 +348,6 @@ static int _var_action_ls(scf_dfa_t* dfa, scf_vector_t* words, void* data) d->current_var->const_literal_flag = 1; SCF_DFA_PUSH_HOOK(scf_dfa_find_node(dfa, "var_rs"), SCF_DFA_HOOK_POST); - //SCF_DFA_PUSH_END_WORD(SCF_LEX_WORD_RS, var, 0); d->nb_lss++; -- 2.25.1