input string left unconsumed by B. If both B and C succeed, then A in turn succeeds and consumes the same total number of input characters that B and C together did. If either B or C fails, however, then A backtracks to the original point in the input string where it was first invoked, and then invokes D on that original input string, returning whatever result D produces. Examples The following TDPL grammar describes the regular language consisting of an arbitrary-length sequence of a's and b's: S ← AS/T T ← BS/E A ← a B ← b E ← ε The following grammar describes the context-free language parentheses language consisting of arbitrary-length strings of matched braces, such as '{}', '{{}{{}}}', etc.: S ← OT/E T ← SU/F U ← CS/F O ← { C ← } E ← ε F ← f The above examples can be represented equivalently but much more succinctly in parsing expression grammar notation as and , respectively. Generalized TDPL A slight variation of TDPL, known as Generalized TDPL or GTDPL, greatly increases the apparent expressiveness of TDPL while retaining the same minimalist approach (though they are actually equivalent). In GTDPL, in place of TDPL's recursive rule form A ← BC/D, we instead use the alternate rule form A ← B[C,D], which is interpreted as follows. When nonterminal A is invoked on some input string, it first recursively invokes B. If B succeeds, then A subsequently invokes C on the remainder of the input left unconsumed by B, and returns the result of C to the original caller. If B fails, on the other hand, then A invokes D on the original input string, and passes the result back to the caller. The important difference between this rule form and the A ← BC/D rule form used in TDPL is that C and D are never both invoked in the same call to A: that is, the GTDPL rule acts more like a "pure" if/then/else construct using B as the condition. In GTDPL it is straightforward to express interesting non-context-free languages such as the classic example {anbncn}. A GTDPL grammar can be reduced to an equivalent TDPL grammar that recognizes the same language, although the process is not straightforward and may greatly increase the number of rules required. Also, both TDPL and GTDPL can be viewed as very restricted forms of parsing expression grammars,