How does Menhir's option() work?

I’m writing an Objective-C parser with Menhir and cannot figure out why the following rule

LPAREN l = separated_list(COMMA, t=IDENT ASTERISK* s=IDENT { (t, s) }) RPAREN
LBLOCK; b = statement* RBLOCK { Block (t, l, b) }


^(NSString *)(ClassA *objA, ClassB *objB) {


and doesn’t match

^(ClassA *objA, ClassB *objB) {


Can you please point out the error in my understanding of option()?

It should work as you wrote it. But it’s kind of hard to understand without a bit more context. When you say doesn’t match, is it that you get a syntax error or is the phrase parsed by some other rule (which would be a conflict that was arbitrarily resolved in favor of that rule ?).
And if you print your tokens as they are lexed, do you see them in the right order ?

Actually scratch that, I tested the rule and indeed there is a conflict, when seing the first LPAREN,
the parser cannot decide which rule should apply (unfold the option, or skip it and start the rest of the rule).

Not tested but it looks like a case where using ioption could help ?

Indeed it works with ioption (for a grammar with just the single rule in the original question).

Yes, in this case inlining solves the problem. Thanks for your prompt help :man_bowing: