[REBOL] Re: Questions about block parsing
From: robert::muench::robertmuench::de at: 21-Sep-2007 11:13
On Fri, 21 Sep 2007 09:18:39 +0200, Rudolf W. MEIJER
> I noticed from the output that the way block parsing works is that all
> alternatives are tried until the first one is found that succeeds,
Hi, no, that's not true. The alternatives are checked top-down, hence I
used the term "maximum match rules first" because the chances that a
generic rule is true is much hier than a more specific one.
> How then can we know during the visit of an alternative that this
> will end up being successful? It looks like we need a stack of our own
> to keep track. Any experiences? I have seen posts on string parsing, but
> think this is still different.
If you reach the end of a rule the rule is successful. You can't decide up
front and you don't need to. PARSE works a bit different than normal
parser generators. But it's extremly powerful and not that hard to
> Furthermore, in order to add some semantic analysis to the parsing, I
> would like to be able to tell the parse function that a certain
> should NOT succeed. Is there any way of communicating TO the parser
> while it
> goes on?
This looks to me that you should try to seprate these. Remember, it's
sometimes much simpler to use 2 or 3 PARSE in sequence. So, first parse on
a high level, than take the result and parse it again with some more
specific rules etc. This is sometimes simpler than writing one big rule.