No, thanks for trying anyway!
Perhaps I wasn't too clear.
I understand already the difference between
using 'to and not using 'to. (Or maybe I don't!)
The question is why does the first parse not complete
the input to the end?
Your versions returned false and true like mine.
Here is my annotated version:
parse "abc" [
start: ; mark start of string
"abc" ; eat 3 characters, so now at index 3
(remove/part start 3) ; remove all the characters
; so now at index ???
:start ; set current index to the start
end ; expect to be at the end
]
;== false ; what??!
The reason I am asking this particular question is
because I don't want to use 'to. 'to has two
different actions, that I don't necessarily want
to use together:
1 - move through any characters (until...)
2 - I am at a position in the string which starts with
the following...
I only want the second action of 'to, if you know what I
mean. Like "I expect the following string to be here, at
the current index position (and I don't want to walk through it.)"
If there were such a word, like, in my imagination, 'here:
parse "abc" [start: here "abc" (remove/part start 3)]
should return true, and I could use that to make the
above parse rule complete. But that still leaves me with
the question, why doesn't it get to the end as it is?
Anton.
> From: "Anton"
> > I have here a bit of confusion:
> >
> > parse "abc" [start: "abc" (remove/part start 3) :start end]
> > ;== false
> >
> > parse "abc" [start: to "abc" (remove/part start 3) :start end]
> > ;== true
> >
> > The first parse "consumes" the "abc" before removal,
> > and the second one doesn't.
> >
> > Why does it matter whether "abc" is consumed or not?
> >
> > I am setting the input position to the start of the
> > string afterwards with :start.
> > I have verified that before the removal, start is at
> > the beginning of the string.
> >
> > Also, this is the same both in latest beta
> > and last full release.
>
> Hi, Anton,
>
> You may feel confused, but you actually are not!
> :-)
> Let me re-word what you have said, using slightly more information, and I
> hope this reframes the issue in words that then make sense.
>
> parse "abcd" [
> start: "abc"
> check: (
> print [start/1 check/1 ] ;yields a and d
> remove/part start 3
> print start/1 ; yields d
> ) :start
> to end
> ]
>
> My analysis: *without* the 'to, then the parser matches through
> the pattern,
> demonstrated by the check. So start still points to the initial start of
> the string, but the parser has already moved through it. So it seems
> "consumed."
>
> parse "abcd" [
> start: to "abc"
> check: (
> print [start/1 check/1] ;yields a and a
> remove/part start 3
> print start/1 ;yields d
> ) :start
> to end
> ]
>
> My analysis: 'to only matches "to" the pattern, as demonstrated by check.
> Parse still hasn't "moved through" the pattern, so it doesn't seem
> "consumed."
>
> Did that help?
> --Scott Jones
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.