Checking grammar consistency

Selecting "Check variables" in the "Search" menu produces a report on variables used in the grammar. Some variables may be undefined, i.e. they appear in the right argument of a rule and nowhere in the left argument of a grammar or glossary rule. The grammar might therefore produce final strings containing these variables. BP2 warns the user at compile time if the grammar contains undefined variables. The grammar may nevertheless be used: when interpreting the final string as a musical item, BP2 ignores left-over variables. When compiling a glossary, however, an error message is returned if any rule or "Define" instruction produced an undefined variable.

Conversely, unreachable variables are the ones found in the left argument of a rule although they appear in no right argument, so that the grammar will never produce them. This is generally not considered a mistake because a grammar may contain unreachable variables coming from an earlier version. Rules containing them will never be candidates. Glossaries may also contain many unreachable variables because a project is generally not using all functionalities of MIDI devices -- it is not likely to make use of the 128 instruments defined in General MIDI, for instance.

When compiling a glossary (see §7), BP2 makes sure that it does not generate variables appearing in the left argument of a grammar rule. Since the glossary is used only once all candidate rules in the grammar have been exhausted (or there is no grammar), the grammar may not be invoked afterwards.