Compound Grammar Indexing
It is possible to index a compound grammar like an array in order to reference a single grammar contained in the compound grammar. This is done using the [] operator and is similar to indexing an array. Whether the compound grammar is represented with the || operator or is a grammar from the grammar repository that would result into a compound grammar.
If the supplied index is out of bounds, a parse time or an evaluation time ExpressionArrayIndexOutOfBoundsException may be thrown as a result. If the grammar being indexed does not represent a compound grammar then an ExpressionClassCastException is thrown.
Compound Grammar Indexing Examples, Each of which Results in a Grammar Expression
G[grammar.tgl][1]
(G[grammar1.digit] || G[grammar2.grxml])[0]
((DG[dtmf-1|word=true] || G[grammar.tgl) || GG[hello|dtmf-3])[0][1]