diff options
-rw-r--r-- | miscutils/bc.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index a67cfbfcd..d2b74ea90 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -392,11 +392,11 @@ typedef enum BcLexType { | |||
392 | XC_LEX_EOF, | 392 | XC_LEX_EOF, |
393 | XC_LEX_INVALID, | 393 | XC_LEX_INVALID, |
394 | 394 | ||
395 | BC_LEX_NLINE, | 395 | XC_LEX_NLINE, |
396 | BC_LEX_WHITESPACE, | 396 | XC_LEX_WHITESPACE, |
397 | BC_LEX_STR, | 397 | XC_LEX_STR, |
398 | BC_LEX_NAME, | 398 | XC_LEX_NAME, |
399 | BC_LEX_NUMBER, | 399 | XC_LEX_NUMBER, |
400 | 400 | ||
401 | XC_LEX_1st_op, | 401 | XC_LEX_1st_op, |
402 | XC_LEX_NEG = XC_LEX_1st_op, // order | 402 | XC_LEX_NEG = XC_LEX_1st_op, // order |
@@ -2745,7 +2745,7 @@ static void bc_lex_lineComment(BcLex *l) | |||
2745 | { | 2745 | { |
2746 | // Try: echo -n '#foo' | bc | 2746 | // Try: echo -n '#foo' | bc |
2747 | size_t i; | 2747 | size_t i; |
2748 | l->t.t = BC_LEX_WHITESPACE; | 2748 | l->t.t = XC_LEX_WHITESPACE; |
2749 | i = l->i; | 2749 | i = l->i; |
2750 | while (i < l->len && l->buf[i] != '\n') | 2750 | while (i < l->len && l->buf[i] != '\n') |
2751 | i++; | 2751 | i++; |
@@ -2754,10 +2754,10 @@ static void bc_lex_lineComment(BcLex *l) | |||
2754 | 2754 | ||
2755 | static void bc_lex_whitespace(BcLex *l) | 2755 | static void bc_lex_whitespace(BcLex *l) |
2756 | { | 2756 | { |
2757 | l->t.t = BC_LEX_WHITESPACE; | 2757 | l->t.t = XC_LEX_WHITESPACE; |
2758 | for (;;) { | 2758 | for (;;) { |
2759 | char c = l->buf[l->i]; | 2759 | char c = l->buf[l->i]; |
2760 | if (c == '\n') // this is BC_LEX_NLINE, not BC_LEX_WHITESPACE | 2760 | if (c == '\n') // this is XC_LEX_NLINE, not XC_LEX_WHITESPACE |
2761 | break; | 2761 | break; |
2762 | if (!isspace(c)) | 2762 | if (!isspace(c)) |
2763 | break; | 2763 | break; |
@@ -2772,7 +2772,7 @@ static BC_STATUS zbc_lex_number(BcLex *l, char start) | |||
2772 | bool pt; | 2772 | bool pt; |
2773 | 2773 | ||
2774 | pt = (start == '.'); | 2774 | pt = (start == '.'); |
2775 | l->t.t = BC_LEX_NUMBER; | 2775 | l->t.t = XC_LEX_NUMBER; |
2776 | ccnt = i = 0; | 2776 | ccnt = i = 0; |
2777 | for (;;) { | 2777 | for (;;) { |
2778 | char c = buf[i]; | 2778 | char c = buf[i]; |
@@ -2840,7 +2840,7 @@ static void bc_lex_name(BcLex *l) | |||
2840 | size_t i; | 2840 | size_t i; |
2841 | const char *buf; | 2841 | const char *buf; |
2842 | 2842 | ||
2843 | l->t.t = BC_LEX_NAME; | 2843 | l->t.t = XC_LEX_NAME; |
2844 | 2844 | ||
2845 | i = 0; | 2845 | i = 0; |
2846 | buf = l->buf + l->i - 1; | 2846 | buf = l->buf + l->i - 1; |
@@ -2971,7 +2971,7 @@ static BC_STATUS zbc_lex_next(BcLex *l) | |||
2971 | 2971 | ||
2972 | // Loop until failure or we don't have whitespace. This | 2972 | // Loop until failure or we don't have whitespace. This |
2973 | // is so the parser doesn't get inundated with whitespace. | 2973 | // is so the parser doesn't get inundated with whitespace. |
2974 | // Comments are also BC_LEX_WHITESPACE tokens and eaten here. | 2974 | // Comments are also XC_LEX_WHITESPACE tokens and eaten here. |
2975 | s = BC_STATUS_SUCCESS; | 2975 | s = BC_STATUS_SUCCESS; |
2976 | do { | 2976 | do { |
2977 | if (l->i == l->len) { | 2977 | if (l->i == l->len) { |
@@ -2992,7 +2992,7 @@ static BC_STATUS zbc_lex_next(BcLex *l) | |||
2992 | } else { | 2992 | } else { |
2993 | IF_DC(s = zdc_lex_token(l)); | 2993 | IF_DC(s = zdc_lex_token(l)); |
2994 | } | 2994 | } |
2995 | } while (!s && l->t.t == BC_LEX_WHITESPACE); | 2995 | } while (!s && l->t.t == XC_LEX_WHITESPACE); |
2996 | dbg_lex("l->t.t from string:%d", l->t.t); | 2996 | dbg_lex("l->t.t from string:%d", l->t.t); |
2997 | 2997 | ||
2998 | RETURN_STATUS(s); | 2998 | RETURN_STATUS(s); |
@@ -3002,7 +3002,7 @@ static BC_STATUS zbc_lex_next(BcLex *l) | |||
3002 | #if ENABLE_BC | 3002 | #if ENABLE_BC |
3003 | static BC_STATUS zbc_lex_skip_if_at_NLINE(BcLex *l) | 3003 | static BC_STATUS zbc_lex_skip_if_at_NLINE(BcLex *l) |
3004 | { | 3004 | { |
3005 | if (l->t.t == BC_LEX_NLINE) | 3005 | if (l->t.t == XC_LEX_NLINE) |
3006 | RETURN_STATUS(zbc_lex_next(l)); | 3006 | RETURN_STATUS(zbc_lex_next(l)); |
3007 | RETURN_STATUS(BC_STATUS_SUCCESS); | 3007 | RETURN_STATUS(BC_STATUS_SUCCESS); |
3008 | } | 3008 | } |
@@ -3081,7 +3081,7 @@ static BC_STATUS zbc_lex_string(BcLex *l) | |||
3081 | { | 3081 | { |
3082 | size_t len, nls, i; | 3082 | size_t len, nls, i; |
3083 | 3083 | ||
3084 | l->t.t = BC_LEX_STR; | 3084 | l->t.t = XC_LEX_STR; |
3085 | 3085 | ||
3086 | nls = 0; | 3086 | nls = 0; |
3087 | i = l->i; | 3087 | i = l->i; |
@@ -3129,7 +3129,7 @@ static BC_STATUS zbc_lex_comment(BcLex *l) | |||
3129 | size_t i, nls = 0; | 3129 | size_t i, nls = 0; |
3130 | const char *buf = l->buf; | 3130 | const char *buf = l->buf; |
3131 | 3131 | ||
3132 | l->t.t = BC_LEX_WHITESPACE; | 3132 | l->t.t = XC_LEX_WHITESPACE; |
3133 | i = l->i; /* here buf[l->i] is the '*' of opening comment delimiter */ | 3133 | i = l->i; /* here buf[l->i] is the '*' of opening comment delimiter */ |
3134 | for (;;) { | 3134 | for (;;) { |
3135 | char c = buf[++i]; | 3135 | char c = buf[++i]; |
@@ -3169,7 +3169,7 @@ static BC_STATUS zbc_lex_token(BcLex *l) | |||
3169 | // l->newline = true; | 3169 | // l->newline = true; |
3170 | // break; | 3170 | // break; |
3171 | case '\n': | 3171 | case '\n': |
3172 | l->t.t = BC_LEX_NLINE; | 3172 | l->t.t = XC_LEX_NLINE; |
3173 | l->newline = true; | 3173 | l->newline = true; |
3174 | break; | 3174 | break; |
3175 | case '\t': | 3175 | case '\t': |
@@ -3286,7 +3286,7 @@ static BC_STATUS zbc_lex_token(BcLex *l) | |||
3286 | break; | 3286 | break; |
3287 | case '\\': | 3287 | case '\\': |
3288 | if (l->buf[l->i] == '\n') { | 3288 | if (l->buf[l->i] == '\n') { |
3289 | l->t.t = BC_LEX_WHITESPACE; | 3289 | l->t.t = XC_LEX_WHITESPACE; |
3290 | ++l->i; | 3290 | ++l->i; |
3291 | } else | 3291 | } else |
3292 | s = bc_error_bad_character(c); | 3292 | s = bc_error_bad_character(c); |
@@ -3360,7 +3360,7 @@ static BC_STATUS zdc_lex_register(BcLex *l) | |||
3360 | bc_vec_pop_all(&l->t.v); | 3360 | bc_vec_pop_all(&l->t.v); |
3361 | bc_vec_push(&l->t.v, &l->buf[l->i++]); | 3361 | bc_vec_push(&l->t.v, &l->buf[l->i++]); |
3362 | bc_vec_pushZeroByte(&l->t.v); | 3362 | bc_vec_pushZeroByte(&l->t.v); |
3363 | l->t.t = BC_LEX_NAME; | 3363 | l->t.t = XC_LEX_NAME; |
3364 | } | 3364 | } |
3365 | 3365 | ||
3366 | RETURN_STATUS(BC_STATUS_SUCCESS); | 3366 | RETURN_STATUS(BC_STATUS_SUCCESS); |
@@ -3371,7 +3371,7 @@ static BC_STATUS zdc_lex_string(BcLex *l) | |||
3371 | { | 3371 | { |
3372 | size_t depth, nls, i; | 3372 | size_t depth, nls, i; |
3373 | 3373 | ||
3374 | l->t.t = BC_LEX_STR; | 3374 | l->t.t = XC_LEX_STR; |
3375 | bc_vec_pop_all(&l->t.v); | 3375 | bc_vec_pop_all(&l->t.v); |
3376 | 3376 | ||
3377 | nls = 0; | 3377 | nls = 0; |
@@ -3445,7 +3445,7 @@ static BC_STATUS zdc_lex_token(BcLex *l) | |||
3445 | // l->t.t = XC_LEX_EOF; | 3445 | // l->t.t = XC_LEX_EOF; |
3446 | // break; | 3446 | // break; |
3447 | case '\n': | 3447 | case '\n': |
3448 | // '\n' is BC_LEX_NLINE, not BC_LEX_WHITESPACE | 3448 | // '\n' is XC_LEX_NLINE, not XC_LEX_WHITESPACE |
3449 | // (and "case '\n':" is not just empty here) | 3449 | // (and "case '\n':" is not just empty here) |
3450 | // only to allow interactive dc have a way to exit | 3450 | // only to allow interactive dc have a way to exit |
3451 | // "parse" stage of "parse,execute" loop | 3451 | // "parse" stage of "parse,execute" loop |
@@ -3453,7 +3453,7 @@ static BC_STATUS zdc_lex_token(BcLex *l) | |||
3453 | // commands are not executed on pressing <enter>). | 3453 | // commands are not executed on pressing <enter>). |
3454 | // IOW: typing "1p<enter>" should print "1" _at once_, | 3454 | // IOW: typing "1p<enter>" should print "1" _at once_, |
3455 | // not after some more input. | 3455 | // not after some more input. |
3456 | l->t.t = BC_LEX_NLINE; | 3456 | l->t.t = XC_LEX_NLINE; |
3457 | l->newline = true; | 3457 | l->newline = true; |
3458 | break; | 3458 | break; |
3459 | case '\t': | 3459 | case '\t': |
@@ -3737,7 +3737,7 @@ static BC_STATUS zbc_parse_stmt_allow_NLINE_before(BcParse *p, const char *after | |||
3737 | // Same for "else", "while()", "for()". | 3737 | // Same for "else", "while()", "for()". |
3738 | BcStatus s = zbc_lex_next_and_skip_NLINE(&p->l); | 3738 | BcStatus s = zbc_lex_next_and_skip_NLINE(&p->l); |
3739 | if (s) RETURN_STATUS(s); | 3739 | if (s) RETURN_STATUS(s); |
3740 | if (p->l.t.t == BC_LEX_NLINE) | 3740 | if (p->l.t.t == XC_LEX_NLINE) |
3741 | RETURN_STATUS(bc_error_fmt("no statement after '%s'", after_X)); | 3741 | RETURN_STATUS(bc_error_fmt("no statement after '%s'", after_X)); |
3742 | 3742 | ||
3743 | RETURN_STATUS(zbc_parse_stmt(p)); | 3743 | RETURN_STATUS(zbc_parse_stmt(p)); |
@@ -4012,7 +4012,7 @@ static BC_STATUS zbc_parse_incdec(BcParse *p, BcInst *prev, bool *paren_expr, | |||
4012 | *nexprs = *nexprs + 1; | 4012 | *nexprs = *nexprs + 1; |
4013 | 4013 | ||
4014 | switch (type) { | 4014 | switch (type) { |
4015 | case BC_LEX_NAME: | 4015 | case XC_LEX_NAME: |
4016 | s = zbc_parse_name(p, prev, flags | BC_PARSE_NOCALL); | 4016 | s = zbc_parse_name(p, prev, flags | BC_PARSE_NOCALL); |
4017 | break; | 4017 | break; |
4018 | case BC_LEX_KEY_IBASE: | 4018 | case BC_LEX_KEY_IBASE: |
@@ -4077,7 +4077,7 @@ static BC_STATUS zbc_parse_print(BcParse *p) | |||
4077 | s = zbc_lex_next(&p->l); | 4077 | s = zbc_lex_next(&p->l); |
4078 | if (s) RETURN_STATUS(s); | 4078 | if (s) RETURN_STATUS(s); |
4079 | type = p->l.t.t; | 4079 | type = p->l.t.t; |
4080 | if (type == BC_LEX_STR) { | 4080 | if (type == XC_LEX_STR) { |
4081 | s = zbc_parse_pushSTR(p); | 4081 | s = zbc_parse_pushSTR(p); |
4082 | } else { | 4082 | } else { |
4083 | s = zbc_parse_expr(p, 0); | 4083 | s = zbc_parse_expr(p, 0); |
@@ -4102,7 +4102,7 @@ static BC_STATUS zbc_parse_return(BcParse *p) | |||
4102 | if (s) RETURN_STATUS(s); | 4102 | if (s) RETURN_STATUS(s); |
4103 | 4103 | ||
4104 | t = p->l.t.t; | 4104 | t = p->l.t.t; |
4105 | if (t == BC_LEX_NLINE || t == BC_LEX_SCOLON) | 4105 | if (t == XC_LEX_NLINE || t == BC_LEX_SCOLON) |
4106 | bc_parse_push(p, BC_INST_RET0); | 4106 | bc_parse_push(p, BC_INST_RET0); |
4107 | else { | 4107 | else { |
4108 | bool paren = (t == BC_LEX_LPAREN); | 4108 | bool paren = (t == BC_LEX_LPAREN); |
@@ -4327,7 +4327,7 @@ static BC_STATUS zbc_parse_break_or_continue(BcParse *p, BcLexType type) | |||
4327 | s = zbc_lex_next(&p->l); | 4327 | s = zbc_lex_next(&p->l); |
4328 | if (s) RETURN_STATUS(s); | 4328 | if (s) RETURN_STATUS(s); |
4329 | 4329 | ||
4330 | if (p->l.t.t != BC_LEX_SCOLON && p->l.t.t != BC_LEX_NLINE) | 4330 | if (p->l.t.t != BC_LEX_SCOLON && p->l.t.t != XC_LEX_NLINE) |
4331 | RETURN_STATUS(bc_error_bad_token()); | 4331 | RETURN_STATUS(bc_error_bad_token()); |
4332 | 4332 | ||
4333 | RETURN_STATUS(zbc_lex_next(&p->l)); | 4333 | RETURN_STATUS(zbc_lex_next(&p->l)); |
@@ -4364,7 +4364,7 @@ static BC_STATUS zbc_parse_funcdef(BcParse *p) | |||
4364 | dbg_lex_enter("%s:%d entered", __func__, __LINE__); | 4364 | dbg_lex_enter("%s:%d entered", __func__, __LINE__); |
4365 | s = zbc_lex_next(&p->l); | 4365 | s = zbc_lex_next(&p->l); |
4366 | if (s) RETURN_STATUS(s); | 4366 | if (s) RETURN_STATUS(s); |
4367 | if (p->l.t.t != BC_LEX_NAME) | 4367 | if (p->l.t.t != XC_LEX_NAME) |
4368 | RETURN_STATUS(bc_error("bad function definition")); | 4368 | RETURN_STATUS(bc_error("bad function definition")); |
4369 | 4369 | ||
4370 | name = xstrdup(p->l.t.v.v); | 4370 | name = xstrdup(p->l.t.v.v); |
@@ -4379,7 +4379,7 @@ static BC_STATUS zbc_parse_funcdef(BcParse *p) | |||
4379 | if (s) RETURN_STATUS(s); | 4379 | if (s) RETURN_STATUS(s); |
4380 | 4380 | ||
4381 | while (p->l.t.t != BC_LEX_RPAREN) { | 4381 | while (p->l.t.t != BC_LEX_RPAREN) { |
4382 | if (p->l.t.t != BC_LEX_NAME) | 4382 | if (p->l.t.t != XC_LEX_NAME) |
4383 | RETURN_STATUS(bc_error("bad function definition")); | 4383 | RETURN_STATUS(bc_error("bad function definition")); |
4384 | 4384 | ||
4385 | ++p->func->nparams; | 4385 | ++p->func->nparams; |
@@ -4459,9 +4459,9 @@ static BC_STATUS zbc_parse_auto(BcParse *p) | |||
4459 | if (s) RETURN_STATUS(s); | 4459 | if (s) RETURN_STATUS(s); |
4460 | 4460 | ||
4461 | comma = false; | 4461 | comma = false; |
4462 | one = p->l.t.t == BC_LEX_NAME; | 4462 | one = p->l.t.t == XC_LEX_NAME; |
4463 | 4463 | ||
4464 | while (p->l.t.t == BC_LEX_NAME) { | 4464 | while (p->l.t.t == XC_LEX_NAME) { |
4465 | name = xstrdup(p->l.t.v.v); | 4465 | name = xstrdup(p->l.t.v.v); |
4466 | s = zbc_lex_next(&p->l); | 4466 | s = zbc_lex_next(&p->l); |
4467 | if (s) goto err; | 4467 | if (s) goto err; |
@@ -4493,7 +4493,7 @@ static BC_STATUS zbc_parse_auto(BcParse *p) | |||
4493 | if (comma) RETURN_STATUS(bc_error("bad function definition")); | 4493 | if (comma) RETURN_STATUS(bc_error("bad function definition")); |
4494 | if (!one) RETURN_STATUS(bc_error("no auto variable found")); | 4494 | if (!one) RETURN_STATUS(bc_error("no auto variable found")); |
4495 | 4495 | ||
4496 | if (p->l.t.t != BC_LEX_NLINE && p->l.t.t != BC_LEX_SCOLON) | 4496 | if (p->l.t.t != XC_LEX_NLINE && p->l.t.t != BC_LEX_SCOLON) |
4497 | RETURN_STATUS(bc_error_bad_token()); | 4497 | RETURN_STATUS(bc_error_bad_token()); |
4498 | 4498 | ||
4499 | dbg_lex_done("%s:%d done", __func__, __LINE__); | 4499 | dbg_lex_done("%s:%d done", __func__, __LINE__); |
@@ -4512,8 +4512,8 @@ static BC_STATUS zbc_parse_stmt_possibly_auto(BcParse *p, bool auto_allowed) | |||
4512 | 4512 | ||
4513 | dbg_lex_enter("%s:%d entered, p->l.t.t:%d", __func__, __LINE__, p->l.t.t); | 4513 | dbg_lex_enter("%s:%d entered, p->l.t.t:%d", __func__, __LINE__, p->l.t.t); |
4514 | 4514 | ||
4515 | if (p->l.t.t == BC_LEX_NLINE) { | 4515 | if (p->l.t.t == XC_LEX_NLINE) { |
4516 | dbg_lex_done("%s:%d done (seen BC_LEX_NLINE)", __func__, __LINE__); | 4516 | dbg_lex_done("%s:%d done (seen XC_LEX_NLINE)", __func__, __LINE__); |
4517 | RETURN_STATUS(zbc_lex_next(&p->l)); | 4517 | RETURN_STATUS(zbc_lex_next(&p->l)); |
4518 | } | 4518 | } |
4519 | if (p->l.t.t == BC_LEX_SCOLON) { | 4519 | if (p->l.t.t == BC_LEX_SCOLON) { |
@@ -4526,7 +4526,7 @@ static BC_STATUS zbc_parse_stmt_possibly_auto(BcParse *p, bool auto_allowed) | |||
4526 | do { | 4526 | do { |
4527 | s = zbc_lex_next(&p->l); | 4527 | s = zbc_lex_next(&p->l); |
4528 | if (s) RETURN_STATUS(s); | 4528 | if (s) RETURN_STATUS(s); |
4529 | } while (p->l.t.t == BC_LEX_NLINE); | 4529 | } while (p->l.t.t == XC_LEX_NLINE); |
4530 | if (auto_allowed && p->l.t.t == BC_LEX_KEY_AUTO) { | 4530 | if (auto_allowed && p->l.t.t == BC_LEX_KEY_AUTO) { |
4531 | dbg_lex("%s:%d calling zbc_parse_auto()", __func__, __LINE__); | 4531 | dbg_lex("%s:%d calling zbc_parse_auto()", __func__, __LINE__); |
4532 | s = zbc_parse_auto(p); | 4532 | s = zbc_parse_auto(p); |
@@ -4549,8 +4549,8 @@ static BC_STATUS zbc_parse_stmt_possibly_auto(BcParse *p, bool auto_allowed) | |||
4549 | case BC_LEX_OP_DEC: | 4549 | case BC_LEX_OP_DEC: |
4550 | case BC_LEX_OP_BOOL_NOT: | 4550 | case BC_LEX_OP_BOOL_NOT: |
4551 | case BC_LEX_LPAREN: | 4551 | case BC_LEX_LPAREN: |
4552 | case BC_LEX_NAME: | 4552 | case XC_LEX_NAME: |
4553 | case BC_LEX_NUMBER: | 4553 | case XC_LEX_NUMBER: |
4554 | case BC_LEX_KEY_IBASE: | 4554 | case BC_LEX_KEY_IBASE: |
4555 | case BC_LEX_KEY_LAST: | 4555 | case BC_LEX_KEY_LAST: |
4556 | case BC_LEX_KEY_LENGTH: | 4556 | case BC_LEX_KEY_LENGTH: |
@@ -4560,7 +4560,7 @@ static BC_STATUS zbc_parse_stmt_possibly_auto(BcParse *p, bool auto_allowed) | |||
4560 | case BC_LEX_KEY_SQRT: | 4560 | case BC_LEX_KEY_SQRT: |
4561 | s = zbc_parse_expr(p, BC_PARSE_PRINT); | 4561 | s = zbc_parse_expr(p, BC_PARSE_PRINT); |
4562 | break; | 4562 | break; |
4563 | case BC_LEX_STR: | 4563 | case XC_LEX_STR: |
4564 | s = zbc_parse_pushSTR(p); | 4564 | s = zbc_parse_pushSTR(p); |
4565 | bc_parse_push(p, XC_INST_PRINT_STR); | 4565 | bc_parse_push(p, XC_INST_PRINT_STR); |
4566 | break; | 4566 | break; |
@@ -4738,7 +4738,7 @@ static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags) | |||
4738 | get_token = bin_last = false; | 4738 | get_token = bin_last = false; |
4739 | s = zbc_parse_rightParen(p, ops_bgn, &nexprs); | 4739 | s = zbc_parse_rightParen(p, ops_bgn, &nexprs); |
4740 | break; | 4740 | break; |
4741 | case BC_LEX_NAME: | 4741 | case XC_LEX_NAME: |
4742 | if (BC_PARSE_LEAF(prev, rprn)) | 4742 | if (BC_PARSE_LEAF(prev, rprn)) |
4743 | return bc_error_bad_expression(); | 4743 | return bc_error_bad_expression(); |
4744 | paren_expr = true; | 4744 | paren_expr = true; |
@@ -4746,7 +4746,7 @@ static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags) | |||
4746 | s = zbc_parse_name(p, &prev, flags & ~BC_PARSE_NOCALL); | 4746 | s = zbc_parse_name(p, &prev, flags & ~BC_PARSE_NOCALL); |
4747 | ++nexprs; | 4747 | ++nexprs; |
4748 | break; | 4748 | break; |
4749 | case BC_LEX_NUMBER: | 4749 | case XC_LEX_NUMBER: |
4750 | if (BC_PARSE_LEAF(prev, rprn)) | 4750 | if (BC_PARSE_LEAF(prev, rprn)) |
4751 | return bc_error_bad_expression(); | 4751 | return bc_error_bad_expression(); |
4752 | bc_parse_pushNUM(p); | 4752 | bc_parse_pushNUM(p); |
@@ -4848,7 +4848,7 @@ static BC_STATUS zdc_parse_register(BcParse *p) | |||
4848 | 4848 | ||
4849 | s = zbc_lex_next(&p->l); | 4849 | s = zbc_lex_next(&p->l); |
4850 | if (s) RETURN_STATUS(s); | 4850 | if (s) RETURN_STATUS(s); |
4851 | if (p->l.t.t != BC_LEX_NAME) RETURN_STATUS(bc_error_bad_token()); | 4851 | if (p->l.t.t != XC_LEX_NAME) RETURN_STATUS(bc_error_bad_token()); |
4852 | 4852 | ||
4853 | bc_parse_pushName(p, p->l.t.v.v); | 4853 | bc_parse_pushName(p, p->l.t.v.v); |
4854 | 4854 | ||
@@ -4948,7 +4948,7 @@ static BC_STATUS zdc_parse_token(BcParse *p, BcLexType t) | |||
4948 | dbg_lex("%s:%d LEX_[S]COLON", __func__, __LINE__); | 4948 | dbg_lex("%s:%d LEX_[S]COLON", __func__, __LINE__); |
4949 | s = zdc_parse_mem(p, XC_INST_ARRAY_ELEM, true, t == DC_LEX_COLON); | 4949 | s = zdc_parse_mem(p, XC_INST_ARRAY_ELEM, true, t == DC_LEX_COLON); |
4950 | break; | 4950 | break; |
4951 | case BC_LEX_STR: | 4951 | case XC_LEX_STR: |
4952 | dbg_lex("%s:%d LEX_STR", __func__, __LINE__); | 4952 | dbg_lex("%s:%d LEX_STR", __func__, __LINE__); |
4953 | dc_parse_string(p); | 4953 | dc_parse_string(p); |
4954 | break; | 4954 | break; |
@@ -4956,12 +4956,12 @@ static BC_STATUS zdc_parse_token(BcParse *p, BcLexType t) | |||
4956 | dbg_lex("%s:%d LEX_NEG", __func__, __LINE__); | 4956 | dbg_lex("%s:%d LEX_NEG", __func__, __LINE__); |
4957 | s = zbc_lex_next(&p->l); | 4957 | s = zbc_lex_next(&p->l); |
4958 | if (s) RETURN_STATUS(s); | 4958 | if (s) RETURN_STATUS(s); |
4959 | if (p->l.t.t != BC_LEX_NUMBER) | 4959 | if (p->l.t.t != XC_LEX_NUMBER) |
4960 | RETURN_STATUS(bc_error_bad_token()); | 4960 | RETURN_STATUS(bc_error_bad_token()); |
4961 | bc_parse_pushNUM(p); | 4961 | bc_parse_pushNUM(p); |
4962 | bc_parse_push(p, XC_INST_NEG); | 4962 | bc_parse_push(p, XC_INST_NEG); |
4963 | break; | 4963 | break; |
4964 | case BC_LEX_NUMBER: | 4964 | case XC_LEX_NUMBER: |
4965 | dbg_lex("%s:%d LEX_NUMBER", __func__, __LINE__); | 4965 | dbg_lex("%s:%d LEX_NUMBER", __func__, __LINE__); |
4966 | bc_parse_pushNUM(p); | 4966 | bc_parse_pushNUM(p); |
4967 | break; | 4967 | break; |
@@ -5252,7 +5252,7 @@ static BC_STATUS zbc_program_read(void) | |||
5252 | } | 5252 | } |
5253 | if (s) goto exec_err; | 5253 | if (s) goto exec_err; |
5254 | 5254 | ||
5255 | if (parse.l.t.t != BC_LEX_NLINE && parse.l.t.t != XC_LEX_EOF) { | 5255 | if (parse.l.t.t != XC_LEX_NLINE && parse.l.t.t != XC_LEX_EOF) { |
5256 | s = bc_error("bad read() expression"); | 5256 | s = bc_error("bad read() expression"); |
5257 | goto exec_err; | 5257 | goto exec_err; |
5258 | } | 5258 | } |
@@ -6733,7 +6733,7 @@ static BC_STATUS zbc_vm_process(const char *text) | |||
6733 | } else { | 6733 | } else { |
6734 | // Most of dc parsing assumes all whitespace, | 6734 | // Most of dc parsing assumes all whitespace, |
6735 | // including '\n', is eaten. | 6735 | // including '\n', is eaten. |
6736 | while (G.prs.l.t.t == BC_LEX_NLINE) { | 6736 | while (G.prs.l.t.t == XC_LEX_NLINE) { |
6737 | s = zbc_lex_next(&G.prs.l); | 6737 | s = zbc_lex_next(&G.prs.l); |
6738 | if (s) goto err; | 6738 | if (s) goto err; |
6739 | if (G.prs.l.t.t == XC_LEX_EOF) | 6739 | if (G.prs.l.t.t == XC_LEX_EOF) |