Top-down parsing language: Difference between revisions

Content deleted Content added
Rescuing 1 sources and tagging 0 as dead. #IABot (v2.0beta)
Tags: Mobile edit Mobile app edit Android app edit
Line 22:
Note that a nonterminal-function may succeed without actually consuming any input, and this is considered an outcome distinct from failure.
 
A nonterminal ''A'' defined by a rule of the form ''A'' ← ε always succeeds without consuming any input, regardless of the input string proved. Conversely, a rule of the form ''A'' ← ''f'' always fails regardless of input. A rule of the form ''A'' ← ''a'' succeeds if the next character in the input string is the terminal ''a'', in which case the nonterminal succeeds and consumes that one terminal; if the next input character does not match (or there is no next character), then the nonterminal fails.
 
A nonterminal ''A'' defined by a rule of the form ''A'' ← ''BC/D'' first [[recursion|recursively]] invokes nonterminal ''B'', and if ''B'' succeeds, invokes ''C'' on the remainder of the 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'' [[backtracking|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.