Production procedures

_destru works exactly as described in §4.5, but it will only be performed if the rule in which it appears is a candidate rule.

_goto is an unconditional jump to another subgrammar or another specific rule in a subgrammar. Its syntax is

_goto(igram,irul)
where igram is the index of the destination grammar and irul the index of the destination rule. In case irul = 0, BP2 will jump to subgrammar igram and look for any candidate rule. If (igram,irul) does not point at a candidate rule, BP2 will either execute a _failed conditional jump (see infra) or search a candidate rule in subgrammar igram. If none is found it will jump to subgrammar igram+1, etc. as usual.

When compiling the grammar BP2 will check that there is a rule indexed irul in subgrammar igram. If there is no such rule an error will be reported.

_failed is a conditional jump to another subgrammar or another specific rule in a subgrammar. Its syntax is

_failed(igram,irul)
in which igram and irul have the same meanings as in _goto. The jump will be performed if the rule was selected by a preceding _goto or _failed and it was not a candidate rule.

_repeat is a loop. Its simplest syntax is

_repeat(n)
where n is an integer value indicating that the current rule should be tried n times. Alternate syntaxes are

_repeat(Kx) and _repeat(Kx = n)
where Kx is a parameter that may be assigned a fixed value (Kx = n) and/or controlled in real time by an external MIDI device (see QuickStart §6). Remember that fixed value assignment must be done only once in the entire grammar.

Both _repeat and _goto may appear in the same rule, e.g.:

X --> a b _repeat(12) _goto(4,8)
In this case, _goto(4,8) will be performed once the rule has been applied 12 times or it is no longer candidate.

See example "-gr.tryrepeat" for important remarks.