See question 3.3 of the JavaCC FAQ. http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-moz.htm#tth_sEc3.3
There are three golden rules for picking which regular expression to use to identify the next token:
- The regular expression must describe a prefix of the remaining input stream.
- If more than one regular expression describes a prefix, then a regular expression that describes the longest prefix of the input stream is used. (This is called the "maximal munch rule".)
- If more than one regular expression describes the longest possible prefix, then the regular expression that comes first in the .jj file is used.
In your case rule 3 applied. You can rewrite start
as
void Start() :
{}
{
<ODDSPACE> | <SPACE>
}