Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe this has been answered here: <a href="https://stackoverflow.com/questions/4161553/can-the-shunting-yard-algorithm-parse-posix-regular-expressions/4161681#4161681">Can the shunting yard algorithm parse POSIX regular expressions?</a></p> <blockquote> <p>I will say that the answer to your question is "no, you cannot implement the shunting yard algorithm using a regular expression." This is for the same reason you cannot parse arbitrary HTML using regular expressions. Which boils down to this:</p> <p>Regular expressions do not have a stack. Because the shunting yard algorithm relies on a stack (to push and pop operands as you convert from infix to RPN), then regular expressions do not have the computational "power" to perform this task.</p> <p>This glosses over many details, but a "regular expression" is one way to define a regular language. When you "use" a regular expression, you are asking the computer to say: "Look at a body of text and tell me whether or not any of those strings are in my language. The language that I defined using a regular expression." I'll point to <a href="https://stackoverflow.com/questions/1085404/what-is-regular-expression/1085469#1085469">this most excellent answer which you and everyone reading this should upvote</a> for more on regular languages.</p> <p>So now you need some mathematical concept to augment "regular languages" in order to create more powerful languages. If you were to characterize the shunting yard algorithm as an realization of a model of computational power, then you might say that the algorithm would be described as a <a href="http://en.wikipedia.org/wiki/Context_free_grammar" rel="nofollow noreferrer">context-free grammar</a> (hey what do you know, that link uses an expression parse tree as an example.) A <a href="http://en.wikipedia.org/wiki/Deterministic_pushdown_automaton" rel="nofollow noreferrer">push-down automata</a>. Something with a stack.</p> <p>If you are less-than-familiar with automata theory and complexity classes, then those wikipedia articles are probably not that helpful without explaining them from the ground up.</p> <p>The point being, you may be able to use regex to help writing shunting yard. But regex are not very good at doing operations that have an arbitrary depth, which this problem has. So I would not spend too much time going down the regex avenue for this problem.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload