It is easy to implement a top-down depth-first recognizer in Prolog --- for this is the strategy Prolog itself uses in its search.