int main() { // functions: A() B(a) C(a, b), D(a, b, c) ... // identifiers: 0 1 2 3 ... and a b c d e ... // operators: = - + / * % ! const char *input = "a = D(f - b * c + d, !e, g)"; char output[128]; printf("input: %s\n", input); if(shunting_yard(input, output)) { printf("output: %s\n", output); if(!execution_order(output)) printf("\nInvalid input\n"); } return 0; }
bool calc(const TCHAR *input, double *outval) { TCHAR output[IOBUFFERS], output2[IOBUFFERS]; calc_log ((_T("IN: '%s'\n"), input)); if (parse_values(input, output2)) { if(shunting_yard(output2, output)) { calc_log ((_T("RPN OUT: %s\n"), output)); if(!execution_order(output, outval)) { calc_log ((_T("PARSE ERROR!\n"))); } else { return true; } } } return false; }