IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 17, 2005, 12:53:55 PM (21 years ago)
Author:
eugene
Message:

fixed up precedence

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c

    r4305 r4306  
    11# include "opihi.h"
    22# define VERBOSE 0
     3
     4# define TWO_OP(A,B,FUNC) \
     5  if (!strncasecmp (&stack[i - 2].type, A, 1) && !strncasecmp (&stack[i - 1].type, B, 1)) \
     6    status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
     7
     8# define ONE_OP(A,FUNC) \
     9  if (!strncasecmp (&stack[i - 1].type, A, 1)) \
     10    status = FUNC (&tmp_stack, &stack[i - 1], stack[i].name);
    311
    412int evaluate_stack (StackVar *stack, int *Nstack) {
     
    4856
    4957    /***** binary operators *****/
    50     if ((stack[i].type == 3) || (stack[i].type == 4) || (stack[i].type == 5) || (stack[i].type == 6)) {
     58    if ((stack[i].type >= 3) && (stack[i].type <= 8)) {
    5159
    5260      if (i < 2) {  /* need two variables to operate on */
     
    5664        return (FALSE);
    5765      }
    58 
    59       /* this could be macro generated... */
    60       # define TWO_OP(A,B,FUNC) \
    61       if (!strncasecmp (&stack[i - 2].type, A, 1) && !strncasecmp (&stack[i - 1].type, B, 1)) \
    62         status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name);
    6366
    6467      TWO_OP ("M","M",MM_binary);
     
    9194
    9295    /***** unary operators **/
    93     if (stack[i].type == 7) {
     96    if (stack[i].type == 9) {
    9497
    9598      if (i < 1) {  /* need one variable to operate on */
     
    99102      }
    100103     
    101       if (!strncasecmp (&stack[i - 1].type, "M", 1))
    102         M_unary (&tmp_stack, &stack[i - 1], stack[i].name);
    103       if (!strncasecmp (&stack[i - 1].type, "V", 1))
    104         V_unary (&tmp_stack, &stack[i - 1], stack[i].name);
    105       if (!strncasecmp (&stack[i - 1].type, "S", 1))
    106         S_unary (&tmp_stack, &stack[i - 1], stack[i].name);
     104      ONE_OP ("M", M_unary);
     105      ONE_OP ("V", V_unary);
     106      ONE_OP ("S", S_unary);
    107107
    108108      /* there are no valid unary string operators */
Note: See TracChangeset for help on using the changeset viewer.