[Solved] C, Mathematic string calculation? [closed]


you need a scanner and parser. The scanner splits the input string into tokens. The parser takes those tokens and does the semantic checks and the calculation. The calculation can be done f.e. recursevly.

34-8*(3+1)-1 will become something like [i]34[op]-[i]8[op]*[bo][i]3[op]+[i]1[bc][op]-[i]1

that leads to

   subtract(34, [i]8[op]*[bo][i]3[op]+[i]1[bc][op]-[i]1)
=> subtract(34, multiply(8, [bo][i]3[op]+[i]1[bc][op]-[i]1))
=> a.s.o.

3

solved C, Mathematic string calculation? [closed]