-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Greedy matching is apparently quite a popularly desired enhancement. It would be good to discuss the possibility of adding this feature to iXML.
For example:
A = ["a"-"z"]+ ; ["0"-"9"]+.
B = (A | B)+.
Some users would value being able to say that A is the longest possible string of alphabetic characters or of digits. Without greedy matching, we get a lot of ambiguity. If we parse "abc123", any of the characters can be an A, any pair of alphabetic chars or digits can be an A, and the two triplets can each be an A. So this is possible:
abc 123but so is this:
ab c 1 2 3and fourteen other possible parses.
Greedy matching would require that the longest possible match is chosen each time. Take this (with "+*" indicating a greedy match, just for convenience):
A = ["a"-"z"]+* ; ["0"-"9"]+*.
B = (A | B)+.
With this grammar, the only possible parse would be:
abc 123