This page is located at http://www.cs.bc.edu/~alvarez/Theory/dfparsing.html
Given a CFG G=(V,Sigma,R,S) and a terminal string w stack <-- empty candidates <-- R push (S,candidates) do { pop stack top into (q,candidates) backtracking <-- false do { write q as uAv where A is leftmost variable in q if target string w does not have u as a prefix backtracking <-- true if there are no A-rules in candidates backtracking <-- true if not backtracking { let A-->x be the first A-rule in candidates push (q, candidates-{A-->x}) replace A by x in q, that is, q<--uxv candidates <-- R } } while not backtracking and q not terminal } while (q different from target string w and the stack is not empty) if derived string q equals target string w accept else reject
However, the procedure is guaranteed to terminate for any CFG expressed in what is known as "Greibach normal form", which means that each rule is of one of the following types:
Since any CFG may be transformed into a CFG in Greibach normal form that generates the same language, this isn't really a limitation.
The search order followed by the depth-first procedure is:
S => aA => aaA => aaaA (backtrack) => aabB => aabbB => aabbbB (backtrack) => aabbb (backtrack) => aabb (success!)