Trainable grammars for speech recognition