Changeset 2792 for trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c
- Timestamp:
- Dec 22, 2004, 1:23:23 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c
r2598 r2792 26 26 return (TRUE); 27 27 } 28 fprintf (stderr, "syntax error!\n");28 push_error ("syntax error!"); 29 29 free (tmp_stack.name); 30 30 return (FALSE); … … 54 54 return (FALSE); 55 55 } 56 57 /* this could be macro generated... */ 58 # define TWO_OP(A,B,FUNC) \ 59 if (!strncasecmp (&stack[i - 2].type, A, 1) && !strncasecmp (&stack[i - 1].type, B, 1)) \ 60 status = FUNC (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); 61 62 TWO_OP ("M","M",MM_binary); 63 TWO_OP ("M","V",MV_binary); 64 TWO_OP ("M","S",MS_binary); 65 TWO_OP ("V","M",VM_binary); 66 TWO_OP ("V","V",VV_binary); 67 TWO_OP ("V","S",VS_binary); 68 TWO_OP ("S","M",SM_binary); 69 TWO_OP ("S","V",SV_binary); 70 TWO_OP ("S","S",SS_binary); 71 TWO_OP ("W","W",WW_binary); 72 73 /* 56 74 if (!strncasecmp (&stack[i - 2].type, "V", 1) && !strncasecmp (&stack[i - 1].type, "V", 1)) 57 75 status = VV_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); … … 72 90 if (!strncasecmp (&stack[i - 2].type, "S", 1) && !strncasecmp (&stack[i - 1].type, "S", 1)) 73 91 status = SS_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); 92 if (!strncasecmp (&stack[i - 2].type, "X", 1) && !strncasecmp (&stack[i - 1].type, "X", 1)) 93 status = XX_binary (&tmp_stack, &stack[i - 2], &stack[i - 1], stack[i].name); 94 */ 95 96 /* string op number is not valid */ 97 if (!strncasecmp (&stack[i - 2].type, "W", 1) && strncasecmp (&stack[i - 1].type, "W", 1)) { 98 free (tmp_stack.name); 99 return (FALSE); 100 } 101 if (strncasecmp (&stack[i - 2].type, "W", 1) && !strncasecmp (&stack[i - 1].type, "W", 1)) { 102 free (tmp_stack.name); 103 return (FALSE); 104 } 105 74 106 if (!status) { 75 107 free (tmp_stack.name); … … 102 134 if (!strncasecmp (&stack[i - 1].type, "S", 1)) 103 135 S_unary (&tmp_stack, &stack[i - 1], stack[i].name); 136 137 /* there are no valid unary string operators */ 138 if (!strncasecmp (&stack[i - 1].type, "W", 1)) { 139 fprintf (stderr, "syntax error\n"); 140 free (tmp_stack.name); 141 return (FALSE); 142 } 104 143 105 144 move_stack (&stack[i-1], &tmp_stack);
Note:
See TracChangeset
for help on using the changeset viewer.
