PARSE: the problem with EITHER
EITHER is problematic as an inline parse command.
The reason is that it requires three rules as arguments, but does not delimit them. Therefore, the rules must be singular. No modifications are allowed, unless you put them in blocks.
However, the concept of EITHER seems quite fundamental to me, almost like OR (the "|"). I'd prefer that we find the more basic pattern that is lurking here and come up with a general solution for it.
For example, consider this expression:
[a + b | c | d]
where we give '+ the meaning: advance past next alternate rule on failure. (This is similar in implementation to the new NOT command; they introduce a pending state forward.) That is the equivalent of EITHER (or you can think of it as a BRANCH notation of sorts.)
The benefit is: all rules are now delimited. You can write:
[a + b | c | d]
[a + 2 b | c | d]
[a + not b | some c | d]
or whatever. This cannot be done with EITHER unless you use separate blocks.
Of course, the '+ symbol isn't essential; it could be a different word... but I liked the elegance of it.
I think a solution like this is more basic and powerful... more fitting of how PARSE rules work.
Also...
In theory, the above solution could potentially support:
[a 2 + b | c | d | e]
Which means: advance past the next 2 alternate rules on failure.
But, let's wait on that until we see if the general concept flies.
46 Comments
|