First read Question 4.16, ” What does it mean to put a regular expression within a BNF production?” .
For regular expressions that are simply strings, you might as well put them directly into the BNF productions, and not bother with defining them in a regular expression production.8 For more complex regular expressions, it is best to give them a name, using a regular expression production. There are two reasons for this. The first is error reporting. If you give a complex regular expression a name, that name will be used in the message attached to any ParseExceptions generated. If you don’t give it a name, JavaCC will make up a name like ” < token of kind 42 > “. The second is perspicuity.