Maybe the most logical would be to produce
<varlistentry>
<term>a</term>
<term><indexterm role="cp"><primary>index</primary></indexterm>b</term>
<listitem>Text.</listitem>
</varlistentry>
This would avoid having to have to look forward when processing @item a.
And if there is no @itemx, then the index entry would be in the
listitem.
Works for me. Thanks.
