Lines Matching refs:te
2625 Test_env te;
2630 te.flags = 0;
2631 te.isa = ptest_isa;
2632 te.getopnd = ptest_getopnd;
2633 te.eval = test_eval;
2634 te.error = ptest_error;
2646 te.pos.wp = wp + 1;
2647 te.wp_end = wp + argc;
2653 * It does, though, inline some calls to '(*te.funcname)()'.
2664 if (ptest_isa(&te, TM_NOT)) {
2668 if ((op = ptest_isa(&te, TM_UNOP))) {
2670 rv = test_eval(&te, op, *te.pos.wp++, NULL, true);
2672 if (te.flags & TEF_ERROR)
2680 swp = te.pos.wp;
2682 lhs = *te.pos.wp++;
2683 if ((op = ptest_isa(&te, TM_BINOP))) {
2685 rv = test_eval(&te, op, lhs, *te.pos.wp++, true);
2688 if (ptest_isa(&te, tm = TM_AND) || ptest_isa(&te, tm = TM_OR)) {
2690 argc = test_eval(&te, TO_STNZE, lhs, NULL, true);
2691 rv = test_eval(&te, TO_STNZE, *te.pos.wp++, NULL, true);
2699 te.pos.wp = swp;
2700 if (ptest_isa(&te, TM_NOT)) {
2704 if (ptest_isa(&te, TM_OPAREN)) {
2705 swp = te.pos.wp;
2707 te.pos.wp++;
2709 op = ptest_isa(&te, TM_CPAREN);
2711 te.pos.wp = swp;
2720 if (ptest_isa(&te, TM_NOT)) {
2724 if (ptest_isa(&te, TM_OPAREN)) {
2725 swp = te.pos.wp;
2727 te.pos.wp++;
2728 te.pos.wp++;
2730 op = ptest_isa(&te, TM_CPAREN);
2732 te.pos.wp = swp;
2743 te.pos.wp = wp + 1;
2744 return (test_parse(&te));
2799 test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2,
2829 te->flags |= TEF_ERROR;
2969 te->flags |= TEF_ERROR;
2991 if (te->flags & TEF_DBRACKET) {
3000 if (te->flags & TEF_DBRACKET) {
3062 te->flags |= TEF_ERROR;
3084 (*te->error)(te, 0, "internal error: unknown op");
3089 test_parse(Test_env *te)
3093 rv = test_oexpr(te, 1);
3095 if (!(te->flags & TEF_ERROR) && !(*te->isa)(te, TM_END))
3096 (*te->error)(te, 0, "unexpected operator/operand");
3098 return ((te->flags & TEF_ERROR) ? T_ERR_EXIT : !rv);
3102 test_oexpr(Test_env *te, bool do_eval)
3106 if ((rv = test_aexpr(te, do_eval)))
3108 if (!(te->flags & TEF_ERROR) && (*te->isa)(te, TM_OR))
3109 return (test_oexpr(te, do_eval) || rv);
3114 test_aexpr(Test_env *te, bool do_eval)
3118 if (!(rv = test_nexpr(te, do_eval)))
3120 if (!(te->flags & TEF_ERROR) && (*te->isa)(te, TM_AND))
3121 return (test_aexpr(te, do_eval) && rv);
3126 test_nexpr(Test_env *te, bool do_eval)
3128 if (!(te->flags & TEF_ERROR) && (*te->isa)(te, TM_NOT))
3129 return (!test_nexpr(te, do_eval));
3130 return (test_primary(te, do_eval));
3134 test_primary(Test_env *te, bool do_eval)
3140 if (te->flags & TEF_ERROR)
3142 if ((*te->isa)(te, TM_OPAREN)) {
3143 rv = test_oexpr(te, do_eval);
3144 if (te->flags & TEF_ERROR)
3146 if (!(*te->isa)(te, TM_CPAREN)) {
3147 (*te->error)(te, 0, "missing )");
3156 if ((te->flags & TEF_DBRACKET) || (&te->pos.wp[1] < te->wp_end &&
3157 !test_isop(TM_BINOP, te->pos.wp[1]))) {
3158 if ((op = (*te->isa)(te, TM_UNOP))) {
3160 opnd1 = (*te->getopnd)(te, op, do_eval);
3162 (*te->error)(te, -1, Tno_args);
3166 return ((*te->eval)(te, op, opnd1, NULL, do_eval));
3169 opnd1 = (*te->getopnd)(te, TO_NONOP, do_eval);
3171 (*te->error)(te, 0, "expression expected");
3174 if ((op = (*te->isa)(te, TM_BINOP))) {
3176 opnd2 = (*te->getopnd)(te, op, do_eval);
3178 (*te->error)(te, -1, "missing second argument");
3182 return ((*te->eval)(te, op, opnd1, opnd2, do_eval));
3184 return ((*te->eval)(te, TO_STNZE, opnd1, NULL, do_eval));
3197 ptest_isa(Test_env *te, Test_meta meta)
3205 if (te->pos.wp >= te->wp_end)
3209 rv = test_isop(meta, *te->pos.wp);
3213 rv = !strcmp(*te->pos.wp, tokens[(int)meta]) ?
3218 te->pos.wp++;
3224 ptest_getopnd(Test_env *te, Test_op op, bool do_eval MKSH_A_UNUSED)
3226 if (te->pos.wp >= te->wp_end)
3228 return (*te->pos.wp++);
3232 ptest_error(Test_env *te, int ofs, const char *msg)
3236 te->flags |= TEF_ERROR;
3237 if ((op = te->pos.wp + ofs >= te->wp_end ? NULL : te->pos.wp[ofs]))