multi-part names in single token



I have some productions that have to deal with names that can be 'bar'
or 'foo.bar'

ASTProgramUnit programUnit() #ProgramUnit : {}
{
(
(<FUNCTION> | <PROCEDURE>) programUnitName()
...
)
{ return jjtThis; }
}


ASTProgramUnitName programUnitName() #ProgramUnitName : {}
{
(LOOKAHEAD(2) ID()".")? ID()
{ return jjtThis; }
}

How do I get a single token whose image is either 'bar' or 'foo.bar'?

When I walk my tree, ASTProgramUnitName's _first , _next and _last
tokens
are 'foo', '.', and 'bar'.

Thanks in advance,

Mike Norman

.