Editing Shunting yard algorithm

Jump to: navigation, search

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.
 
==Code==
 
* [[Shunting yard algorithm/foo.hs|Haskell reference implementation for this article]]
 
  
 
==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]

Please note that all contributions to PEGWiki are considered to be released under the Attribution 3.0 Unported (see PEGWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)