25 May 2012 17:40

## Recursive rule with warning

Hi list,

I have a rule that produces a warning, which I would like to get rid of. However, it seems I can't get further without some help, so I would much appreciate any hint to solve this. The actual grammar is of course more complex but I condensed the problem to this:

a: b (d1 (e)? | d2 a e)*;
b: 'b';
d1: 'd1';
d2: 'd2';
e: 'e';

The problem is the recursion of rule a which may end in rule e, but via two alternatives (obviously). I was thinking about extracting the (e)? part  somehow like this:

a: b ((d1 | d2 a e) (e)?)*

but this doesn't feel right. Any better idea?

```<div>Hi list,<div><br></div>
<div>I have a rule that produces a warning, which I would like to get rid of. However, it seems I can't get further without some help, so I would much appreciate any hint to solve this. The actual grammar is of course more complex but I condensed the problem to this:</div>
<div><br></div>
<div>
<div>a: b (d1 (e)? | d2 a e)*;</div>
<div>b: 'b';</div>
<div>d1: 'd1';</div>
<div>d2: 'd2';</div>
<div>e: 'e';</div>
<div><br></div>
<div>The problem is the recursion of rule a which may end in rule e, but via two alternatives (obviously). I was thinking about extracting the (e)? part &nbsp;somehow like this:</div>
<div><br></div>
<div>a: b ((d1 | d2 a e) (e)?)*</div>
<div><br></div>
<div>but this doesn't feel right. Any better idea?</div>
<div><br></div>
<div apple-content-edited="true">
Mike<br>--&nbsp;<br><a href="http://www.soft-gems.net">www.soft-gems.net</a><br>
</div>

<br>
</div>
</div>
```

Gmane