[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Re: 3-byte char. and left-parsing



** Reply to note from "Carl L. Distefano"  Fri, 7 Mar 1997 12:31:44 EST

Carl:

I wrestled with a similar problem during development of Stack when
Searching Backwards, i.e. starting at the bottom of the Stack rather than
the top (oldest rather than most recent command). As you demonstrate, it
is easy enough to start parsing on the right end of a string if the string
is relatively short. But serious problems arise when the string exceeds 80
characters -- approaches, say, 3K or 10K in length -- and economy
necessitates the use of Wild-W rather than Wild-X. Wild-W has a
"left-leaning tendency" which I could never defeat.

For example: Suppose that I append the number "9" to a source string like
"William", thus forming "William9". My goal is to isolate everything in
the string preceding the last occurrence of the letter "i" in the name
"William". I use an input separator like "i{Wild-W}9" in an XS parse
. My *hope* might be that by this strategy, I would
obtain the left-side result (Save/Get 03) "Will", and the output separator
(S/G 04) "iam9" (S/G 05 will of course be empty). In fact, what happens is
that this command (like all XyWrite commands) is parsed from left to right,
even though our thinking is right to left and thus leads us to hope for a
right-weighted result. First, the leading "i" is located. Then Wild-W
tries to seize 80 characters to the right of "i", or, if 80 chars aren't
found, then the maximum number of characters available. Then "9" is sought
within the string claimed by Wild-W, starting on the left. Accordingly,
the left-side result (Save/Get 03) is "W", and the output separator
(S/G 04) is "illiam9". An incontrovertible demonstration of this behavior
is to use two different input separators: "i{Wild-W}9" and
"i{Wild-W}i{Wild-W}9". They both yield the identical result, "W" and
"illiam9". Bummer.

+"9">
+"-"+>


In Stack, the solution was to maintain in memory, at all times, a string of
Wild-Ws interspersed between unique separator characters (functioning like
"9", above) equal to the number of commands in the Stack, minus 1. That
eliminated having to build up a fresh string of Wild-Ws each time you want
to peel something off the end. It works, too -- not as fast as peeling off
the beginning of the Stack, but pretty darn fast...

My point is that the procedure you outlined the other day would, I'm sure,
be ubiquitous if not for grave limitations. What we need is a native
RightString function and a reliable Wild-X (per Xy3+ v3.54 and earlier), as
opposed to this cosmetic nonsense where Wild-X can represent 1, 2, or 3
bytes, so long as it "looks like" one character. Dum-de-dum-dum, DUMB!


-----------
Robert Holmgren
holmgren@xxxxxxxx
-----------