If there are only 3 mandatory blocks then, in principle, you can look for all possible combinations in the input:

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

_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to