guys in JavaCC when I have a non-terminal inside square brackets, for example:
void NonTerminal: {}
{
[OtherNonTerminal()]
}
void OtherNonTerminal: {}
{
<TOKEN> [<OTHERTOKEN> OtherNonTerminal()]
}
What do the square brackets around it mean?
[OtherNonTerminal()]
is the same as (OtherNonTerminal())?
and means that OtherNonTerminal
is optional. That is, NonTerminal
can either match OtherNonTerminal
or nothing.