[REBOL] Re: parse consumption
From: lmecir:mbox:vol:cz at: 10-Sep-2002 18:06
Hi Anton,
this is an old parse "glitch". The difference between your rules is, that
the second one didn't cause the internal pointer to "get past the end" of
the input and therefore it didn't fail.
Current parse behaviour:
1) If a rule causes the internal pointer to "get past the end" of the input,
PARSE considers it a failure. This means, that even a PAREN! rule can fail,
if it removes a part of input.
2) to yield TRUE PARSE must
2a) "get successfully" through the whole rule
2b) get to the end position of the input
My favourite behaviour looks different:
1) "past end" position doesn't mean a failure
2) to yield TRUE PARSE has to "get successfully" through the whole rule
If you want PARSE to behave like I proposed above, you can use the following
workaround:
parse "abc" [start: "abc" opt (remove/part start 3) :start to end] ; ==
true
HTH
-L