I implement a shunt yard algorithm . I'm having trouble finding when there are no arguments to the operators. Wikipedia entries are very bad in this thread, and their code will also fail for the example below.
For example, it is 3 - (5 + )incorrect because there is +no argument.
3 - (5 + )
+
Before the algorithm reaches ), the operator stack contains - ( +, and the operand stack contains 3 5. Then it looks like this:
)
- ( +
3 5
8
(
So how can I find that an +argument is missing? super reach if you also update wikipedia :-)
For binary operators only expressions, the postfix expression has an invariant that in any expression prefix, operand numbers> number of operators and, in the end, this difference is exactly the same.
, RPN , - . , .
, , , , .
(: , , )
. , - .
, . , , .
, / .
postfix .
, , .
ifs .:)
Source: https://habr.com/ru/post/1755555/More articles:How to save an image using UIImageWriteToSavedPhotosAlbum after converting it - iphoneIPhone Cost vs. Benefit - OpenGL ES 1.x vs. 2.0 - performanceLINQ Select a specific cell in the DataGridView depending on another cell in the row - c #How to get rgb cimg value? - c ++Automatic code upgrade to Java 5 - javaDisplay markers in the Eclipse file comparison view - eclipsewhich Java reporting tool for use in 2010 for small / medium web applications - javaCompiling C ++ Template Specialization - c ++SQLite database in android - androidHow does a Struts2 action compare to a servlet? - servletsAll Articles