Editing Shunting yard algorithm
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 56: | Line 56: | ||
The use of a syntax tree representation relieves us of the responsibility of finding some way to tag unary minus signs and variadic functions in the output (although we must still identify unary minus signs before pushing them onto the operator stack); the correct number of operands of an operator is simply the number of children the operator's node has in the final syntax tree. A variation of the algorithm, in which function arguments are directly added as children to the function token still waiting on the operator stack as soon as they are finished construction, also eliminates the need for the arity stack; details are left as an exercise for the reader. | The use of a syntax tree representation relieves us of the responsibility of finding some way to tag unary minus signs and variadic functions in the output (although we must still identify unary minus signs before pushing them onto the operator stack); the correct number of operands of an operator is simply the number of children the operator's node has in the final syntax tree. A variation of the algorithm, in which function arguments are directly added as children to the function token still waiting on the operator stack as soon as they are finished construction, also eliminates the need for the arity stack; details are left as an exercise for the reader. | ||
− | |||
− | |||
− | |||
==References== | ==References== | ||
# Dijkstra, E. W. (1961). ''ALGOL-60 Translation''. Retrieved from http://www.cs.utexas.edu/~EWD/MCReps/MR35.PDF | # Dijkstra, E. W. (1961). ''ALGOL-60 Translation''. Retrieved from http://www.cs.utexas.edu/~EWD/MCReps/MR35.PDF | ||
# [http://en.wikipedia.org/w/index.php?title=Shunting-yard_algorithm&oldid=477381628 Wikipedia] | # [http://en.wikipedia.org/w/index.php?title=Shunting-yard_algorithm&oldid=477381628 Wikipedia] |