[antlr-interest] Question about idiom.

Michael Richter ttmrichter at gmail.com
Fri Jan 8 20:32:05 PST 2010


I keep coming across a pattern in a grammar I'm working on.  This pattern
looks something like this:

   - A production can be *A*.
   - A production can be *B*.
   - A production can be *A B.*

In the grammar I'm transcribing this from, the notation used is *(A & B)*.
Is there some convenient way to code that in ANTLR's EBNF notation?  I keep
having to do *(A | B | A B)*.  As is that isn't all that onerous as-is, I
admit, but imagine if A is five tokens long and B is also five tokens long
and then imagine this kind of pattern happening about twenty times in the
grammar.  Is there a way to concisely do this?


More information about the antlr-interest mailing list