in reply to Backtracking in Parse::RecDescent
The behavior is quite okay.
The point is that ( "aa" | "a" ) and "a" represents two tokens, separated by whitespace. Hence 'aa a' is valid input, as well as 'a a', but 'aa' is not since it's a single token and the grammar specifies two.
Hope this clears the confusion, -gjb-
Update/clarification: The assumption that " The reason is that the first branch of the alternation matched, then the next subrule failed." is simply wrong. The string 'aa' is not valid because it simply not part of the language described by the grammar. That language consists of two strings: 'aa a' and 'a a'. The grammar ( "aa" | "a" ) "a" specifies that an 'aa' should be followed by a 'a' token separated by whitespace or that an 'a' should be followed by an 'a' token separated by whitespace. The example you give 'aa' has no whitespace, hence only one token while your grammar requires two.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Backtracking in Parse::RecDescent
by ruscoekm (Monk) on Dec 06, 2002 at 13:33 UTC |