When the gen_tab has only one entry, do not call optimize_gen_tab, it is not necessary.
This commit is contained in:
parent
574737b7b6
commit
a922f797d3
|
|
@ -382,7 +382,7 @@ typedef struct parse_table *PTABLE;
|
||||||
struct parse_table {
|
struct parse_table {
|
||||||
TLINE first;
|
TLINE first;
|
||||||
TLINE last;
|
TLINE last;
|
||||||
int num_entries;
|
unsigned int num_entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
static PTABLE parse_tab = NULL;
|
static PTABLE parse_tab = NULL;
|
||||||
|
|
@ -1295,10 +1295,7 @@ static BOOL bparse(char *line, BOOL new_lexer)
|
||||||
lookahead = lex_scan(); // ':'
|
lookahead = lex_scan(); // ':'
|
||||||
lookahead = lex_scan();
|
lookahead = lex_scan();
|
||||||
while (lookahead != '\0') {
|
while (lookahead != '\0') {
|
||||||
#define LOOP_OPT
|
unsigned int last_count = 0, curr_count = 0;
|
||||||
#ifdef LOOP_OPT
|
|
||||||
int last_count = 0, curr_count = 0;
|
|
||||||
#endif
|
|
||||||
init_parse_tables();
|
init_parse_tables();
|
||||||
adepth = max_adepth = 0;
|
adepth = max_adepth = 0;
|
||||||
stmt_num++;
|
stmt_num++;
|
||||||
|
|
@ -1309,53 +1306,35 @@ static BOOL bparse(char *line, BOOL new_lexer)
|
||||||
beval_order();
|
beval_order();
|
||||||
|
|
||||||
/* generate gates only when optimizations are successful */
|
/* generate gates only when optimizations are successful */
|
||||||
opt_tab1 = optimize_gen_tab(gen_tab);
|
|
||||||
#ifdef LOOP_OPT
|
|
||||||
last_count = gen_tab->num_entries;
|
last_count = gen_tab->num_entries;
|
||||||
if (opt_tab1) {
|
if (last_count == 1) {
|
||||||
int loop_count = 0;
|
gen_gates(gen_tab, lx->lexer_sym_tab);
|
||||||
curr_count = opt_tab1->num_entries;
|
} else if (last_count > 1) {
|
||||||
#ifdef TRACE
|
opt_tab1 = optimize_gen_tab(gen_tab);
|
||||||
printf("Start opt last_count %d curr_count %d\n", last_count, curr_count);
|
if (opt_tab1) {
|
||||||
#endif
|
curr_count = opt_tab1->num_entries;
|
||||||
opt_tab2 = opt_tab1;
|
opt_tab2 = opt_tab1;
|
||||||
while (curr_count > 1 && curr_count < last_count) {
|
while (curr_count > 1 && curr_count < last_count) {
|
||||||
loop_count++;
|
last_count = curr_count;
|
||||||
last_count = curr_count;
|
opt_tab2 = optimize_gen_tab(opt_tab1);
|
||||||
opt_tab2 = optimize_gen_tab(opt_tab1);
|
delete_parse_table(opt_tab1);
|
||||||
delete_parse_table(opt_tab1);
|
if (!opt_tab2) {
|
||||||
if (!opt_tab2) {
|
ret_val = FALSE;
|
||||||
ret_val = FALSE;
|
break;
|
||||||
break;
|
}
|
||||||
|
opt_tab1 = opt_tab2;
|
||||||
|
curr_count = opt_tab2->num_entries;
|
||||||
}
|
}
|
||||||
opt_tab1 = opt_tab2;
|
if (opt_tab2) {
|
||||||
curr_count = opt_tab2->num_entries;
|
gen_gates(opt_tab2, lx->lexer_sym_tab);
|
||||||
#ifdef TRACE
|
delete_parse_table(opt_tab2);
|
||||||
printf("Next(%d) opt last_count %d curr_count %d\n", loop_count, last_count, curr_count);
|
}
|
||||||
#endif
|
} else {
|
||||||
}
|
ret_val = FALSE;
|
||||||
#ifdef TRACE
|
|
||||||
printf("Finish opt last_count %d curr_count %d\n", last_count, curr_count);
|
|
||||||
#endif
|
|
||||||
if (opt_tab2) {
|
|
||||||
gen_gates(opt_tab2, lx->lexer_sym_tab);
|
|
||||||
delete_parse_table(opt_tab2);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret_val = FALSE;
|
ret_val = FALSE;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (opt_tab1) {
|
|
||||||
opt_tab2 = optimize_gen_tab(opt_tab1);
|
|
||||||
if (opt_tab2) {
|
|
||||||
gen_gates(opt_tab2, lx->lexer_sym_tab);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ret_val = FALSE;
|
|
||||||
}
|
|
||||||
delete_parse_table(opt_tab1);
|
|
||||||
delete_parse_table(opt_tab2);
|
|
||||||
#endif
|
|
||||||
delete_parse_gen_tables();
|
delete_parse_gen_tables();
|
||||||
if (!ret_val) {
|
if (!ret_val) {
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue