Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[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 <> wrote:
> 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 > I > 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 understand.
> 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 > alternative > 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. Robert