diff options
-rw-r--r-- | miscutils/bc.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 1c47fba1d..4d252cc97 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -4986,6 +4986,7 @@ static BC_STATUS zdc_parse_expr(BcParse *p) | |||
4986 | BcStatus s; | 4986 | BcStatus s; |
4987 | 4987 | ||
4988 | t = p->l.t.t; | 4988 | t = p->l.t.t; |
4989 | dbg_lex("%s:%d G.prs.l.t.t:%d", __func__, __LINE__, G.prs.l.t.t); | ||
4989 | if (t == BC_LEX_EOF) break; | 4990 | if (t == BC_LEX_EOF) break; |
4990 | 4991 | ||
4991 | inst = dc_parse_insts[t]; | 4992 | inst = dc_parse_insts[t]; |
@@ -5009,6 +5010,7 @@ static BC_STATUS zdc_parse_parse(BcParse *p) | |||
5009 | { | 5010 | { |
5010 | BcStatus s; | 5011 | BcStatus s; |
5011 | 5012 | ||
5013 | dbg_lex_enter("%s:%d entered", __func__, __LINE__); | ||
5012 | if (p->l.t.t == BC_LEX_EOF) | 5014 | if (p->l.t.t == BC_LEX_EOF) |
5013 | s = bc_error("end of file"); | 5015 | s = bc_error("end of file"); |
5014 | else | 5016 | else |
@@ -5019,22 +5021,13 @@ static BC_STATUS zdc_parse_parse(BcParse *p) | |||
5019 | s = BC_STATUS_FAILURE; | 5021 | s = BC_STATUS_FAILURE; |
5020 | } | 5022 | } |
5021 | 5023 | ||
5024 | dbg_lex_done("%s:%d done", __func__, __LINE__); | ||
5022 | RETURN_STATUS(s); | 5025 | RETURN_STATUS(s); |
5023 | } | 5026 | } |
5024 | #define zdc_parse_parse(...) (zdc_parse_parse(__VA_ARGS__) COMMA_SUCCESS) | 5027 | #define zdc_parse_parse(...) (zdc_parse_parse(__VA_ARGS__) COMMA_SUCCESS) |
5025 | 5028 | ||
5026 | #endif // ENABLE_DC | 5029 | #endif // ENABLE_DC |
5027 | 5030 | ||
5028 | static BC_STATUS zcommon_parse_expr(BcParse *p) | ||
5029 | { | ||
5030 | if (IS_BC) { | ||
5031 | IF_BC(RETURN_STATUS(zbc_parse_expr(p, 0))); | ||
5032 | } else { | ||
5033 | IF_DC(RETURN_STATUS(zdc_parse_expr(p))); | ||
5034 | } | ||
5035 | } | ||
5036 | #define zcommon_parse_expr(...) (zcommon_parse_expr(__VA_ARGS__) COMMA_SUCCESS) | ||
5037 | |||
5038 | static BcVec* bc_program_search(char *id, bool var) | 5031 | static BcVec* bc_program_search(char *id, bool var) |
5039 | { | 5032 | { |
5040 | BcId e, *ptr; | 5033 | BcId e, *ptr; |
@@ -5239,7 +5232,11 @@ static BC_STATUS zbc_program_read(void) | |||
5239 | 5232 | ||
5240 | s = zbc_parse_text_init(&parse, buf.v); | 5233 | s = zbc_parse_text_init(&parse, buf.v); |
5241 | if (s) goto exec_err; | 5234 | if (s) goto exec_err; |
5242 | s = zcommon_parse_expr(&parse); | 5235 | if (IS_BC) { |
5236 | IF_BC(s = zbc_parse_expr(&parse, 0)); | ||
5237 | } else { | ||
5238 | IF_DC(s = zdc_parse_expr(&parse)); | ||
5239 | } | ||
5243 | if (s) goto exec_err; | 5240 | if (s) goto exec_err; |
5244 | 5241 | ||
5245 | if (parse.l.t.t != BC_LEX_NLINE && parse.l.t.t != BC_LEX_EOF) { | 5242 | if (parse.l.t.t != BC_LEX_NLINE && parse.l.t.t != BC_LEX_EOF) { |
@@ -6367,7 +6364,7 @@ static BC_STATUS zdc_program_execStr(char *code, size_t *bgn, bool cond) | |||
6367 | str = *bc_program_str(sidx); | 6364 | str = *bc_program_str(sidx); |
6368 | s = zbc_parse_text_init(&prs, str); | 6365 | s = zbc_parse_text_init(&prs, str); |
6369 | if (s) goto err; | 6366 | if (s) goto err; |
6370 | s = zcommon_parse_expr(&prs); | 6367 | s = zdc_parse_expr(&prs); |
6371 | if (s) goto err; | 6368 | if (s) goto err; |
6372 | if (prs.l.t.t != BC_LEX_EOF) { | 6369 | if (prs.l.t.t != BC_LEX_EOF) { |
6373 | s = bc_error_bad_expression(); | 6370 | s = bc_error_bad_expression(); |