Changeset 4305 for trunk/Ohana/src/opihi/lib.shell/convert_to_RPN.c
- Timestamp:
- Jun 17, 2005, 12:20:48 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.shell/convert_to_RPN.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/convert_to_RPN.c
r3414 r4305 23 23 type = 0; 24 24 /* unary operations */ 25 if (!strcmp (argv[i], "abs")) { type = 7; goto gotit; } 26 if (!strcmp (argv[i], "int")) { type = 7; goto gotit; } 27 if (!strcmp (argv[i], "exp")) { type = 7; goto gotit; } 28 if (!strcmp (argv[i], "ten")) { type = 7; goto gotit; } 29 if (!strcmp (argv[i], "log")) { type = 7; goto gotit; } 30 if (!strcmp (argv[i], "ln")) { type = 7; goto gotit; } 31 if (!strcmp (argv[i], "sqrt")) { type = 7; goto gotit; } 25 if (!strcmp (argv[i], "abs")) { type = 7; goto gotit; } 26 if (!strcmp (argv[i], "int")) { type = 7; goto gotit; } 27 if (!strcmp (argv[i], "exp")) { type = 7; goto gotit; } 28 if (!strcmp (argv[i], "ten")) { type = 7; goto gotit; } 29 if (!strcmp (argv[i], "log")) { type = 7; goto gotit; } 30 if (!strcmp (argv[i], "ln")) { type = 7; goto gotit; } 31 if (!strcmp (argv[i], "sqrt")) { type = 7; goto gotit; } 32 if (!strcmp (argv[i], "erf")) { type = 7; goto gotit; } 32 33 33 34 if (!strcmp (argv[i], "sinh")) { type = 7; goto gotit; } … … 36 37 if (!strcmp (argv[i], "acosh")) { type = 7; goto gotit; } 37 38 38 if (!strcmp (argv[i], "sin")) { type = 7; goto gotit; }39 if (!strcmp (argv[i], "cos")) { type = 7; goto gotit; }40 if (!strcmp (argv[i], "tan")) { type = 7; goto gotit; }41 if (!strcmp (argv[i], "dsin")) { type = 7; goto gotit; }42 if (!strcmp (argv[i], "dcos")) { type = 7; goto gotit; }43 if (!strcmp (argv[i], "dtan")) { type = 7; goto gotit; }44 if (!strcmp (argv[i], "asin")) { type = 7; goto gotit; }45 if (!strcmp (argv[i], "acos")) { type = 7; goto gotit; }46 if (!strcmp (argv[i], "atan")) { type = 7; goto gotit; }47 if (!strcmp (argv[i], "dasin")) { type = 7; goto gotit; }48 if (!strcmp (argv[i], "dacos")) { type = 7; goto gotit; }49 if (!strcmp (argv[i], "datan")) { type = 7; goto gotit; }39 if (!strcmp (argv[i], "sin")) { type = 7; goto gotit; } 40 if (!strcmp (argv[i], "cos")) { type = 7; goto gotit; } 41 if (!strcmp (argv[i], "tan")) { type = 7; goto gotit; } 42 if (!strcmp (argv[i], "dsin")) { type = 7; goto gotit; } 43 if (!strcmp (argv[i], "dcos")) { type = 7; goto gotit; } 44 if (!strcmp (argv[i], "dtan")) { type = 7; goto gotit; } 45 if (!strcmp (argv[i], "asin")) { type = 7; goto gotit; } 46 if (!strcmp (argv[i], "acos")) { type = 7; goto gotit; } 47 if (!strcmp (argv[i], "atan")) { type = 7; goto gotit; } 48 if (!strcmp (argv[i], "dasin")) { type = 7; goto gotit; } 49 if (!strcmp (argv[i], "dacos")) { type = 7; goto gotit; } 50 if (!strcmp (argv[i], "datan")) { type = 7; goto gotit; } 50 51 51 52 if (!strcmp (argv[i], "lgamma")) { type = 7; goto gotit; } 52 53 53 if (!strcmp (argv[i], "rnd")) { type = 7; goto gotit; }54 if (!strcmp (argv[i], "xramp")) { type = 7; goto gotit; }55 if (!strcmp (argv[i], "yramp")) { type = 7; goto gotit; }56 if (!strcmp (argv[i], "ramp")) { type = 7; goto gotit; }57 if (!strcmp (argv[i], "zero")) { type = 7; goto gotit; }58 if (!strcmp (argv[i], "--")) { type = 7; goto gotit; }59 if (!strcmp (argv[i], "not")) { type = 7; goto gotit; }60 if (!strcmp (argv[i], "isinf")) { type = 7; goto gotit; }61 if (!strcmp (argv[i], "isnan")) { type = 7; goto gotit; }54 if (!strcmp (argv[i], "rnd")) { type = 7; goto gotit; } 55 if (!strcmp (argv[i], "xramp")) { type = 7; goto gotit; } 56 if (!strcmp (argv[i], "yramp")) { type = 7; goto gotit; } 57 if (!strcmp (argv[i], "ramp")) { type = 7; goto gotit; } 58 if (!strcmp (argv[i], "zero")) { type = 7; goto gotit; } 59 if (!strcmp (argv[i], "--")) { type = 7; goto gotit; } 60 if (!strcmp (argv[i], "not")) { type = 7; goto gotit; } 61 if (!strcmp (argv[i], "isinf")) { type = 7; goto gotit; } 62 if (!strcmp (argv[i], "isnan")) { type = 7; goto gotit; } 62 63 63 64 /* binary operations */ 64 if (!strcmp (argv[i], "^")) { type = 6; goto gotit; } 65 if (!strcmp (argv[i], "@")) { type = 5; goto gotit; } 66 67 if (!strcmp (argv[i], "<")) { type = 5; goto gotit; } 68 if (!strcmp (argv[i], ">")) { type = 5; goto gotit; } 69 if (!strcmp (argv[i], "&&")) { type = 5; strcpy (argv[i], "A"); goto gotit; } 70 if (!strcmp (argv[i], "||")) { type = 5; strcpy (argv[i], "O"); goto gotit; } 71 if (!strcmp (argv[i], "==")) { type = 5; strcpy (argv[i], "E"); goto gotit; } 72 if (!strcmp (argv[i], "!=")) { type = 5; strcpy (argv[i], "N"); goto gotit; } 73 if (!strcmp (argv[i], "<=")) { type = 5; strcpy (argv[i], "L"); goto gotit; } 74 if (!strcmp (argv[i], ">=")) { type = 5; strcpy (argv[i], "G"); goto gotit; } 75 if (!strcmp (argv[i], ">>")) { type = 5; strcpy (argv[i], "U"); goto gotit; } 76 if (!strcmp (argv[i], "<<")) { type = 5; strcpy (argv[i], "D"); goto gotit; } 77 78 if (!strcmp (argv[i], "&")) { type = 5; goto gotit; } 79 if (!strcmp (argv[i], "|")) { type = 5; goto gotit; } 80 81 if (!strcmp (argv[i], "/")) { type = 4; goto gotit; } 82 if (!strcmp (argv[i], "*")) { type = 4; goto gotit; } 83 84 if (!strcmp (argv[i], "+")) { type = 3; goto gotit; } 85 if (!strcmp (argv[i], "-")) { type = 3; goto gotit; } 65 if (!strcmp (argv[i], "^")) { type = 6; goto gotit; } 66 67 if (!strcmp (argv[i], "@")) { type = 5; goto gotit; } 68 if (!strcmp (argv[i], "/")) { type = 5; goto gotit; } 69 if (!strcmp (argv[i], "*")) { type = 5; goto gotit; } 70 71 if (!strcmp (argv[i], "+")) { type = 4; goto gotit; } 72 if (!strcmp (argv[i], "-")) { type = 4; goto gotit; } 86 73 87 if (!strcmp (argv[i], "(")) { type = 2; goto gotit; } 88 if (!strcmp (argv[i], ")")) { type = 1; goto gotit; } 74 if (!strcmp (argv[i], "<")) { type = 3; goto gotit; } 75 if (!strcmp (argv[i], ">")) { type = 3; goto gotit; } 76 if (!strcmp (argv[i], "&&")) { type = 3; strcpy (argv[i], "A"); goto gotit; } 77 if (!strcmp (argv[i], "||")) { type = 3; strcpy (argv[i], "O"); goto gotit; } 78 if (!strcmp (argv[i], "==")) { type = 3; strcpy (argv[i], "E"); goto gotit; } 79 if (!strcmp (argv[i], "!=")) { type = 3; strcpy (argv[i], "N"); goto gotit; } 80 if (!strcmp (argv[i], "<=")) { type = 3; strcpy (argv[i], "L"); goto gotit; } 81 if (!strcmp (argv[i], ">=")) { type = 3; strcpy (argv[i], "G"); goto gotit; } 82 if (!strcmp (argv[i], ">>")) { type = 3; strcpy (argv[i], "U"); goto gotit; } 83 if (!strcmp (argv[i], "<<")) { type = 3; strcpy (argv[i], "D"); goto gotit; } 84 if (!strcmp (argv[i], "&")) { type = 3; goto gotit; } 85 if (!strcmp (argv[i], "|")) { type = 3; goto gotit; } 86 87 if (!strcmp (argv[i], "(")) { type = 2; goto gotit; } 88 if (!strcmp (argv[i], ")")) { type = 1; goto gotit; } 89 89 90 90 gotit: 91 91 /* choose how to deal with object */ 92 92 switch (type) { 93 case 6: /* unary OPs*/93 case 6: /* exponentiation */ 94 94 /* pop previous, higher operators from OP stack to stack */ 95 95 for (j = Nop_stack - 1; (j >= 0) && (op_stack[j].type > type); j--) { … … 104 104 Nop_stack ++; 105 105 break; 106 case 7: /* binary OPs */106 case 7: /* unary OPs */ 107 107 case 5: /* binary OPs */ 108 108 case 4:
Note:
See TracChangeset
for help on using the changeset viewer.
