|
From: | Evan Lavelle |
Subject: | Re: Match at least one? |
Date: | Tue, 05 Apr 2011 11:06:01 +0100 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 |
message : M1 M2 M3 | M1 M3 M2 | M2 M1 M3 | M2 M3 M1 | M3 M1 M2 | M3 M2 M1 ;However, you've got a problem in that you need 'at least one' of the mandatory blocks, and the repeats can presumably come in any order. Explicitly listing all expected variants can be useful in simple cases, but not in this case.
So, you're right, you need to do some post-processing. This is easy - just push the type of the block you've just parsed onto a list whenever you see a block, and then process the list when you've seen your terminator. This is the "right" way to do it - keep the parser for parsing, and do any semantic analysis afterwards.
-Evan
[Prev in Thread] | Current Thread | [Next in Thread] |