D
D
Daniil Demidko2015-12-20 10:58:02
C++ / C#
Daniil Demidko, 2015-12-20 10:58:02

How to parse a string without reverse polish notation?

I am writing a calculator for expressions like this:
4+2*2-3*(4-5*9)-6
I managed to cope with the translation of string into double and vice versa (drinking a couple of my bikes instead of itoa and atof), but with parsing the expression there were problems.
I don't want to use reverse Polish notation, it's too dry and trivial.
I tried to use various perversions with recursion, but there are errors.
Is there any way to parse the string without using the OPN ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Makaleks, 2015-12-23
@Daniro_San

I don’t know a fundamentally different way, but if you really need it, you can suffer with recursion. There will be errors, difficulties in adding new operators, and so on.
At the dawn of self-study, he sawed such a thing. That horror... If you want to peep - catch .h , but it's actually C and I didn't know anything at all. Although it supports arguments (through Latin letters), sin and cos functions, as well as brackets and modules. No spaces, no tabs.
I hope, having seen this horror, you will understand that it is better to parse reverse Polish.
It's better to take it apart, really.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question