This term is used in relation to musical composition and analysis as an analogy to grammatical functions and rules in language, and operational rules in the computing sense of the term. The term is invariably allied with attempts to formalise musical knowledge and perceptual response. In composition, grammar may be broadly associated with procedures that make definitions of micro-structural 'units' and proceed to establish operational procedures for their organisation into macro-structures. It is therefore associated with, e.g., stochastic, fractal and generative approaches to composition.
Formalist approaches to musical analysis may attempt, through defining grammar-based rules, to model perceptual responses to music.
Many concerned with formalist grammars are interested in approaches (usually through computing) to model the process of composition itself.